@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
34 lines (32 loc) • 1.5 kB
TypeScript
import { type ExportedDeclarations, type ModuleDeclaration, type Project, type SourceFile } from "ts-morph";
import type { ExtractedDeclaration } from "./types.js";
/** `ExtractDeclarationsOptions` contains the options for calling {@link extractDeclarations}. */
export interface ExtractDeclarationsOptions {
/** Container that exports the top-level declarations. */
container: SourceFile | ModuleDeclaration;
/**
Container name (e.g., the name of a namespace), used to generate declaration IDs.
*/
containerName: string;
/** Maximum extraction depth for nested namespaces. */
maxDepth: number;
/** Instance of a `ts-morph` `Project`, used to find ambient modules. */
project?: Project;
/** Name of the package being analyzed, used to filter ambient modules. */
pkgName?: string;
}
/** `FoundDeclaration` represents a declaration found during the initial extraction process. */
export interface FoundDeclaration {
/** Declaration container name. */
containerName: string;
/** Export name (may differ from the original name). */
exportName: string;
/** Declaration. */
declaration: ExportedDeclarations;
}
/**
`extractDeclarations` extracts the top-level declarations
found in a container and/or a project.
@param options - {@link ExtractDeclarationsOptions}
*/
export declare function extractDeclarations({ containerName, container, maxDepth, project, pkgName, }: ExtractDeclarationsOptions): Promise<ExtractedDeclaration[]>;