Skip to content

Paka.Extractor

Paka / Extractor

Import

typescript
import { Paka } from '@wollybeard/kit'

// Access via namespace
Paka.Extractor.someFunction()
typescript
import * as Paka from '@wollybeard/kit/paka'

// Access via namespace
Paka.Extractor.someFunction()

Functions

[F] extractFromFiles

typescript
(params: { projectRoot?: string; files: Layout; entrypoints?: string[]; extractorVersion?: string; filterUnderscoreExports?: boolean; }): Package

Parameters:

  • params - Extraction parameters including files layout

Returns: Complete interface model

Pure extraction function that processes files without I/O. Takes all files as input and returns the extracted model.

Examples:

typescript
const 
layout
= Dir.spec('/')
.add('package.json', {
name
: 'x',
exports
: { './foo': './build/foo/$.js' } })
.add('src/foo/$.ts', 'export const bar = () => {}') .toLayout() const
model
=
Paka
.Extractor.extractFromFiles({
files
:
layout
})

[F] extract

typescript
(config: ExtractConfig): Package

Parameters:

  • config - Extraction configuration

Returns: Complete interface model

Extract documentation model from TypeScript source files.

[F] categorize

typescript
(decl: Node<ts.Node>): Category

Parameters:

  • decl - The declaration node to categorize

Returns: Category with level (value/type) and specific type

Categorize a TypeScript declaration node into export level and type.

[F] extractExport

typescript
(name: string, decl: ExportedDeclarations): ValueExport | TypeExport

Parameters:

  • name - The export name
  • decl - The declaration node

Returns: Export object with all metadata

Extract export information from a declaration node.

[F] parseJSDoc

typescript
(decl: Node<ts.Node>): JSDocInfo

Parameters:

  • decl - The declaration node to extract JSDoc from

Returns: Parsed JSDoc information

Parse JSDoc from a declaration node.

[F] extractModuleFromFile

typescript
(sourceFile: SourceFile, location: RelFile, options?: ModuleExtractionOptions = {}): Module

Parameters:

  • sourceFile - The source file to extract from
  • location - Relative file path from project root
  • options - Extraction options for filtering

Returns: Module with all exports

Extract a module from a source file.

[F] extractModule

typescript
(moduleDecl: ModuleDeclaration, location: RelFile, options?: ModuleExtractionOptions = {}): Module

Parameters:

  • moduleDecl - The module/namespace declaration
  • location - Relative file path from project root
  • options - Extraction options for filtering

Returns: Module with all namespace exports

Extract a module from a namespace declaration.

Types

[T] ExtractConfig

typescript
type ExtractConfig = {
  /** Project root directory */
  projectRoot: string
  /** Path to tsconfig.json */
  tsconfigPath?: string
  /** Specific entrypoints to extract (if not specified, extracts all from package.json) */
  entrypoints?: string[]
  /** Extractor version */
  extractorVersion?: string
  /** Filter exports that start with underscore `_` prefix (default: false) */
  filterUnderscoreExports?: boolean
}

Configuration for extraction.

[T] Category

typescript
type Category = {
  level: ExportLevel
  type: ValueExportType | TypeExportType
}

Categorization result for a declaration node.

[T] JSDocInfo

typescript
type JSDocInfo = {
  description: string | undefined
  examples: Example[]
  deprecated: string | undefined
  category: string | undefined
  tags: Record<string, string>
  /** Force this export to be treated as a namespace */
  forceNamespace?: boolean
  /** Mark this export as a builder pattern entry point */
  isBuilder?: boolean
  /** Mark this export as internal (should not appear in public documentation) */
  internal?: boolean
  /** Parameter descriptions from @param tags (name -> description) */
  params: Record<string, string>
  /** Return value description from @returns tag */
  returns: string | undefined
  /** Error descriptions from @throws tags */
  throws: string[]
}

Parsed JSDoc information.

[T] ModuleExtractionOptions

typescript
type ModuleExtractionOptions = {
  /** Filter exports marked with @internal */
  filterInternal?: boolean
  /** Filter exports starting with underscore _ prefix */
  filterUnderscoreExports?: boolean
}

Options for module extraction.