UNPKG

6 kBTypeScriptView Raw
1import { Converter } from "./converter/index";
2import { Renderer } from "./output/renderer";
3import { Deserializer, Serializer } from "./serialization";
4import type { ProjectReflection } from "./models/index";
5import { Logger, type OptionsReader } from "./utils/index";
6import { type AbstractComponent, ChildableComponent } from "./utils/component";
7import { Options } from "./utils";
8import type { TypeDocOptions } from "./utils/options/declaration";
9import { type DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-point";
10import { Internationalization } from "./internationalization/internationalization";
11import { FileRegistry } from "./models/FileRegistry";
12export declare function createAppForTesting(): Application;
13export interface ApplicationEvents {
14 bootstrapEnd: [Application];
15 reviveProject: [ProjectReflection];
16 validateProject: [ProjectReflection];
17}
18/**
19 * The default TypeDoc main application class.
20 *
21 * This class holds the two main components of TypeDoc, the {@link Converter} and
22 * the {@link Renderer}. When running TypeDoc, first the {@link Converter} is invoked which
23 * generates a {@link ProjectReflection} from the passed in source files. The
24 * {@link ProjectReflection} is a hierarchical model representation of the TypeScript
25 * project. Afterwards the model is passed to the {@link Renderer} which uses an instance
26 * of {@link Theme} to generate the final documentation.
27 *
28 * Both the {@link Converter} and the {@link Renderer} emit a series of events while processing the project.
29 * Subscribe to these Events to control the application flow or alter the output.
30 *
31 * @remarks
32 *
33 * Access to an Application instance can be retrieved with {@link Application.bootstrap} or
34 * {@link Application.bootstrapWithPlugins}. It can not be constructed manually.
35 */
36export declare class Application extends ChildableComponent<Application, AbstractComponent<Application, {}>, ApplicationEvents> {
37 /**
38 * The converter used to create the declaration reflections.
39 */
40 converter: Converter;
41 /**
42 * The renderer used to generate the documentation output.
43 */
44 renderer: Renderer;
45 /**
46 * The serializer used to generate JSON output.
47 */
48 serializer: Serializer;
49 /**
50 * The deserializer used to restore previously serialized JSON output.
51 */
52 deserializer: Deserializer;
53 /**
54 * The logger that should be used to output messages.
55 */
56 logger: Logger;
57 /**
58 * Internationalization module which supports translating according to
59 * the `lang` option.
60 */
61 internationalization: Internationalization;
62 /**
63 * Proxy based shortcuts for internationalization keys.
64 */
65 i18n: import("./internationalization/internationalization").TranslationProxy;
66 options: Options;
67 files: FileRegistry;
68 /** @internal */
69 accessor lang: string;
70 /** @internal */
71 accessor skipErrorChecking: boolean;
72 /** @internal */
73 accessor entryPointStrategy: EntryPointStrategy;
74 /** @internal */
75 accessor entryPoints: string[];
76 /**
77 * The version number of TypeDoc.
78 */
79 static readonly VERSION: string;
80 /**
81 * Emitted after plugins have been loaded and options have been read, but before they have been frozen.
82 * The listener will be given an instance of {@link Application}.
83 */
84 static readonly EVENT_BOOTSTRAP_END: "bootstrapEnd";
85 /**
86 * Emitted after a project has been deserialized from JSON.
87 * The listener will be given an instance of {@link ProjectReflection}.
88 */
89 static readonly EVENT_PROJECT_REVIVE: "reviveProject";
90 /**
91 * Emitted when validation is being run.
92 * The listener will be given an instance of {@link ProjectReflection}.
93 */
94 static readonly EVENT_VALIDATE_PROJECT: "validateProject";
95 /**
96 * Create a new TypeDoc application instance.
97 */
98 private constructor();
99 /**
100 * Initialize TypeDoc, loading plugins if applicable.
101 */
102 static bootstrapWithPlugins(options?: Partial<TypeDocOptions>, readers?: readonly OptionsReader[]): Promise<Application>;
103 /**
104 * Initialize TypeDoc without loading plugins.
105 *
106 * @example
107 * Initialize the application with pretty-printing output disabled.
108 * ```ts
109 * const app = Application.bootstrap({ pretty: false });
110 * ```
111 *
112 * @param options Options to set during initialization
113 * @param readers Option readers to use to discover options from config files.
114 */
115 static bootstrap(options?: Partial<TypeDocOptions>, readers?: readonly OptionsReader[]): Promise<Application>;
116 private _bootstrap;
117 private setOptions;
118 /**
119 * Return the path to the TypeScript compiler.
120 */
121 getTypeScriptPath(): string;
122 getTypeScriptVersion(): string;
123 /**
124 * Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
125 * May return undefined if entry points fail to be expanded.
126 */
127 getEntryPoints(): DocumentationEntryPoint[] | undefined;
128 /**
129 * Run the converter for the given set of files and return the generated reflections.
130 *
131 * @returns An instance of ProjectReflection on success, undefined otherwise.
132 */
133 convert(): Promise<ProjectReflection | undefined>;
134 convertAndWatch(success: (project: ProjectReflection) => Promise<void>): void;
135 validate(project: ProjectReflection): void;
136 /**
137 * Render HTML for the given project
138 */
139 generateDocs(project: ProjectReflection, out: string): Promise<void>;
140 /**
141 * Write the reflections to a json file.
142 *
143 * @param out The path and file name of the target file.
144 * @returns Whether the JSON file could be written successfully.
145 */
146 generateJson(project: ProjectReflection, out: string): Promise<void>;
147 /**
148 * Print the version number.
149 */
150 toString(): string;
151 private _convertPackages;
152 private _merge;
153}