docs: introduce deprecation annotation and any type (#4930)

This commit is contained in:
Pavel Feldman 2021-01-07 11:11:40 -08:00 committed by GitHub
parent 913f85249f
commit 4cd989c653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 45 deletions

View File

@ -583,11 +583,8 @@ pages to read its geolocation.
## async method: BrowserContext.setHTTPCredentials ## async method: BrowserContext.setHTTPCredentials
Provide credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). **DEPRECATED** Browsers may cache credentials after successful authentication.
Create a new browser context instead.
> **NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing
`null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context
instead.
### param: BrowserContext.setHTTPCredentials.httpCredentials ### param: BrowserContext.setHTTPCredentials.httpCredentials
- `httpCredentials` <[null]|[Object]> - `httpCredentials` <[null]|[Object]>
@ -644,7 +641,7 @@ BrowserContext.route`].
Optional handler function used to register a routing with [`method: BrowserContext.route`]. Optional handler function used to register a routing with [`method: BrowserContext.route`].
## async method: BrowserContext.waitForEvent ## async method: BrowserContext.waitForEvent
- returns: <[Object]> - returns: <[any]>
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
value. Will throw an error if the context closes before the event is fired. Returns the event data value. value. Will throw an error if the context closes before the event is fired. Returns the event data value.
@ -2187,7 +2184,7 @@ Video object associated with this page.
- `height` <[int]> page height in pixels. - `height` <[int]> page height in pixels.
## async method: Page.waitForEvent ## async method: Page.waitForEvent
- returns: <[Object]> - returns: <[any]>
Returns the event data value. Returns the event data value.
@ -4505,7 +4502,7 @@ Request's post body, if any.
Request's post body in a binary form, if any. Request's post body in a binary form, if any.
## method: Request.postDataJSON ## method: Request.postDataJSON
- returns: <[null]|[Object]> - returns: <[null]|[any]>
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
@ -4838,7 +4835,7 @@ Indicates that the web socket has been closed.
Contains the URL of the WebSocket. Contains the URL of the WebSocket.
## async method: WebSocket.waitForEvent ## async method: WebSocket.waitForEvent
- returns: <[Object]> - returns: <[any]>
Returns the event data value. Returns the event data value.

View File

@ -222,18 +222,14 @@ Logger sink for Playwright logging.
## context-option-videospath ## context-option-videospath
- `videosPath` <[path]> - `videosPath` <[path]>
**NOTE** Use [`option: recordVideo`] instead, it takes precedence over [`option: videosPath`]. Enables video recording for all pages to [`option: videosPath`] directory. If not specified, videos are not recorded. Make sure to await **DEPRECATED** Use [`option: recordVideo`] instead.
[`method: BrowserContext.close`] for videos to be saved.
## context-option-videosize ## context-option-videosize
- `videoSize` <[Object]> - `videoSize` <[Object]>
- `width` <[int]> Video frame width. - `width` <[int]> Video frame width.
- `height` <[int]> Video frame height. - `height` <[int]> Video frame height.
**NOTE** Use [`option: recordVideo`] instead, it takes precedence over [`option: videoSize`]. Specifies dimensions of the automatically **DEPRECATED** Use [`option: recordVideo`] instead.
recorded video. Can only be used if [`option: videosPath`] is set. If not specified the size will be equal to `viewport`. If
`viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled
down if necessary to fit specified size.
## context-option-recordhar ## context-option-recordhar
- `recordHar` <[Object]> - `recordHar` <[Object]>

45
types/types.d.ts vendored
View File

@ -4945,11 +4945,8 @@ export interface BrowserContext {
}): Promise<void>; }): Promise<void>;
/** /**
* Provide credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). * **DEPRECATED** Browsers may cache credentials after successful authentication. Create a new browser context instead.
* * @deprecated
* > **NOTE** Browsers may cache credentials after successful authentication. Passing different credentials or passing
* `null` to disable authentication will be unreliable. To remove or replace credentials, create a new browser context
* instead.
* @param httpCredentials * @param httpCredentials
*/ */
setHTTPCredentials(httpCredentials: null|{ setHTTPCredentials(httpCredentials: null|{
@ -6461,10 +6458,8 @@ export interface BrowserType<Browser> {
userAgent?: string; userAgent?: string;
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically * **DEPRECATED** Use `recordVideo` instead.
* recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If * @deprecated
* `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled
* down if necessary to fit specified size.
*/ */
videoSize?: { videoSize?: {
/** /**
@ -6479,10 +6474,8 @@ export interface BrowserType<Browser> {
}; };
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to * **DEPRECATED** Use `recordVideo` instead.
* `videosPath` directory. If not specified, videos are not recorded. Make sure to await * @deprecated
* [browserContext.close()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextclose) for
* videos to be saved.
*/ */
videosPath?: string; videosPath?: string;
@ -7272,10 +7265,8 @@ export interface Browser extends EventEmitter {
userAgent?: string; userAgent?: string;
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically * **DEPRECATED** Use `recordVideo` instead.
* recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If * @deprecated
* `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled
* down if necessary to fit specified size.
*/ */
videoSize?: { videoSize?: {
/** /**
@ -7290,10 +7281,8 @@ export interface Browser extends EventEmitter {
}; };
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to * **DEPRECATED** Use `recordVideo` instead.
* `videosPath` directory. If not specified, videos are not recorded. Make sure to await * @deprecated
* [browserContext.close()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextclose) for
* videos to be saved.
*/ */
videosPath?: string; videosPath?: string;
@ -7924,7 +7913,7 @@ export interface Request {
* When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. * When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
* Otherwise it will be parsed as JSON. * Otherwise it will be parsed as JSON.
*/ */
postDataJSON(): null|Object; postDataJSON(): null|any;
/** /**
* Request that was redirected by the server to this one, if any. * Request that was redirected by the server to this one, if any.
@ -9299,10 +9288,8 @@ export interface BrowserContextOptions {
userAgent?: string; userAgent?: string;
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videoSize`. Specifies dimensions of the automatically * **DEPRECATED** Use `recordVideo` instead.
* recorded video. Can only be used if `videosPath` is set. If not specified the size will be equal to `viewport`. If * @deprecated
* `viewport` is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled
* down if necessary to fit specified size.
*/ */
videoSize?: { videoSize?: {
/** /**
@ -9317,10 +9304,8 @@ export interface BrowserContextOptions {
}; };
/** /**
* **NOTE** Use `recordVideo` instead, it takes precedence over `videosPath`. Enables video recording for all pages to * **DEPRECATED** Use `recordVideo` instead.
* `videosPath` directory. If not specified, videos are not recorded. Make sure to await * @deprecated
* [browserContext.close()](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsercontextclose) for
* videos to be saved.
*/ */
videosPath?: string; videosPath?: string;

View File

@ -16,6 +16,8 @@
// @ts-check // @ts-check
const md = require('../markdown');
/** @typedef {import('../markdown').MarkdownNode} MarkdownNode */ /** @typedef {import('../markdown').MarkdownNode} MarkdownNode */
/** /**
@ -177,6 +179,13 @@ Documentation.Member = class {
this.args.set(arg.name, arg); this.args.set(arg.name, arg);
/** @type {!Documentation.Class} */ /** @type {!Documentation.Class} */
this.clazz = null; this.clazz = null;
this.deprecated = false;
if (spec) {
md.visitAll(spec, node => {
if (node.text && node.text.includes('**DEPRECATED**'))
this.deprecated = true;
});
}
} }
clone() { clone() {

View File

@ -330,6 +330,8 @@ function stringifySimpleType(type, indent = '', ...namespace) {
} }
if (out === 'path') if (out === 'path')
return 'string'; return 'string';
if (out === 'Any')
return 'any';
if (type.templates) if (type.templates)
out += '<' + type.templates.map(t => stringifySimpleType(t, indent, ...namespace)).join(', ') + '>'; out += '<' + type.templates.map(t => stringifySimpleType(t, indent, ...namespace)).join(', ') + '>';
if (type.union) if (type.union)
@ -353,6 +355,8 @@ function memberJSDOC(member, indent) {
const lines = []; const lines = [];
if (member.comment) if (member.comment)
lines.push(...member.comment.split('\n')); lines.push(...member.comment.split('\n'));
if (member.deprecated)
lines.push('@deprecated');
lines.push(...member.argsArray.map(arg => `@param ${arg.name.replace(/\./g, '')} ${arg.comment.replace('\n', ' ')}`)); lines.push(...member.argsArray.map(arg => `@param ${arg.name.replace(/\./g, '')} ${arg.comment.replace('\n', ' ')}`));
if (!lines.length) if (!lines.length)
return indent; return indent;