Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions new-docs/puppeteer.consolemessage._constructor_.md
Expand Up @@ -9,15 +9,15 @@ Constructs a new instance of the `ConsoleMessage` class
<b>Signature:</b>

```typescript
constructor(type: string, text: string, args: JSHandle[], location?: ConsoleMessageLocation);
constructor(type: ConsoleMessageType, text: string, args: JSHandle[], location?: ConsoleMessageLocation);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| type | string | |
| type | [ConsoleMessageType](./puppeteer.consolemessagetype.md) | |
| text | string | |
| args | [JSHandle](./puppeteer.jshandle.md)<!-- -->\[\] | |
| location | ConsoleMessageLocation | |
| location | [ConsoleMessageLocation](./puppeteer.consolemessagelocation.md) | |

2 changes: 2 additions & 0 deletions new-docs/puppeteer.consolemessage.args.md
Expand Up @@ -13,3 +13,5 @@ args(): JSHandle[];

[JSHandle](./puppeteer.jshandle.md)<!-- -->\[\]

An array of arguments passed to the console.

4 changes: 3 additions & 1 deletion new-docs/puppeteer.consolemessage.location.md
Expand Up @@ -11,5 +11,7 @@ location(): ConsoleMessageLocation;
```
<b>Returns:</b>

ConsoleMessageLocation
[ConsoleMessageLocation](./puppeteer.consolemessagelocation.md)

The location of the console message.

2 changes: 2 additions & 0 deletions new-docs/puppeteer.consolemessage.md
Expand Up @@ -4,6 +4,8 @@

## ConsoleMessage class

ConsoleMessage objects are dispatched by page via the 'console' event.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions new-docs/puppeteer.consolemessage.text.md
Expand Up @@ -13,3 +13,5 @@ text(): string;

string

The text of the console message.

6 changes: 4 additions & 2 deletions new-docs/puppeteer.consolemessage.type.md
Expand Up @@ -7,9 +7,11 @@
<b>Signature:</b>

```typescript
type(): string;
type(): ConsoleMessageType;
```
<b>Returns:</b>

string
[ConsoleMessageType](./puppeteer.consolemessagetype.md)

The type of the console message.

13 changes: 13 additions & 0 deletions new-docs/puppeteer.consolemessagelocation.columnnumber.md
@@ -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;
```
13 changes: 13 additions & 0 deletions new-docs/puppeteer.consolemessagelocation.linenumber.md
@@ -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;
```
21 changes: 21 additions & 0 deletions new-docs/puppeteer.consolemessagelocation.md
@@ -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. |

13 changes: 13 additions & 0 deletions new-docs/puppeteer.consolemessagelocation.url.md
@@ -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;
```
13 changes: 13 additions & 0 deletions new-docs/puppeteer.consolemessagetype.md
@@ -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';
```
4 changes: 3 additions & 1 deletion new-docs/puppeteer.md
Expand Up @@ -14,7 +14,7 @@
| [BrowserFetcher](./puppeteer.browserfetcher.md) | |
| [CDPSession](./puppeteer.cdpsession.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) | |
| [Dialog](./puppeteer.dialog.md) | Dialog instances are dispatched by the [Page](./puppeteer.page.md) via the <code>dialog</code> event. |
| [ElementHandle](./puppeteer.elementhandle.md) | |
Expand Down Expand Up @@ -54,6 +54,7 @@
| Interface | Description |
| --- | --- |
| [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. |
| [SnapshotOptions](./puppeteer.snapshotoptions.md) | |

Expand All @@ -68,6 +69,7 @@

| Type Alias | Description |
| --- | --- |
| [ConsoleMessageType](./puppeteer.consolemessagetype.md) | The supported types for console messages. |
| [MouseButtonInput](./puppeteer.mousebuttoninput.md) | |
| [PuppeteerErrors](./puppeteer.puppeteererrors.md) | |

55 changes: 51 additions & 4 deletions src/common/ConsoleMessage.ts
Expand Up @@ -16,20 +16,55 @@

import { JSHandle } from './JSHandle';

interface ConsoleMessageLocation {
/**
* @public
*/
export interface ConsoleMessageLocation {
/**
* URL of the resource if known or `undefined` otherwise.
*/
url?: string;

/**
* 0-based line number in the resource if known or `undefined` otherwise.
*/
lineNumber?: number;

/**
* 0-based column number in the resource if known or `undefined` otherwise.
*/
columnNumber?: number;
}

// Prettier seems to struggle with the ConsoleMessageType declaration
// so it is switched off just for that block.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't know. As per our offline conversation, it seems unhappy in the context of the file itself. Maybe a version difference?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe! Let's leave this be for now. Not worth blocking.

/* 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';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this type already exist in src/protocol.d.ts ? If so could we import it to avoid the duplication? It might not (there's ongoing work to get us onto the devtools-protocol npm package) and in that case this is fine

Copy link
Contributor Author

@paullewis paullewis Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out no. While there is something similar in the protocol, because it's autogenerated we can't get at the values.


/* eslint-enable prettier/prettier */

/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export class ConsoleMessage {
private _type: string;
private _type: ConsoleMessageType;
private _text: string;
private _args: JSHandle[];
private _location: ConsoleMessageLocation;

/**
* @public
*/
constructor(
type: string,
type: ConsoleMessageType,
text: string,
args: JSHandle[],
location: ConsoleMessageLocation = {}
Expand All @@ -40,18 +75,30 @@ export class ConsoleMessage {
this._location = location;
}

type(): string {
/**
* @returns The type of the console message.
*/
type(): ConsoleMessageType {
return this._type;
}

/**
* @returns The text of the console message.
*/
text(): string {
return this._text;
}

/**
* @returns An array of arguments passed to the console.
*/
args(): JSHandle[] {
return this._args;
}

/**
* @returns The location of the console message.
*/
location(): ConsoleMessageLocation {
return this._location;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/Page.ts
Expand Up @@ -38,7 +38,7 @@ import { HTTPResponse } from './HTTPResponse';
import { Accessibility } from './Accessibility';
import { TimeoutSettings } from './TimeoutSettings';
import { FileChooser } from './FileChooser';
import { ConsoleMessage } from './ConsoleMessage';
import { ConsoleMessage, ConsoleMessageType } from './ConsoleMessage';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher';
import Protocol from '../protocol';

Expand Down Expand Up @@ -775,7 +775,7 @@ export class Page extends EventEmitter {
}

private _addConsoleMessage(
type: string,
type: ConsoleMessageType,
args: JSHandle[],
stackTrace?: Protocol.Runtime.StackTrace
): void {
Expand Down