Skip to content

Commit

Permalink
chore(types): lint the api docs with typescript (#3577)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelEinbinder authored and aslushnikov committed Nov 21, 2018
1 parent fb5b080 commit a0cbaf3
Show file tree
Hide file tree
Showing 17 changed files with 453 additions and 336 deletions.
12 changes: 6 additions & 6 deletions docs/api.md
Expand Up @@ -1102,7 +1102,7 @@ Get the browser the page belongs to.
#### page.click(selector[, options])
- `selector` <[string]> A [selector] to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]> Promise which resolves when the element matching `selector` is successfully clicked. The Promise will be rejected if there is no element matching `selector`.
Expand Down Expand Up @@ -2183,7 +2183,7 @@ await page.mouse.up();
- `x` <[number]>
- `y` <[number]>
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]>
Expand All @@ -2192,7 +2192,7 @@ Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownopt

#### mouse.down([options])
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- returns: <[Promise]>

Expand All @@ -2209,7 +2209,7 @@ Dispatches a `mousemove` event.

#### mouse.up([options])
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- returns: <[Promise]>

Expand Down Expand Up @@ -2407,7 +2407,7 @@ Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<s
#### frame.click(selector[, options])
- `selector` <[string]> A [selector] to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]> Promise which resolves when the element matching `selector` is successfully clicked. The Promise will be rejected if there is no element matching `selector`.
Expand Down Expand Up @@ -3000,7 +3000,7 @@ This method returns boxes of the element, or `null` if the element is not visibl

#### elementHandle.click([options])
- `options` <[Object]>
- `button` <[string]> `left`, `right`, or `middle`, defaults to `left`.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- returns: <[Promise]> Promise which resolves when the element is successfully clicked. Promise gets rejected if the element is detached from DOM.
Expand Down
47 changes: 27 additions & 20 deletions utils/doclint/check_public_api/Documentation.js
Expand Up @@ -20,6 +20,7 @@ class Documentation {
*/
constructor(classesArray) {
this.classesArray = classesArray;
/** @type {!Map<string, !Documentation.Class>} */
this.classes = new Map();
for (const cls of classesArray)
this.classes.set(cls.name, cls);
Expand All @@ -34,74 +35,80 @@ Documentation.Class = class {
constructor(name, membersArray) {
this.name = name;
this.membersArray = membersArray;
/** @type {!Map<string, !Documentation.Member>} */
this.members = new Map();
/** @type {!Map<string, !Documentation.Member>} */
this.properties = new Map();
/** @type {!Map<string, !Documentation.Member>} */
this.methods = new Map();
/** @type {!Map<string, !Documentation.Member>} */
this.events = new Map();
for (const member of membersArray) {
this.members.set(member.name, member);
if (member.type === 'method')
if (member.kind === 'method')
this.methods.set(member.name, member);
else if (member.type === 'property')
else if (member.kind === 'property')
this.properties.set(member.name, member);
else if (member.type === 'event')
else if (member.kind === 'event')
this.events.set(member.name, member);
}
}
};

Documentation.Member = class {
/**
* @param {string} type
* @param {string} kind
* @param {string} name
* @param {!Array<!Documentation.Argument>} argsArray
* @param {boolean} hasReturn
* @param {boolean} async
* @param {!Documentation.Type} type
* @param {!Array<!Documentation.Member>} argsArray
*/
constructor(type, name, argsArray, hasReturn, async) {
this.type = type;
constructor(kind, name, type, argsArray) {
this.kind = kind;
this.name = name;
this.type = type;
this.argsArray = argsArray;
/** @type {!Map<string, !Documentation.Member>} */
this.args = new Map();
this.hasReturn = hasReturn;
this.async = async;
for (const arg of argsArray)
this.args.set(arg.name, arg);
}

/**
* @param {string} name
* @param {!Array<!Documentation.Argument>} argsArray
* @param {boolean} hasReturn
* @param {!Array<!Documentation.Member>} argsArray
* @param {?Documentation.Type} returnType
* @return {!Documentation.Member}
*/
static createMethod(name, argsArray, hasReturn, async) {
return new Documentation.Member('method', name, argsArray, hasReturn, async);
static createMethod(name, argsArray, returnType) {
return new Documentation.Member('method', name, returnType, argsArray,);
}

/**
* @param {string} name
* @param {!Documentation.Type}
* @return {!Documentation.Member}
*/
static createProperty(name) {
return new Documentation.Member('property', name, [], false, false);
static createProperty(name, type) {
return new Documentation.Member('property', name, type, []);
}

/**
* @param {string} name
* @return {!Documentation.Member}
*/
static createEvent(name) {
return new Documentation.Member('event', name, [], false, false);
return new Documentation.Member('event', name, null, []);
}
};

Documentation.Argument = class {
Documentation.Type = class {
/**
* @param {string} name
* @param {!Array<!Documentation.Member>=} properties
*/
constructor(name) {
constructor(name, properties = []) {
this.name = name;
this.properties = properties;
}
};

Expand Down

0 comments on commit a0cbaf3

Please sign in to comment.