Skip to content

Commit

Permalink
docs: add enum aliases (#5335)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Feb 5, 2021
1 parent c0610cc commit 4b74f56
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
5 changes: 1 addition & 4 deletions docs/src/api/class-elementhandle.md
Expand Up @@ -504,10 +504,7 @@ The file path to save the image to. The screenshot type will be inferred from fi
relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
saved to the disk.

### option: ElementHandle.screenshot.type
- `type` <"png"|"jpeg">

Specify screenshot type, defaults to `png`.
### option: ElementHandle.screenshot.type = %%-screenshot-type-%%

### option: ElementHandle.screenshot.quality
- `quality` <[int]>
Expand Down
9 changes: 3 additions & 6 deletions docs/src/api/class-page.md
Expand Up @@ -712,13 +712,13 @@ page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
```

### option: Page.emulateMedia.media
- `media` <[null]|"screen"|"print">
- `media` <null|[MediaEnum]<"screen"|"print">>

Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`.
Passing `null` disables CSS media emulation.

### option: Page.emulateMedia.colorScheme
- `colorScheme` <[null]|"light"|"dark"|"no-preference">
- `colorScheme` <null|[ColorSchemeEnum]<"light"|"dark"|"no-preference">>

Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
`null` disables color scheme emulation.
Expand Down Expand Up @@ -1844,10 +1844,7 @@ The file path to save the image to. The screenshot type will be inferred from fi
relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
saved to the disk.

### option: Page.screenshot.type
- `type` <"png"|"jpeg">

Specify screenshot type, defaults to `png`.
### option: Page.screenshot.type = %%-screenshot-type-%%

### option: Page.screenshot.quality
- `quality` <[int]>
Expand Down
17 changes: 11 additions & 6 deletions docs/src/api/params.md
@@ -1,5 +1,5 @@
## navigation-wait-until
- `waitUntil` <"load"|"domcontentloaded"|"networkidle">
- `waitUntil` <[WaitUntilEnum]<"load"|"domcontentloaded"|"networkidle">>

When to consider operation succeeded, defaults to `load`. Events can be either:
* `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
Expand Down Expand Up @@ -56,13 +56,13 @@ A point to use relative to the top-left corner of element padding box. If not sp
element.

## input-modifiers
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `modifiers` <[Array]<[ModifierEnum]<"Alt"|"Control"|"Meta"|"Shift">>>

Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
modifiers back. If not specified, currently pressed modifiers are used.

## input-button
- `button` <"left"|"right"|"middle">
- `button` <[ButtonEnum]<"left"|"right"|"middle">>

Defaults to `left`.

Expand All @@ -88,7 +88,7 @@ defaults to 1. See [UIEvent.detail].
A selector to query for. See [working with selectors](./selectors.md) for more details.

## wait-for-selector-state
- `state` <"attached"|"detached"|"visible"|"hidden">
- `state` <[ElementStateEnum]<"attached"|"detached"|"visible"|"hidden">>

Defaults to `'visible'`. Can be either:
* `'attached'` - wait for element to be present in DOM.
Expand Down Expand Up @@ -321,7 +321,7 @@ Whether to emulate network being offline. Defaults to `false`.
Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).

## context-option-colorscheme
- `colorScheme` <"light"|"dark"|"no-preference">
- `colorScheme` <[ColorSchemeEnum]<"light"|"dark"|"no-preference">>

Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
[`method: Page.emulateMedia`] for more details. Defaults to '`light`'.
Expand Down Expand Up @@ -432,14 +432,19 @@ A glob pattern, regex pattern or predicate receiving [URL] to match while waitin
Event name, same one typically passed into `*.on(event)`.

## wait-for-load-state-state
- `state` <"load"|"domcontentloaded"|"networkidle">
- `state` <[LoadStateEnum]<"load"|"domcontentloaded"|"networkidle">>

Optional load state to wait for, defaults to `load`. If the state has been already reached while loading current document, the
method resolves immediately. Can be one of:
* `'load'` - wait for the `load` event to be fired.
* `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
* `'networkidle'` - wait until there are no network connections for at least `500` ms.

## screenshot-type
- `type` <[ScreenshotTypeEnum]<"png"|"jpeg">>

Specify screenshot type, defaults to `png`.

## java-wait-for-event-callback
* langs: java
- `callback` <[Runnable]>
Expand Down
25 changes: 24 additions & 1 deletion utils/doclint/documentation.js
Expand Up @@ -27,6 +27,7 @@ const md = require('../markdown');
* retType: ParsedType | null,
* template: ParsedType | null,
* union: ParsedType | null,
* unionName?: string,
* next: ParsedType | null,
* }} ParsedType
*/
Expand Down Expand Up @@ -428,7 +429,8 @@ Documentation.Type = class {
*/
static fromParsedType(parsedType, inUnion = false) {
if (!inUnion && parsedType.union) {
const type = new Documentation.Type('union');
const name = parsedType.unionName || '';
const type = new Documentation.Type(name);
type.union = [];
for (let t = parsedType; t; t = t.union)
type.union.push(Documentation.Type.fromParsedType(t, true));
Expand Down Expand Up @@ -527,6 +529,21 @@ Documentation.Type = class {
}
};

/**
* @param {ParsedType} type
* @returns {boolean}
*/
function isStringUnion(type) {
if (!type.union)
return false;
while (type) {
if (!type.name.startsWith('"') || !type.name.endsWith('"'))
return false;
type = type.union;
}
return true;
}

/**
* @param {string} type
* @returns {ParsedType}
Expand Down Expand Up @@ -571,6 +588,12 @@ function parseTypeExpression(type) {
union = parseTypeExpression(type.substring(firstTypeLength + 1));
else if (type[firstTypeLength] === ',')
next = parseTypeExpression(type.substring(firstTypeLength + 1));

if (template && !template.unionName && isStringUnion(template)) {
template.unionName = name;
return template;
}

return {
name,
args,
Expand Down

0 comments on commit 4b74f56

Please sign in to comment.