@ts-ast-parser/core
Version:
Reflects a simplified version of the TypeScript AST for generating documentation
110 lines • 3.64 kB
TypeScript
import type { ReflectedNode } from '../reflected-node.js';
import type { DeclarationKind } from '../models/declaration-kind.js';
import type { ExportNode, ImportNode } from '../utils/types.js';
import type { DeclarationNode } from './declaration-node.js';
import type { ProjectContext } from '../project-context.js';
import type { Module } from '../models/module.js';
import { CommentNode } from './comment-node.js';
import ts from 'typescript';
/**
* Represents a reflected module as a collection of imports, exports and
* class/interface/function/type-alias/enum declarations
*/
export declare class ModuleNode implements ReflectedNode<Module, ts.SourceFile> {
private _declarations;
private readonly _exports;
private readonly _imports;
private readonly _node;
private readonly _context;
private readonly _jsDoc;
constructor(node: ts.SourceFile, context: ProjectContext);
/**
* The original TypeScript node
*
* @returns The TypeScript AST node associated with this module
*/
getTSNode(): ts.SourceFile;
/**
* The path to the source file for this module relative to the current
* working directory
*
* @returns The relative path where the module is located
*/
getSourcePath(): string;
/**
* The path where the JS file will be output by the TypeScript Compiler
*
* @returns The relative path where the TypeScript compiler would emit the JS module. If
* the source file is a JS file, it returns the source path.
*/
getOutputPath(): string;
/**
* The context includes useful APIs that are shared across
* all the reflected symbols.
*
* Some APIs include the parsed configuration options, the
* system interface, the type checker
*
* @returns The analyser context
*/
getContext(): ProjectContext;
/**
* All the import declarations found in the source file
*
* @returns The reflected import declarations
*/
getImports(): ImportNode[];
/**
* All the export declarations found in the source file
*
* @returns The reflected export declarations
*/
getExports(): ExportNode[];
/**
* All the class/interface/function/type-alias/enum declarations found
* in the source file
*
* @returns The reflected declaration nodes
*/
getDeclarations(): DeclarationNode[];
/**
* Reflects the module-level JSDoc comment
*
* @returns The module-level JSDoc comment blocks for a given source file.
*/
getJSDoc(): CommentNode;
/**
* Finds a declaration based on it's kind
*
* @param kind - The declaration kind
* @returns All declaration nodes found
*/
getDeclarationByKind(kind: DeclarationKind): DeclarationNode[];
/**
* Finds a declaration based on it's name
*
* @param name - The declaration name
* @returns The matched declaration found if any
*/
getDeclarationByName(name: string): DeclarationNode | null;
/**
* Returns all the declarations that have the tag `@category`
* with the specified name
*
* @param category - The category name
* @returns All declaration nodes found
*/
getDeclarationsByCategory(category: string): DeclarationNode[];
/**
* Serializes the reflected node
*
* @returns The reflected node as a serializable object
*/
serialize(): Module;
private _visitNode;
private _add;
private _hasDeclaration;
private _hasExport;
private _removeNonPublicDeclarations;
}
//# sourceMappingURL=module-node.d.ts.map