docs.ts

Source

8 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

Reference

fnbuildSymbolMap(docs: ExtractedDocs[]): Map<string, SymbolLocation>Builds a map of all symbols to their file locations.

Builds a map of all symbols to their file locations.

View source

Parameters

  • docs ExtractedDocs[]

Returns

Map
fnconvertSymbolLinks(text: string, currentFileName: string, symbolMap: Map<string, SymbolLocation>): stringConverts symbol links [SymbolName] to markdown links. Processes description tex…

Converts symbol links [SymbolName] to markdown links. Processes description text to convert cargo-docs-style symbol references [SymbolName] into clickable markdown links pointing to the appropriate documentation page.

Examples

Input: "See [transformMarkdown] for usage" (same file) Output: "See transformMarkdown for usage" Input: "Uses NavItem interface" (different file: types.ts) Output: "Uses NavItem interface"

View source

Parameters

  • text string

    Description text containing symbol references

  • currentFileName string

    Current file name (without extension) for same-file detection

  • symbolMap Map

    Map of symbol names to their file locations

Returns

string

Text with symbol references converted to markdown links

fnextractDocs(srcDirs: string[], options: ResolvedDocsOptions): Promise<ExtractedDocs[]>Extracts JSDoc documentation from source files in specified directories. This f…

Extracts JSDoc documentation from source files in specified directories. This function recursively searches directories for source files matching the include/exclude patterns, then extracts all documented items (functions, classes, interfaces, types) from those files.

Process

  1. File Discovery: Recursively walks directories, applying filters
  2. File Reading: Loads each matching file's content
  3. JSDoc Extraction: Parses JSDoc comments using regex patterns
  4. Declaration Matching: Pairs JSDoc comments with source declarations
  5. Result Collection: Aggregates extracted documentation by file

Include/Exclude Patterns

Patterns support:

  • ** - Match any directory structure
  • * - Match any filename
  • Standard glob patterns (e.g., **\/*.test.ts)

Performance Considerations

  • Uses filesystem I/O which can be slow for large codebases
  • Consider using more specific include patterns to reduce file scanning
  • Results are not cached; call once per build/dev session Each ExtractedDocs object contains file path and array of DocEntry items.

View source

Parameters

  • srcDirs string[]

    Array of source directory paths to scan

  • options ResolvedDocsOptions

    Documentation extraction options (filters, grouping, etc.)

Returns

Promise

Promise resolving to array of extracted documentation by file.

Examples

const docs = await extractDocs(
  ['./packages/vite-plugin/src'],
  {
    enabled: true,
    src: [],
    out: 'docs',
    include: ['**\/*.ts'],
    exclude: ['**\/*.test.ts', '**\/*.spec.ts'],
    format: 'markdown',
    private: false,
    toc: true,
    groupBy: 'file',
    generateNav: true,
  }
);
// Returns:
// [
//   {
//     file: '/path/to/transform.ts',
//     entries: [
//       { name: 'transformMarkdown', kind: 'function', ... },
//       { name: 'loadNapiBindings', kind: 'function', ... },
//     ]
//   },
//   ...
// ]
fnfindFiles(dir: string, options: ResolvedDocsOptions): Promise<string[]>Recursively finds all source files matching include/exclude patterns.

Recursively finds all source files matching include/exclude patterns.

View source

Parameters

  • dir string
  • options ResolvedDocsOptions

Returns

Promise
fngenerateMarkdown(docs: ExtractedDocs[], options: ResolvedDocsOptions): Record<string, string>Generates Markdown documentation from extracted docs.

Generates Markdown documentation from extracted docs.

View source

Parameters

  • docs ExtractedDocs[]
  • options ResolvedDocsOptions

Returns

Record
fngenerateSourceHref(filePath: string, githubUrl: string, lineNumber?: number, endLineNumber?: number): stringGenerates a GitHub source link for a file and optional line range.

Generates a GitHub source link for a file and optional line range.

View source

Parameters

  • filePath string

    Full path to the source file

  • githubUrl string

    Base GitHub repository URL

  • lineNumber number

    Optional start line number to link to — optional

  • endLineNumber number

    Optional end line number to link to — optional

Returns

string

Absolute GitHub URL to source code

interfaceSymbolLocationSymbol location info for cross-file linking.

Symbol location info for cross-file linking.

View source

fnwriteDocs(docs: Record<string, string>, outDir: string, extractedDocs?: ExtractedDocs[], options?: ResolvedDocsOptions): Promise<void>Writes generated documentation to the output directory.

Writes generated documentation to the output directory.

View source

Parameters

  • docs Record
  • outDir string
  • extractedDocs ExtractedDocs[]

    optional

  • options ResolvedDocsOptions

    optional

Returns

Promise