import { TSDocParser } from '@microsoft/tsdoc'; import * as tsm from 'ts-morph'; import { Index, Thunk } from '../lib/utils'; export interface Settings { projectDir: string; /** * Absolute path to the source root. This should match the path that rootDir * resolves to from the project's tsconfig.json. */ sourceDir: string; sourceMainModulePath: string; sourceModuleToPackagePathMappings?: Record; } /** * Create a new set of docs. */ export declare class Manager { settings: Settings; constructor(settings: Settings); EDD: DocPackage; tsdocParser: TSDocParser; isIndexable(t: tsm.Type): boolean; isIndexed(name: string): boolean; getFromIndex(name: string): Node; getFQTN(t: tsm.Type): string; indexTypeAliasNode(n: tsm.TypeAliasDeclaration, doc: Thunk): Node; indexTypeIfApplicable(t: tsm.Type, doc: Thunk): Node; isMainModule(sf: tsm.SourceFile): boolean; getImportFromPath(sf: tsm.SourceFile): string; } export declare function getFQTNFromTypeAliasNode(sourceRoot: string, n: tsm.TypeAliasDeclaration): string; export declare function getFQTNFromType(sourceRoot: string, t: tsm.Type): string; export declare type Node = DocTypeUnion | DocTypePrimitive | DocTypeLiteral | DocTypeAlias | DocTypeInterface | DocTypeCallable | DocTypeArray | DocTypeObject | DocTypeIndexRef | DocUnsupported | DocTypeIntersection; export declare type IndexableNode = DocTypeAlias | DocTypeInterface; export declare type TypeNode = DocTypeUnion | DocTypeIntersection | DocTypePrimitive | DocTypeLiteral | DocTypeAlias | DocTypeInterface | DocTypeCallable | DocTypeArray | DocTypeObject; export declare type TSDocFrag = { /** * The extracted tsdoc for this entity (module, type, term). If none, is null. */ tsdoc: null | TSDoc; }; export interface TSDoc { summary: string; examples: { text: string; }[]; customTags: { name: string; text: string; }[]; raw: string; } export declare type RawFrag = { raw: { typeText: string; nodeText: string; nodeFullText: string; }; }; export declare type TypeIndex = Index; export declare type Expor = { kind: 'export'; name: string; isTerm: boolean; isType: boolean; type: Node; }; declare type ExporInput = { name: string; node: tsm.ExportedDeclarations; type: Node; }; export declare function expor(input: ExporInput): Expor; /** * A module (aka. file) */ export declare type DocModule = TSDocFrag & { /** * Tells you the kind of data (aka. schema) contained within this object. */ kind: 'module'; /** * The name of the module (aka. file name). File extension or directory path not included. */ name: string; /** * The path to this module from package root. If this module is the main * module then the path will be `/`. * * @remarks * * This is what a user would place in their import `from` string _following_ the * package name. For example: * * ```ts * import foo from "@foo/bar/quux/toto" * // ^^^^^^^^^^ * ``` */ path: string; /** * Is this module the main one of the package? * * @remarks * * The main module of a package is the one that is specified in the * package.json "main" field. */ isMain: boolean; /** * Information about the main export from the module. If none, is null. * * @remarks * * The "main" export is the one exported using the `export default ...` syntax. */ mainExport: null | Node; /** * Information about the named exports from the module. Being empty means the module * does not have any named exports (it may still have a mainExport though). */ namedExports: Expor[]; /** * Detailed location info about the module on disk. */ location: { /** * The file path to the module relative to the project root. */ filePath: string; }; }; declare type ModInput = { name: string; mainExport?: null | Node; isMain: boolean; namedExports?: Expor[]; tsdoc: TSDocFrag['tsdoc']; path: string; location: { filePath: string; }; }; export declare function mod(input: ModInput): DocModule; export declare function modFromSourceFile(manager: Manager, sourceFile: tsm.SourceFile): DocModule; export declare function tsDocFromText(manager: Manager, raw: string): { raw: string; summary: string; examples: { text: string; }[]; customTags: { name: string; text: string; }[]; }; /** * The root of the extracted JSON that Tydoc produces. */ export declare type DocPackage = { /** * List of the extracted modules. There may be more than one because a package * may officially support importing from multiple modules. */ modules: DocModule[]; /** * An index of the all the types that have been extracted. This includes three * cases: * * 1. Directly exported types * 2. Types referenced directly or indirectly by exported types. * * If a term is exported but the type it is annotated with is not exported * then the type will not appear in the type index and the term's type info will * inlined. * * If a term is exported and so it its annotated type then the term type info * will be a reference to the type index. * * If a term is exported, but the type it is annotated with (A) is not, but the * type (A) is referenced by another type (B) that _is_ exported, then the * type (A) will appear in the type index referenced by type A, but the term * will inline the type info of type A rather than be a type index reference. */ typeIndex: TypeIndex; }; export declare type DocProp = { kind: 'prop'; name: string; type: Node; }; export declare type DocTypeArray = { kind: 'array'; innerType: Node; }; export declare function array(innerType: Node): DocTypeArray; export declare type DocTypeLiteral = { kind: 'literal'; base: string; }; export declare function literal(input: { name: string; base: string; }): DocTypeLiteral; export declare type DocTypePrimitive = { kind: 'primitive'; type: string; }; export declare function prim(type: string): DocTypePrimitive; /** * A link to the type index. All named types go into the type index. When a type * or export includes a named type, rather than documenting it inline, a * reference to the type index is created. * */ export declare type DocTypeIndexRef = { kind: 'typeIndexRef'; /** * An identifier that can be used to lookup the type in the type index. * * @example * * ```ts * docs.typeIndex[typeIndexRef.link] * ``` */ link: string; }; export declare function typeIndexRef(link: string): DocTypeIndexRef; export declare type DocTypeAlias = { kind: 'alias'; name: string; type: Node; } & RawFrag & TSDocFrag; declare type AliasInput = Omit; export declare function alias(input: AliasInput): DocTypeAlias; export declare type DocTypeInterface = { kind: 'interface'; name: string; props: DocProp[]; } & RawFrag & TSDocFrag; declare type InterInput = Omit; export declare function inter(input: InterInput): DocTypeInterface; export declare function prop(input: { name: string; type: Node; }): DocProp; export declare type DocTypeObject = { kind: 'object'; props: DocProp[]; } & RawFrag; declare type objInput = Omit; export declare function obj(input: objInput): DocTypeObject; export declare type DocTypeCallable = { kind: 'callable'; isOverloaded: boolean; hasProps: boolean; /** * Signatures extracted for this function. * * @remarks * * This is an array because overloaded functions have multiple signatures. Look at property "isOverloaded" to know if this function is overloaded or not. If it is overloaded that means this array is guaranteed to have two or more signatures. Otherwise this array is guaranteed to have exactly one signature. */ sigs: DocSig[]; props: DocProp[]; } & RawFrag; declare type callableInput = Omit; export declare function callable(input: callableInput): DocTypeCallable; export declare type DocSig = { kind: 'sig'; params: DocSigParam[]; return: Node; }; export declare function sig(input: { params: DocSigParam[]; return: Node; }): DocSig; export declare type DocSigParam = { kind: 'sigParam'; name: string; type: Node; }; export declare function sigParam(input: { name: string; type: Node; }): DocSigParam; export declare type DocUnsupported = { kind: 'unsupported'; } & RawFrag; export declare function unsupported(raw: RawFrag): DocUnsupported; export declare type DocTypeIntersection = { kind: 'intersection'; types: Node[]; } & RawFrag; declare type IntersectionInput = Omit; export declare function intersection(input: IntersectionInput): DocTypeIntersection; export declare type DocTypeUnion = { kind: 'union'; isDiscriminated: boolean; discriminantProperties: null | string[]; types: Node[]; } & RawFrag; declare type UnionInput = { types: Node[]; discriminantProperties: string[]; } & RawFrag; export declare function union(input: UnionInput): DocTypeUnion; export {}; //# sourceMappingURL=doc.d.ts.map