import * as tsm from 'ts-morph'; import { PackageJson } from 'type-fest'; import { DiagnosticFilter } from '../lib/ts-helpers'; import * as Doc from './doc'; export interface FromProjectParams { /** * Paths to modules in project, relative to source root or absolute. */ entrypoints: string[]; /** * Should Tydoc settings be read from from the package file. */ readSettingsFromJSON?: boolean; /** * Sometimes a source entrypoint is fronted by a facade module that allows * package consumers to do e.g. `import foo from "bar/toto"` _instead of_ * `import foo from "bar/dist/toto". Use this mapping to force tydoc to view * the given source modules (the keys) at the given package path (the values). * * @example * * Given project layout: * * ``` * /src/foo/bar/toto.ts * ``` * * The setting: * * ```ts * sourceModuleToPackagePathMappings: { * "foo/bar/toto": "toto" * } * ``` * * Will cause the `toto` module to be documented as being available at path: * * ```ts * import some from "thing/toto" * ``` */ sourceModuleToPackagePathMappings?: Record; layout?: { /** * Should Tydoc halt when TypeScript diagnostics are raised? * * Pass true to halt on any diagnostic * * Pass false to ignore all diagnostics * * Pass an array of filters to ignore only certain diagnostics. * * @default true * * @remarks * * Typically your package should be error free before documentation is extracted for it. However there may be cases where you want to bypass this check in general or for specific kinds of type check errors. For example a @ts-expect-error that is erroring because there is no error. * */ validateTypeScriptDiagnostics?: boolean | DiagnosticFilter[]; /** * Should the projectDir and sourceMainModulePath be validated that they exist on disk? * * @default true */ validateExists?: boolean; /** * Absolute path to the source main entrypoint. * * @default A discovery attempt is made by running heuristics against a combination of package.json and tsconfig.json however it only covers common patterns, not all possible setups. */ sourceMainModulePath?: string; /** * Specify the root of the project. * * @default The current working directory * @remarks This is useful for tests to avoid having to mock process.cwd */ projectDir?: string; sourceDir?: string; packageJson?: PackageJson; tsMorphProject?: tsm.Project; }; } export declare function fromPublished(options: { packageName: string; packageVersion?: string; project?: tsm.Project; downloadDir?: string; }): Promise; /** * Recursively extract docs from the given project starting from the exports of * the given list of entrypoint modules. Everything that is reachable from the * exports will be considered part of the API. */ export declare function fromProject(options: FromProjectParams): Doc.DocPackage; /** * Recursively extract docs starting from exports of the given module. * Everything that is reachable will be considered. */ export declare function fromModule(manager: Doc.Manager, sourceFile: tsm.SourceFile): Doc.DocPackage; export declare function fromType(manager: Doc.Manager, t: tsm.Type): Doc.Node; /** * Extract tsdoc docs for the given type. * * @return * * If the node associated with the type does not support JSDoc (not all node * types do) then `null` is returned. * * If the node associated with the type does not have JSDoc present in the * source code then `null` is returned. */ export declare function getTSDoc(manager: Doc.Manager, t: tsm.Type): Doc.TSDocFrag; //# sourceMappingURL=extract.d.ts.map