UNPKG

ts2md

Version:

Simple Typescript Documentation Generator to GitHub Compatible MarkDown

98 lines 3.21 kB
import ts from "typescript"; import { Ts2MdOptions } from "./Ts2MdOptions"; import { DocGenSupportApi } from "./JSDocs"; /** * Uses the Typescript compiler to parse source tree given a top level source file such as `index.ts`. * * Extract the exported API interfaces, classes, types, functions and variables. * * Generate GitHub friendly MarkDown documentation for the extracted API leveraging TypeScript type information * and merging JSDoc style documentation comments. * * The following JSDoc tags are supported: * * `@example` Adds example as code block or comments and embedded code block(s). * * `@param` Adds comment for function or method parameter. * * `@private` Hides an otherwise accessible documentation item. * * `@privateinitializer` Hides property initializer from documentation typescript. * * `@property` Adds comment for class or interface property parameter in parent's JSDoc comment. * * `@publicbody` Overrides the normal hidding of method and function bodies. * * `@returns` Adds comment for function or method return value. * * `@throws` Adds thrown error comment to function or method. */ export declare class TypescriptToMarkdown implements DocGenSupportApi { options: Ts2MdOptions; mdLinksEx?: Record<string, string> | undefined; private program; /** * @private */ printer: ts.Printer; private sourceFiles; private docs; /** * For each symbol name, the markdown link which will exist in this document. */ private mdLinks; /** * mdLinks that are not defined in the current outputPath */ private mdLinksExternal; noDetailsSummary: boolean; /** * @private */ nothingPrivate: boolean; /** * The top level input Typescript file's filename with full path. */ filePath: string; /** * The top level input Typescript file's filename without path */ fileName: string; /** * The generated documentation as markdown string */ markDown?: string; /** * The file path to which `markDown` was written. */ outputPath?: string; /** * Construct a new instance configured for `run` method to be called next. * * @param options Must be provided. inputFilename defaults to `./src/index.ts` */ constructor(options: Ts2MdOptions, mdLinksEx?: Record<string, string> | undefined); /** * Generates the documentation markdown and write's it to output file * and/or merges it to README.md */ run(): { outputPath: string; mdLinks: Record<string, string>; mdLinksExternal: Record<string, string>; }; /** * @private */ headingLevelMd(relativeLevel: number): string; private parseSourceFiles; private extractDocs; private generateMarkDown; /** * Generates a markdown table of named links to docItem documentation headers. * @param doc The category of documentation for which to generate the table. * @returns markdown table of named links to docItem documentation headers */ private generateDocItemLinksTable; } //# sourceMappingURL=TypescriptToMarkdown.d.ts.map