Skip to content

Source

4 exports Added in v4.0.0 Source

Extraction

extract

Added in v4.0.0 Source

Extracts marked TypeScript code snippets from documentation text.

Details

Extraction uses an ordered text scan and does not parse the containing source file.

Signature

declare function extract(source: string, format: SourceFormat): readonly Array<Snippet>

extractFile

Added in v4.0.0 Source

Reads a file and extracts its marked code snippets.

Signature

declare function extractFile(file: string): Promise<readonly Array<Snippet>>

Models

Snippet interface

Added in v4.0.0 Source

Represents an executable TypeScript code snippet.

Signature

interface Snippet {
  readonly line: number;
  readonly name: string | undefined;
  readonly source: string;
}

SourceFormat type

Added in v4.0.0 Source

Identifies how documentation is embedded in the source text.

Signature

type SourceFormat = "jsdoc" | "markdown";