UNPKG

builddocs

Version:

Generate HTML documentation from TypeScript types and doc comments

200 lines (199 loc) 5.25 kB
export interface Binding { name: string; qualifiedName?: string; id: string; description?: string; loc?: { file: string; line: number; column: number; }; } export type Item = Item.Class | Item.Enum | Item.EnumMember | Item.Interface | Item.Variable | Item.TypeAlias | Item.Function | Item.Export | Item.Namespace; export declare namespace Item { type Class = Binding & Type.Class & { kind: "class"; abstract?: boolean; typeParams?: readonly TypeParam[]; }; type Enum = Binding & Type.Enum & { kind: "enum"; }; type EnumMember = Binding & Type & { kind: "enummember"; }; type Interface = Binding & Type.Interface & { kind: "interface"; typeParams?: readonly TypeParam[]; }; type Variable = Binding & Type & { kind: "variable"; readonly?: boolean; }; type TypeAlias = Binding & Type & { kind: "typealias"; typeParams?: readonly TypeParam[]; }; type Function = Binding & Type.Function & { kind: "function"; }; type Export = Binding & Type.Reference & { kind: "reexport"; }; type Namespace = Binding & Type.Namespace & { kind: "namespace"; }; } export type Member = Member.Property | Member.Method | Member.Constructor; export declare namespace Member { type Property = Binding & Type & { kind: "property"; abstract?: boolean; protected?: boolean; readonly?: boolean; static?: boolean; optional?: boolean; }; type Method = Binding & Type.Function & { kind: "method"; abstract?: boolean; protected?: boolean; static?: boolean; }; type Constructor = Binding & Type.Function & { kind: "constructor"; protected?: boolean; }; } export type Type = Type.Simple | Type.Namespace | Type.Reference | Type.Enum | Type.Literal | Type.Template | Type.Union | Type.Intersection | Type.Indexed | Type.KeyOf | Type.Object | Type.Class | Type.Interface | Type.Function | Type.Mapped | Type.Inferred | Type.Conditional | Type.Tuple | Type.Typeof | Type.Predicate; export declare namespace Type { type SimpleTag = "any" | "string" | "number" | "boolean" | "bigint" | "symbol" | "undefined" | "null" | "void" | "never" | "unknown"; type Simple = { type: "simple"; typeName: Type.SimpleTag; }; type Namespace = { type: "namespace"; items: readonly Item[]; }; type Reference = { type: "reference"; typeName: string; local?: string; source?: string; typeArgs?: readonly Type[]; }; type Enum = { type: "enum"; items: readonly Item.EnumMember[]; }; type Template = { type: "template"; typeArgs: readonly Type[]; }; type Literal = { type: "literal"; value: number | string | boolean; }; type Union = { type: "union"; typeArgs: readonly Type[]; }; type Intersection = { type: "intersection"; typeArgs: readonly Type[]; }; type KeyOf = { type: "keyof"; inner: Type; }; type Object = { type: "object"; members: readonly Member[]; signatures?: readonly CallSignature[]; }; type Interface = { type: "interface"; members: readonly Member[]; signatures?: readonly CallSignature[]; implements?: readonly Type[]; }; type Class = { type: "class"; members: readonly Member[]; extends?: Type; implements?: readonly Type[]; }; type Function = { type: "function"; signatures: readonly CallSignature[]; }; type Mapped = { type: "mapped"; key: TypeParam; inner: Type; }; type Inferred = { type: "infer"; inner: Type; }; type Conditional = { type: "conditional"; inner: Type; extends?: Type; true: Type; false: Type; }; type Tuple = { type: "tuple"; typeArgs: readonly Type[]; }; type Typeof = { type: "typeof"; inner: Type; }; type Indexed = { type: "indexed"; key: Type; inner: Type; }; type Predicate = { type: "predicate"; inner: Type; target: string; }; } export type CallSignature = { type: "function" | "constructor" | "method"; params: readonly Param[]; returns?: Type; typeParams?: readonly TypeParam[]; }; export type Param = Type & Binding & { kind: "param"; optional?: boolean; rest?: boolean; defaultValue?: string; }; export interface TypeParam extends Binding { kind: "typeparam"; default?: Type; extends?: Type; } interface Options { modules: readonly { filename: string; modname?: string; }[]; basedir?: string; } export interface Module { filename: string; modname?: string; items: readonly Item[]; template: readonly (string | { export: string; })[]; } export declare function getDocs(spec: Options): readonly Module[]; export {};