docs: fix the docs validator (#86)

This commit is contained in:
Pavel Feldman 2019-11-26 08:52:47 -08:00 committed by GitHub
parent 66d3dd8626
commit 991f4a9072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 21 deletions

View File

@ -160,7 +160,7 @@
- [class: Keyboard](#class-keyboard) - [class: Keyboard](#class-keyboard)
* [keyboard.down(key[, options])](#keyboarddownkey-options) * [keyboard.down(key[, options])](#keyboarddownkey-options)
* [keyboard.press(key[, options])](#keyboardpresskey-options) * [keyboard.press(key[, options])](#keyboardpresskey-options)
* [keyboard.sendCharacter(char)](#keyboardsendcharacterchar) * [keyboard.sendCharacters(text)](#keyboardsendcharacterstext)
* [keyboard.type(text[, options])](#keyboardtypetext-options) * [keyboard.type(text[, options])](#keyboardtypetext-options)
* [keyboard.up(key)](#keyboardupkey) * [keyboard.up(key)](#keyboardupkey)
- [class: Mouse](#class-mouse) - [class: Mouse](#class-mouse)
@ -1240,7 +1240,7 @@ List of all available devices is available in the source code: [DeviceDescriptor
#### page.emulateMedia(options) #### page.emulateMedia(options)
- `options` <[Object]> - `options` <[Object]>
- `type` <?[string]> Optional. Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null` disables CSS media emulation. - `type` <?[string]> Optional. Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null` disables CSS media emulation.
- `colorScheme` <?[string]> Optional. Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. - `colorScheme` <"dark"|"light"|"no-preference"> Optional. Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`.
- returns: <[Promise]> - returns: <[Promise]>
```js ```js
@ -2127,7 +2127,7 @@ function findFocusedNode(node) {
Keyboard provides an api for managing a virtual keyboard. The high level api is [`keyboard.type`](#keyboardtypetext-options), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page. Keyboard provides an api for managing a virtual keyboard. The high level api is [`keyboard.type`](#keyboardtypetext-options), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
For finer control, you can use [`keyboard.down`](#keyboarddownkey-options), [`keyboard.up`](#keyboardupkey), and [`keyboard.sendCharacter`](#keyboardsendcharacterchar) to manually fire events as if they were generated from a real keyboard. For finer control, you can use [`keyboard.down`](#keyboarddownkey-options), [`keyboard.up`](#keyboardupkey), and [`keyboard.sendCharacters`](#keyboardsendcharacterstext) to manually fire events as if they were generated from a real keyboard.
An example of holding down `Shift` in order to select and delete some text: An example of holding down `Shift` in order to select and delete some text:
```js ```js
@ -2181,17 +2181,17 @@ If `key` is a single character and no modifier keys besides `Shift` are being he
Shortcut for [`keyboard.down`](#keyboarddownkey-options) and [`keyboard.up`](#keyboardupkey). Shortcut for [`keyboard.down`](#keyboarddownkey-options) and [`keyboard.up`](#keyboardupkey).
#### keyboard.sendCharacter(char) #### keyboard.sendCharacters(text)
- `char` <[string]> Character to send into the page. - `text` <[string]> Characters to send into the page.
- returns: <[Promise]> - returns: <[Promise]>
Dispatches a `keypress` and `input` event. This does not send a `keydown` or `keyup` event. Dispatches a `keypress` and `input` event. This does not send a `keydown` or `keyup` event.
```js ```js
page.keyboard.sendCharacter('嗨'); page.keyboard.sendCharacters('嗨');
``` ```
> **NOTE** Modifier keys DO NOT effect `keyboard.sendCharacter`. Holding down `Shift` will not type the text in upper case. > **NOTE** Modifier keys DO NOT effect `keyboard.sendCharacters`. Holding down `Shift` will not type the text in upper case.
#### keyboard.type(text[, options]) #### keyboard.type(text[, options])
- `text` <[string]> A text to type into a focused element. - `text` <[string]> A text to type into a focused element.
@ -2240,6 +2240,10 @@ await page.mouse.up();
- `button` <"left"|"right"|"middle"> Defaults to `left`. - `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail]. - `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0. - `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]> - returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions). Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
@ -2250,6 +2254,10 @@ Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownopt
- `options` <[Object]> - `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`. - `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0. - `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]> - returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions). Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
@ -2277,6 +2285,10 @@ Dispatches a `mousemove` event.
- `options` <[Object]> - `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`. - `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0. - `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]> - returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions). Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
@ -3134,10 +3146,12 @@ page.on('request', request => {
``` ```
#### interception.disable() #### interception.disable()
- returns: <[Promise]>
Disables network request interception. Disables network request interception.
#### interception.enable() #### interception.enable()
- returns: <[Promise]>
Once request interception is enabled, every request will stall unless it's continued, responded or aborted. Once request interception is enabled, every request will stall unless it's continued, responded or aborted.
An example of a naïve request interceptor that aborts all image requests: An example of a naïve request interceptor that aborts all image requests:

View File

@ -326,7 +326,7 @@ export class ElementHandle extends JSHandle {
if (error) if (error)
throw new Error(error); throw new Error(error);
await this.focus(); await this.focus();
await this._page.keyboard.sendCharacter(value); await this._page.keyboard.sendCharacters(value);
} }
async uploadFile(...filePaths: string[]) { async uploadFile(...filePaths: string[]) {

View File

@ -378,7 +378,7 @@ export class ElementHandle extends JSHandle {
if (error) if (error)
throw new Error(error); throw new Error(error);
await this.focus(); await this.focus();
await this._frame._page.keyboard.sendCharacter(value); await this._frame._page.keyboard.sendCharacters(value);
} }
async _clickablePoint(): Promise<{ x: number; y: number; }> { async _clickablePoint(): Promise<{ x: number; y: number; }> {

View File

@ -123,7 +123,7 @@ export class Keyboard {
await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.key, description.location); await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.key, description.location);
} }
async sendCharacter(text: string) { async sendCharacters(text: string) {
await this._raw.sendText(text); await this._raw.sendText(text);
} }
@ -135,7 +135,7 @@ export class Keyboard {
} else { } else {
if (delay) if (delay)
await new Promise(f => setTimeout(f, delay)); await new Promise(f => setTimeout(f, delay));
await this.sendCharacter(char); await this.sendCharacters(char);
} }
} }
} }

View File

@ -5,12 +5,12 @@ type Boxed<Args extends any[], Handle> = { [Index in keyof Args]: Args[Index] |
type PageFunction<Args extends any[], R = any> = string | ((...args: Args) => R | Promise<R>); type PageFunction<Args extends any[], R = any> = string | ((...args: Args) => R | Promise<R>);
type PageFunctionOn<On, Args extends any[], R = any> = string | ((on: On, ...args: Args) => R | Promise<R>); type PageFunctionOn<On, Args extends any[], R = any> = string | ((on: On, ...args: Args) => R | Promise<R>);
export type Evaluate<Handle> = <Args extends any[], R>(fn: PageFunction<Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; export type Evaluate<Handle> = <Args extends any[], R>(pageFunction: PageFunction<Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
export type EvaluateHandle<Handle> = <Args extends any[]>(fn: PageFunction<Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>; export type EvaluateHandle<Handle> = <Args extends any[]>(pageFunction: PageFunction<Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
export type $Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; export type $Eval<Handle> = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
export type $$Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; export type $$Eval<Handle> = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
export type EvaluateOn<Handle> = <Args extends any[], R>(fn: PageFunctionOn<any, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>; export type EvaluateOn<Handle> = <Args extends any[], R>(pageFunction: PageFunctionOn<any, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
export type EvaluateHandleOn<Handle> = <Args extends any[]>(fn: PageFunctionOn<any, Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>; export type EvaluateHandleOn<Handle> = <Args extends any[]>(pageFunction: PageFunctionOn<any, Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
export interface EvaluationContext<Handle> { export interface EvaluationContext<Handle> {
evaluate: Evaluate<Handle>; evaluate: Evaluate<Handle>;

View File

@ -256,7 +256,7 @@ export class ElementHandle extends JSHandle {
if (error) if (error)
throw new Error(error); throw new Error(error);
await this.focus(); await this.focus();
await this._page.keyboard.sendCharacter(value); await this._page.keyboard.sendCharacters(value);
} }
async focus() { async focus() {

View File

@ -76,10 +76,10 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {
it('should send a character with sendCharacter', async({page, server}) => { it('should send a character with sendCharacter', async({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html'); await page.goto(server.PREFIX + '/input/textarea.html');
await page.focus('textarea'); await page.focus('textarea');
await page.keyboard.sendCharacter('嗨'); await page.keyboard.sendCharacters('嗨');
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨'); expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨');
await page.evaluate(() => window.addEventListener('keydown', e => e.preventDefault(), true)); await page.evaluate(() => window.addEventListener('keydown', e => e.preventDefault(), true));
await page.keyboard.sendCharacter('a'); await page.keyboard.sendCharacters('a');
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨a'); expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨a');
}); });
it.skip(FFOX)('should report shiftKey', async({page, server}) => { it.skip(FFOX)('should report shiftKey', async({page, server}) => {

View File

@ -116,7 +116,7 @@ function checkSources(sources) {
const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration); const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
const name = symbol.getName(); const name = symbol.getName();
if (symbol.valueDeclaration.dotDotDotToken) { if (symbol.valueDeclaration.dotDotDotToken) {
const innerType = serializeType(type.typeArguments[0], circular); const innerType = serializeType(type.typeArguments ? type.typeArguments[0] : type, circular);
innerType.name = '...' + innerType.name; innerType.name = '...' + innerType.name;
return Documentation.Member.createProperty('...' + name, innerType); return Documentation.Member.createProperty('...' + name, innerType);
} }