Paka.Extractor
Paka / Extractor
Import
import { Paka } from '@wollybeard/kit'
// Access via namespace
Paka.Extractor.someFunction()
import * as Paka from '@wollybeard/kit/paka'
// Access via namespace
Paka.Extractor.someFunction()
Functions
[F]
extractFromFiles
(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:
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
(config: ExtractConfig): Package
Parameters:
config
- Extraction configuration
Returns: Complete interface model
Extract documentation model from TypeScript source files.
[F]
categorize
(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
(name: string, decl: ExportedDeclarations): ValueExport | TypeExport
Parameters:
name
- The export namedecl
- The declaration node
Returns: Export object with all metadata
Extract export information from a declaration node.
[F]
parseJSDoc
(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
(sourceFile: SourceFile, location: RelFile, options?: ModuleExtractionOptions = {}): Module
Parameters:
sourceFile
- The source file to extract fromlocation
- Relative file path from project rootoptions
- Extraction options for filtering
Returns: Module with all exports
Extract a module from a source file.
[F]
extractModule
(moduleDecl: ModuleDeclaration, location: RelFile, options?: ModuleExtractionOptions = {}): Module
Parameters:
moduleDecl
- The module/namespace declarationlocation
- Relative file path from project rootoptions
- Extraction options for filtering
Returns: Module with all namespace exports
Extract a module from a namespace declaration.
Types
[T]
ExtractConfig
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
type Category = {
level: ExportLevel
type: ValueExportType | TypeExportType
}
Categorization result for a declaration node.
[T]
JSDocInfo
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
type ModuleExtractionOptions = {
/** Filter exports marked with @internal */
filterInternal?: boolean
/** Filter exports starting with underscore _ prefix */
filterUnderscoreExports?: boolean
}
Options for module extraction.