docs(new): migrate ConsoleMessage docs to TSDoc (#6065)

This commit is contained in:
Paul Lewis 2020-06-22 13:52:39 +01:00 committed by GitHub
parent 983a7b67df
commit 819afbebf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 145 additions and 13 deletions

View File

@ -9,15 +9,15 @@ Constructs a new instance of the `ConsoleMessage` class
<b>Signature:</b> <b>Signature:</b>
```typescript ```typescript
constructor(type: string, text: string, args: JSHandle[], location?: ConsoleMessageLocation); constructor(type: ConsoleMessageType, text: string, args: JSHandle[], location?: ConsoleMessageLocation);
``` ```
## Parameters ## Parameters
| Parameter | Type | Description | | Parameter | Type | Description |
| --- | --- | --- | | --- | --- | --- |
| type | string | | | type | [ConsoleMessageType](./puppeteer.consolemessagetype.md) | |
| text | string | | | text | string | |
| args | [JSHandle](./puppeteer.jshandle.md)<!-- -->\[\] | | | args | [JSHandle](./puppeteer.jshandle.md)<!-- -->\[\] | |
| location | ConsoleMessageLocation | | | location | [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) | |

View File

@ -13,3 +13,5 @@ args(): JSHandle[];
[JSHandle](./puppeteer.jshandle.md)<!-- -->\[\] [JSHandle](./puppeteer.jshandle.md)<!-- -->\[\]
An array of arguments passed to the console.

View File

@ -11,5 +11,7 @@ location(): ConsoleMessageLocation;
``` ```
<b>Returns:</b> <b>Returns:</b>
ConsoleMessageLocation [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md)
The location of the console message.

View File

@ -4,6 +4,8 @@
## ConsoleMessage class ## ConsoleMessage class
ConsoleMessage objects are dispatched by page via the 'console' event.
<b>Signature:</b> <b>Signature:</b>
```typescript ```typescript

View File

@ -13,3 +13,5 @@ text(): string;
string string
The text of the console message.

View File

@ -7,9 +7,11 @@
<b>Signature:</b> <b>Signature:</b>
```typescript ```typescript
type(): string; type(): ConsoleMessageType;
``` ```
<b>Returns:</b> <b>Returns:</b>
string [ConsoleMessageType](./puppeteer.consolemessagetype.md)
The type of the console message.

View File

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) &gt; [columnNumber](./puppeteer.consolemessagelocation.columnnumber.md)
## ConsoleMessageLocation.columnNumber property
0-based column number in the resource if known or `undefined` otherwise.
<b>Signature:</b>
```typescript
columnNumber?: number;
```

View File

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) &gt; [lineNumber](./puppeteer.consolemessagelocation.linenumber.md)
## ConsoleMessageLocation.lineNumber property
0-based line number in the resource if known or `undefined` otherwise.
<b>Signature:</b>
```typescript
lineNumber?: number;
```

View File

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md)
## ConsoleMessageLocation interface
<b>Signature:</b>
```typescript
export interface ConsoleMessageLocation
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [columnNumber](./puppeteer.consolemessagelocation.columnnumber.md) | number | 0-based column number in the resource if known or <code>undefined</code> otherwise. |
| [lineNumber](./puppeteer.consolemessagelocation.linenumber.md) | number | 0-based line number in the resource if known or <code>undefined</code> otherwise. |
| [url](./puppeteer.consolemessagelocation.url.md) | string | URL of the resource if known or <code>undefined</code> otherwise. |

View File

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) &gt; [url](./puppeteer.consolemessagelocation.url.md)
## ConsoleMessageLocation.url property
URL of the resource if known or `undefined` otherwise.
<b>Signature:</b>
```typescript
url?: string;
```

View File

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [ConsoleMessageType](./puppeteer.consolemessagetype.md)
## ConsoleMessageType type
The supported types for console messages.
<b>Signature:</b>
```typescript
export declare type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
```

View File

@ -14,7 +14,7 @@
| [BrowserFetcher](./puppeteer.browserfetcher.md) | | | [BrowserFetcher](./puppeteer.browserfetcher.md) | |
| [CDPSession](./puppeteer.cdpsession.md) | The <code>CDPSession</code> instances are used to talk raw Chrome Devtools Protocol. | | [CDPSession](./puppeteer.cdpsession.md) | The <code>CDPSession</code> instances are used to talk raw Chrome Devtools Protocol. |
| [Connection](./puppeteer.connection.md) | | | [Connection](./puppeteer.connection.md) | |
| [ConsoleMessage](./puppeteer.consolemessage.md) | | | [ConsoleMessage](./puppeteer.consolemessage.md) | ConsoleMessage objects are dispatched by page via the 'console' event. |
| [Coverage](./puppeteer.coverage.md) | | | [Coverage](./puppeteer.coverage.md) | |
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. | | [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
| [ElementHandle](./puppeteer.elementhandle.md) | | | [ElementHandle](./puppeteer.elementhandle.md) | |
@ -54,6 +54,7 @@
| Interface | Description | | Interface | Description |
| --- | --- | | --- | --- |
| [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | | | [BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md) | |
| [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) | |
| [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. | | [SerializedAXNode](./puppeteer.serializedaxnode.md) | Represents a Node and the properties of it that are relevant to Accessibility. |
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | | | [SnapshotOptions](./puppeteer.snapshotoptions.md) | |
@ -68,6 +69,7 @@
| Type Alias | Description | | Type Alias | Description |
| --- | --- | | --- | --- |
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
| [MouseButtonInput](./puppeteer.mousebuttoninput.md) | | | [MouseButtonInput](./puppeteer.mousebuttoninput.md) | |
| [PuppeteerErrors](./puppeteer.puppeteererrors.md) | | | [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |

View File

@ -16,20 +16,55 @@
import { JSHandle } from './JSHandle'; import { JSHandle } from './JSHandle';
interface ConsoleMessageLocation { /**
* @public
*/
export interface ConsoleMessageLocation {
/**
* URL of the resource if known or `undefined` otherwise.
*/
url?: string; url?: string;
/**
* 0-based line number in the resource if known or `undefined` otherwise.
*/
lineNumber?: number; lineNumber?: number;
/**
* 0-based column number in the resource if known or `undefined` otherwise.
*/
columnNumber?: number; columnNumber?: number;
} }
// Prettier seems to struggle with the ConsoleMessageType declaration
// so it is switched off just for that block.
/* eslint-disable prettier/prettier */
/**
* The supported types for console messages.
*/
export type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' |
'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' |
'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' |
'profileEnd' | 'count' | 'timeEnd' | 'verbose';
/* eslint-enable prettier/prettier */
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export class ConsoleMessage { export class ConsoleMessage {
private _type: string; private _type: ConsoleMessageType;
private _text: string; private _text: string;
private _args: JSHandle[]; private _args: JSHandle[];
private _location: ConsoleMessageLocation; private _location: ConsoleMessageLocation;
/**
* @public
*/
constructor( constructor(
type: string, type: ConsoleMessageType,
text: string, text: string,
args: JSHandle[], args: JSHandle[],
location: ConsoleMessageLocation = {} location: ConsoleMessageLocation = {}
@ -40,18 +75,30 @@ export class ConsoleMessage {
this._location = location; this._location = location;
} }
type(): string { /**
* @returns The type of the console message.
*/
type(): ConsoleMessageType {
return this._type; return this._type;
} }
/**
* @returns The text of the console message.
*/
text(): string { text(): string {
return this._text; return this._text;
} }
/**
* @returns An array of arguments passed to the console.
*/
args(): JSHandle[] { args(): JSHandle[] {
return this._args; return this._args;
} }
/**
* @returns The location of the console message.
*/
location(): ConsoleMessageLocation { location(): ConsoleMessageLocation {
return this._location; return this._location;
} }

View File

@ -38,7 +38,7 @@ import { HTTPResponse } from './HTTPResponse';
import { Accessibility } from './Accessibility'; import { Accessibility } from './Accessibility';
import { TimeoutSettings } from './TimeoutSettings'; import { TimeoutSettings } from './TimeoutSettings';
import { FileChooser } from './FileChooser'; import { FileChooser } from './FileChooser';
import { ConsoleMessage } from './ConsoleMessage'; import { ConsoleMessage, ConsoleMessageType } from './ConsoleMessage';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher'; import { PuppeteerLifeCycleEvent } from './LifecycleWatcher';
import Protocol from '../protocol'; import Protocol from '../protocol';
@ -775,7 +775,7 @@ export class Page extends EventEmitter {
} }
private _addConsoleMessage( private _addConsoleMessage(
type: string, type: ConsoleMessageType,
args: JSHandle[], args: JSHandle[],
stackTrace?: Protocol.Runtime.StackTrace stackTrace?: Protocol.Runtime.StackTrace
): void { ): void {