-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(docs): fixup and lint optionals and return values in api.md #1376
fix(docs): fixup and lint optionals and return values in api.md #1376
Conversation
utils/doclint/cli.js
Outdated
firefoxVersion: browserVersions.firefox, | ||
}))); | ||
messages.push(...await preprocessor.ensureReleasedAPILinks([readme], VERSION)); | ||
// const preprocessor = require('./preprocessor'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
draft, its not done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we spell out our policy? Something like the following or not?
- Optional arguments are denoted as [, arg] in the arg list.
- All incoming object properties are optional by default.
- All incoming object properties which are required are marked as required.
- Outgoing object properties can not be optional (only nullable).
- "?" means nullable, both in incoming and outgoing.
@@ -205,7 +205,7 @@ Indicates that the browser is connected. | |||
- `geolocation` <[Object]> | |||
- `latitude` <[number]> Latitude between -90 and 90. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required here?
docs/api.md
Outdated
@@ -3718,7 +3718,7 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'. | |||
|
|||
#### browserType.connect(options) | |||
- `options` <[Object]> | |||
- `wsEndpoint` <[string]> A browser websocket endpoint to connect to. | |||
- `wsEndpoint` <[string]> A browser websocket endpoint to connect to. **required** | |||
- `slowMo` <?[number]> Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove '?' here?
a340ba7
to
9622d70
Compare
docs/api.md
Outdated
@@ -1750,7 +1749,7 @@ const [response] = await Promise.all([ | |||
Shortcut for [page.mainFrame().waitForNavigation(options)](#framewaitfornavigationoptions). | |||
|
|||
#### page.waitForRequest(urlOrPredicate[, options]) | |||
- `urlOrPredicate` <?[string]|[RegExp]|[Function]> Optional. Request URL string, regex or predicate receiving [Request] object. | |||
- `urlOrPredicate` <[string]|[RegExp]|[Function]> Optional. Request URL string, regex or predicate receiving [Request] object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the implementation, urlOrPredicate
is not optional. Let's update the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
docs/api.md
Outdated
@@ -1766,7 +1765,7 @@ await page.waitForRequest(request => request.url().searchParams.get('foo') === ' | |||
``` | |||
|
|||
#### page.waitForResponse(urlOrPredicate[, options]) | |||
- `urlOrPredicate` <?[string]|[RegExp]|[Function]> Optional. Request URL string, regex or predicate receiving [Response] object. | |||
- `urlOrPredicate` <[string]|[RegExp]|[Function]> Optional. Request URL string, regex or predicate receiving [Response] object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -2931,9 +2930,9 @@ function, it **will not be called**. | |||
|
|||
#### consoleMessage.location() | |||
- returns: <[Object]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We return an object with optional fields? Let's make them nullable instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are helpful when JSON stringifying or console logging these objects in node. I'd rather not change implementation in this patch.
- `invalid` <[string]> Whether and in what way this node's value is invalid. | ||
- `orientation` <[string]> Whether the node is oriented horizontally or vertically. | ||
- `children` <[Array]<[Object]>> Child [AXNode]s of this node, if any. | ||
- `value` <[string]|[number]> The current value of the node, if applicable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - make it nullable?
@@ -3905,7 +3904,7 @@ const v8toIstanbul = require('v8-to-istanbul'); | |||
#### chromiumCoverage.stopCSSCoverage() | |||
- returns: <[Promise]<[Array]<[Object]>>> Promise that resolves to the array of coverage reports for all stylesheets | |||
- `url` <[string]> StyleSheet URL | |||
- `text` <[string]> StyleSheet content | |||
- `text` <[string]> StyleSheet content, if available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here.
@@ -3915,8 +3914,13 @@ const v8toIstanbul = require('v8-to-istanbul'); | |||
#### chromiumCoverage.stopJSCoverage() | |||
- returns: <[Promise]<[Array]<[Object]>>> Promise that resolves to the array of coverage reports for all scripts | |||
- `url` <[string]> Script URL | |||
- `source` <[string]> Script content | |||
- `source` <[string]> Script content, if applicable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
9622d70
to
0dbe973
Compare
0dbe973
to
482121b
Compare
Currently in our API
?
means null, but sometimes it means optional. Linting optional/nulls with this patch is required for #1166 to land nicely.Previously, return types were not being linted in
api.md
. This is fixed, along with many broken return types.This patch considers
?
to mean nullable, and has some heuristics to determine optionality. I believe this to be the minimal patch needed to unblock #1166. After it lands, we can consider changing the api docs to hopefully remove some heuristics and strangeness.