Skip to content

Commit

Permalink
chore(docs): fix DOMWorld doc warnings (#6166)
Browse files Browse the repository at this point in the history
I noticed that DOMWorld was spitting a lot of warnings out when we
generated the docs. It was mostly easy tidy-ups and removing old JSDoc
comments and now the warnings are gone :)
  • Loading branch information
jackfranklin committed Jul 6, 2020
1 parent 782c1d4 commit e2e0502
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion new-docs/puppeteer.frame.goto.md
Expand Up @@ -19,7 +19,7 @@ goto(url: string, options?: {
| Parameter | Type | Description |
| --- | --- | --- |
| url | string | |
| options | { referer?: string; timeout?: number; waitUntil?: PuppeteerLifeCycleEvent \| PuppeteerLifeCycleEvent\[\]; } | |
| options | { referer?: string; timeout?: number; waitUntil?: [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) \| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)<!-- -->\[\]; } | |
<b>Returns:</b>
Expand Down
2 changes: 1 addition & 1 deletion new-docs/puppeteer.frame.setcontent.md
Expand Up @@ -18,7 +18,7 @@ setContent(html: string, options?: {
| Parameter | Type | Description |
| --- | --- | --- |
| html | string | |
| options | { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent \| PuppeteerLifeCycleEvent\[\]; } | |
| options | { timeout?: number; waitUntil?: [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) \| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)<!-- -->\[\]; } | |

<b>Returns:</b>

Expand Down
2 changes: 1 addition & 1 deletion new-docs/puppeteer.frame.waitfornavigation.md
Expand Up @@ -17,7 +17,7 @@ waitForNavigation(options?: {

| Parameter | Type | Description |
| --- | --- | --- |
| options | { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent \| PuppeteerLifeCycleEvent\[\]; } | |
| options | { timeout?: number; waitUntil?: [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) \| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)<!-- -->\[\]; } | |

<b>Returns:</b>

Expand Down
1 change: 1 addition & 0 deletions new-docs/puppeteer.md
Expand Up @@ -102,6 +102,7 @@
| [Platform](./puppeteer.platform.md) | Supported platforms. |
| [Product](./puppeteer.product.md) | Supported products. |
| [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |
| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) | |
| [Serializable](./puppeteer.serializable.md) | |
| [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md) | |
| [UnwrapElementHandle](./puppeteer.unwrapelementhandle.md) | Unwraps a DOM element out of an ElementHandle instance |
Expand Down
11 changes: 11 additions & 0 deletions new-docs/puppeteer.puppeteerlifecycleevent.md
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)

## PuppeteerLifeCycleEvent type

<b>Signature:</b>

```typescript
export declare type PuppeteerLifeCycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
```
2 changes: 1 addition & 1 deletion new-docs/puppeteer.waitforoptions.md
Expand Up @@ -16,5 +16,5 @@ export interface WaitForOptions
| Property | Type | Description |
| --- | --- | --- |
| [timeout](./puppeteer.waitforoptions.timeout.md) | number | Maximum wait time in milliseconds, defaults to 30 seconds, pass <code>0</code> to disable the timeout. |
| [waitUntil](./puppeteer.waitforoptions.waituntil.md) | PuppeteerLifeCycleEvent \| PuppeteerLifeCycleEvent\[\] | |
| [waitUntil](./puppeteer.waitforoptions.waituntil.md) | [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md) \| [PuppeteerLifeCycleEvent](./puppeteer.puppeteerlifecycleevent.md)<!-- -->\[\] | |

2 changes: 2 additions & 0 deletions src/api-docs-entry.ts
Expand Up @@ -54,3 +54,5 @@ export * from './common/NetworkManager';
export * from './common/WebWorker';
export * from './common/USKeyboardLayout';
export * from './common/EvalTypes';
export * from './common/TimeoutSettings';
export * from './common/LifecycleWatcher';
46 changes: 10 additions & 36 deletions src/common/DOMWorld.ts
Expand Up @@ -48,15 +48,18 @@ export interface WaitForSelectorOptions {
* @internal
*/
export class DOMWorld {
_frameManager: FrameManager;
_frame: Frame;
_timeoutSettings: TimeoutSettings;
_documentPromise?: Promise<ElementHandle> = null;
_contextPromise?: Promise<ExecutionContext> = null;
private _frameManager: FrameManager;
private _frame: Frame;
private _timeoutSettings: TimeoutSettings;
private _documentPromise?: Promise<ElementHandle> = null;
private _contextPromise?: Promise<ExecutionContext> = null;

_contextResolveCallback?: (x?: ExecutionContext) => void = null;
private _contextResolveCallback?: (x?: ExecutionContext) => void = null;

_detached = false;
private _detached = false;
/**
* internal
*/
_waitTasks = new Set<WaitTask>();

constructor(
Expand All @@ -74,9 +77,6 @@ export class DOMWorld {
return this._frame;
}

/**
* @param {?ExecutionContext} context
*/
_setContext(context?: ExecutionContext): void {
if (context) {
this._contextResolveCallback.call(null, context);
Expand All @@ -102,9 +102,6 @@ export class DOMWorld {
);
}

/**
* @returns {!Promise<!ExecutionContext>}
*/
executionContext(): Promise<ExecutionContext> {
if (this._detached)
throw new Error(
Expand All @@ -121,11 +118,6 @@ export class DOMWorld {
return context.evaluateHandle(pageFunction, ...args);
}

/**
* @param {Function|string} pageFunction
* @param {!Array<*>} args
* @returns {!Promise<*>}
*/
async evaluate<ReturnType extends any>(
pageFunction: Function | string,
...args: unknown[]
Expand All @@ -134,10 +126,6 @@ export class DOMWorld {
return context.evaluate<ReturnType>(pageFunction, ...args);
}

/**
* @param {string} selector
* @returns {!Promise<?ElementHandle>}
*/
async $(selector: string): Promise<ElementHandle | null> {
const document = await this._document();
const value = await document.$(selector);
Expand Down Expand Up @@ -188,10 +176,6 @@ export class DOMWorld {
return value;
}

/**
* @param {string} selector
* @returns {!Promise<!Array<!ElementHandle>>}
*/
async $$(selector: string): Promise<ElementHandle[]> {
const document = await this._document();
const value = await document.$$(selector);
Expand Down Expand Up @@ -249,8 +233,6 @@ export class DOMWorld {
* You can pass a URL, filepath or string of contents. Note that when running Puppeteer
* in a browser environment you cannot pass a filepath and should use either
* `url` or `content`.
*
* @param options
*/
async addScriptTag(options: {
url?: string;
Expand Down Expand Up @@ -340,7 +322,6 @@ export class DOMWorld {
* in a browser environment you cannot pass a filepath and should use either
* `url` or `content`.
*
* @param options
*/
async addStyleTag(options: {
url?: string;
Expand Down Expand Up @@ -541,13 +522,6 @@ export class DOMWorld {
}
return handle.asElement();

/**
* @param {string} selectorOrXPath
* @param {boolean} isXPath
* @param {boolean} waitForVisible
* @param {boolean} waitForHidden
* @returns {?Node|boolean}
*/
function predicate(
selectorOrXPath: string,
isXPath: boolean,
Expand Down
3 changes: 3 additions & 0 deletions src/common/LifecycleWatcher.ts
Expand Up @@ -43,6 +43,9 @@ const puppeteerToProtocolLifecycle = new Map<
['networkidle2', 'networkAlmostIdle'],
]);

/**
* @internal
*/
export class LifecycleWatcher {
_expectedLifecycle: ProtocolLifeCycleEvent[];
_frameManager: FrameManager;
Expand Down
6 changes: 3 additions & 3 deletions src/common/TimeoutSettings.ts
Expand Up @@ -16,6 +16,9 @@

const DEFAULT_TIMEOUT = 30000;

/**
* @internal
*/
export class TimeoutSettings {
_defaultTimeout: number | null;
_defaultNavigationTimeout: number | null;
Expand All @@ -29,9 +32,6 @@ export class TimeoutSettings {
this._defaultTimeout = timeout;
}

/**
* @param {number} timeout
*/
setDefaultNavigationTimeout(timeout: number): void {
this._defaultNavigationTimeout = timeout;
}
Expand Down

0 comments on commit e2e0502

Please sign in to comment.