Skip to content

Commit

Permalink
docs: improve docs (#9988)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored Apr 6, 2023
1 parent 1985249 commit 7d1734a
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 15 deletions.
10 changes: 6 additions & 4 deletions docs/browsers-api/browsers.computeexecutablepath.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ sidebar_label: computeExecutablePath
#### Signature:

```typescript
export declare function computeExecutablePath(options: Options): string;
export declare function computeExecutablePath(
options: ComputeExecutablePathOptions
): string;
```

## Parameters

| Parameter | Type | Description |
| --------- | -------------------------------- | ----------- |
| options | [Options](./browsers.options.md) | |
| Parameter | Type | Description |
| --------- | ----------------------------------------------------- | ----------- |
| options | [ComputeExecutablePathOptions](./browsers.options.md) | |

**Returns:**

Expand Down
2 changes: 1 addition & 1 deletion docs/browsers-api/browsers.install.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export declare function install(

**Returns:**

Promise<InstalledBrowser>
Promise<[InstalledBrowser](./browsers.installedbrowser.md)>
18 changes: 18 additions & 0 deletions docs/browsers-api/browsers.installedbrowser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
sidebar_label: InstalledBrowser
---

# InstalledBrowser type

#### Signature:

```typescript
export type InstalledBrowser = {
path: string;
browser: Browser;
buildId: string;
platform: BrowserPlatform;
};
```

**References:** [Browser](./browsers.browser.md), [BrowserPlatform](./browsers.browserplatform.md)
2 changes: 1 addition & 1 deletion docs/browsers-api/browsers.launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export declare function launch(opts: LaunchOptions): Process;

**Returns:**

Process
[Process](./browsers.process.md)
2 changes: 1 addition & 1 deletion docs/browsers-api/browsers.options.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_label: Options
#### Signature:

```typescript
export interface Options
export interface ComputeExecutablePathOptions
```

## Properties
Expand Down
21 changes: 21 additions & 0 deletions docs/browsers-api/browsers.process._constructor_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
sidebar_label: Process.(constructor)
---

# Process.(constructor)

Constructs a new instance of the `Process` class

#### Signature:

```typescript
class Process {
constructor(opts: LaunchOptions);
}
```

## Parameters

| Parameter | Type | Description |
| --------- | -------------------------------------------- | ----------- |
| opts | [LaunchOptions](./browsers.launchoptions.md) | |
17 changes: 17 additions & 0 deletions docs/browsers-api/browsers.process.close.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_label: Process.close
---

# Process.close() method

#### Signature:

```typescript
class Process {
close(): Promise<void>;
}
```

**Returns:**

Promise&lt;void&gt;
17 changes: 17 additions & 0 deletions docs/browsers-api/browsers.process.hasclosed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_label: Process.hasClosed
---

# Process.hasClosed() method

#### Signature:

```typescript
class Process {
hasClosed(): Promise<void>;
}
```

**Returns:**

Promise&lt;void&gt;
17 changes: 17 additions & 0 deletions docs/browsers-api/browsers.process.kill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_label: Process.kill
---

# Process.kill() method

#### Signature:

```typescript
class Process {
kill(): void;
}
```

**Returns:**

void
32 changes: 32 additions & 0 deletions docs/browsers-api/browsers.process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sidebar_label: Process
---

# Process class

#### Signature:

```typescript
export declare class Process
```

## Constructors

| Constructor | Modifiers | Description |
| ---------------------------------------------------------- | --------- | ----------------------------------------------------------- |
| [(constructor)(opts)](./browsers.process._constructor_.md) | | Constructs a new instance of the <code>Process</code> class |

## Properties

| Property | Modifiers | Type | Description |
| ----------- | --------------------- | ------------------------- | ----------- |
| nodeProcess | <code>readonly</code> | childProcess.ChildProcess | |

## Methods

| Method | Modifiers | Description |
| ---------------------------------------------------------------------------- | --------- | ----------- |
| [close()](./browsers.process.close.md) | | |
| [hasClosed()](./browsers.process.hasclosed.md) | | |
| [kill()](./browsers.process.kill.md) | | |
| [waitForLineOutput(regex, timeout)](./browsers.process.waitforlineoutput.md) | | |
24 changes: 24 additions & 0 deletions docs/browsers-api/browsers.process.waitforlineoutput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
sidebar_label: Process.waitForLineOutput
---

# Process.waitForLineOutput() method

#### Signature:

```typescript
class Process {
waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
}
```

## Parameters

| Parameter | Type | Description |
| --------- | ------ | ------------ |
| regex | RegExp | |
| timeout | number | _(Optional)_ |

**Returns:**

Promise&lt;string&gt;
8 changes: 5 additions & 3 deletions docs/browsers-api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ sidebar_label: API
| Class | Description |
| ------------------------------------------ | ----------- |
| [CLI](./browsers.cli.md) | |
| [Process](./browsers.process.md) | |
| [TimeoutError](./browsers.timeouterror.md) | |

## Enumerations
Expand Down Expand Up @@ -51,6 +52,7 @@ sidebar_label: API

## Type Aliases

| Type Alias | Description |
| -------------------------------------------- | ----------- |
| [LaunchOptions](./browsers.launchoptions.md) | |
| Type Alias | Description |
| -------------------------------------------------- | ----------- |
| [InstalledBrowser](./browsers.installedbrowser.md) | |
| [LaunchOptions](./browsers.launchoptions.md) | |
6 changes: 6 additions & 0 deletions packages/browsers/src/CLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type ClearArgs = {
path?: string;
};

/**
* @public
*/
export class CLI {
#cachePath;
#rl?: readline.Interface;
Expand Down Expand Up @@ -275,6 +278,9 @@ export class CLI {
}
}

/**
* @public
*/
export function makeProgressCallback(
browser: Browser,
buildId: string
Expand Down
9 changes: 9 additions & 0 deletions packages/browsers/src/browser-data/browser-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const executablePathByBrowser = {

export {Browser, BrowserPlatform, ChromeReleaseChannel};

/**
* @public
*/
export async function resolveBuildId(
browser: Browser,
platform: BrowserPlatform,
Expand Down Expand Up @@ -74,6 +77,9 @@ export async function resolveBuildId(
return tag;
}

/**
* @public
*/
export async function createProfile(
browser: Browser,
opts: ProfileOptions
Expand All @@ -87,6 +93,9 @@ export async function createProfile(
}
}

/**
* @public
*/
export function resolveSystemExecutablePath(
browser: Browser,
platform: BrowserPlatform,
Expand Down
13 changes: 13 additions & 0 deletions packages/browsers/src/browser-data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import * as firefox from './firefox.js';

/**
* Supported browsers.
*
* @public
*/
export enum Browser {
CHROME = 'chrome',
Expand All @@ -29,6 +31,8 @@ export enum Browser {
/**
* Platform names used to identify a OS platfrom x architecture combination in the way
* that is relevant for the browser download.
*
* @public
*/
export enum BrowserPlatform {
LINUX = 'linux',
Expand All @@ -44,15 +48,24 @@ export const downloadUrls = {
[Browser.FIREFOX]: firefox.resolveDownloadUrl,
};

/**
* @public
*/
export enum BrowserTag {
LATEST = 'latest',
}

/**
* @public
*/
export interface ProfileOptions {
preferences: Record<string, unknown>;
path: string;
}

/**
* @public
*/
export enum ChromeReleaseChannel {
STABLE = 'stable',
DEV = 'dev',
Expand Down
3 changes: 3 additions & 0 deletions packages/browsers/src/detectPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import os from 'os';

import {BrowserPlatform} from './browser-data/browser-data.js';

/**
* @public
*/
export function detectBrowserPlatform(): BrowserPlatform | undefined {
const platform = os.platform();
switch (platform) {
Expand Down
9 changes: 9 additions & 0 deletions packages/browsers/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ export interface InstallOptions {
unpack?: boolean;
}

/**
* @public
*/
export type InstalledBrowser = {
path: string;
browser: Browser;
buildId: string;
platform: BrowserPlatform;
};

/**
* @public
*/
export async function install(
options: InstallOptions
): Promise<InstalledBrowser> {
Expand Down Expand Up @@ -194,6 +200,9 @@ export async function install(
};
}

/**
* @public
*/
export async function canDownload(options: InstallOptions): Promise<boolean> {
options.platform ??= detectBrowserPlatform();
if (!options.platform) {
Expand Down
Loading

0 comments on commit 7d1734a

Please sign in to comment.