UNPKG

6.4 kBTypeScriptView Raw
1import { Deserializer, Serializer } from "./serialization/index.js";
2import { Converter } from "./converter/index.js";
3import { Renderer } from "./output/renderer.js";
4import type { ProjectReflection } from "./models/index.js";
5import { Logger, type OptionsReader, AbstractComponent } from "./utils/index.js";
6import { Options } from "./utils/index.js";
7import type { TypeDocOptions } from "./utils/options/declaration.js";
8import { type DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-point.js";
9import { Internationalization } from "./internationalization/internationalization.js";
10import { FileRegistry } from "./models/FileRegistry.js";
11import { Outputs } from "./output/output.js";
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 *
36 * @group Common
37 * @summary Root level class which contains most useful behavior.
38 */
39export declare class Application extends AbstractComponent<Application, ApplicationEvents> {
40 /**
41 * The converter used to create the declaration reflections.
42 */
43 converter: Converter;
44 outputs: Outputs;
45 /**
46 * The renderer used to generate the HTML documentation output.
47 */
48 renderer: Renderer;
49 /**
50 * The serializer used to generate JSON output.
51 */
52 serializer: Serializer;
53 /**
54 * The deserializer used to restore previously serialized JSON output.
55 */
56 deserializer: Deserializer;
57 /**
58 * The logger that should be used to output messages.
59 */
60 logger: Logger;
61 /**
62 * Internationalization module which supports translating according to
63 * the `lang` option.
64 */
65 internationalization: Internationalization;
66 /**
67 * Proxy based shortcuts for internationalization keys.
68 */
69 i18n: import("./internationalization/internationalization.js").TranslationProxy;
70 options: Options;
71 files: FileRegistry;
72 /** @internal */
73 accessor lang: string;
74 /** @internal */
75 accessor skipErrorChecking: boolean;
76 /** @internal */
77 accessor entryPointStrategy: EntryPointStrategy;
78 /** @internal */
79 accessor entryPoints: string[];
80 /**
81 * The version number of TypeDoc.
82 */
83 static readonly VERSION: string;
84 /**
85 * Emitted after plugins have been loaded and options have been read, but before they have been frozen.
86 * The listener will be given an instance of {@link Application}.
87 */
88 static readonly EVENT_BOOTSTRAP_END: "bootstrapEnd";
89 /**
90 * Emitted after a project has been deserialized from JSON.
91 * The listener will be given an instance of {@link ProjectReflection}.
92 */
93 static readonly EVENT_PROJECT_REVIVE: "reviveProject";
94 /**
95 * Emitted when validation is being run.
96 * The listener will be given an instance of {@link ProjectReflection}.
97 */
98 static readonly EVENT_VALIDATE_PROJECT: "validateProject";
99 /**
100 * Create a new TypeDoc application instance.
101 */
102 private constructor();
103 /**
104 * Initialize TypeDoc, loading plugins if applicable.
105 */
106 static bootstrapWithPlugins(options?: Partial<TypeDocOptions>, readers?: readonly OptionsReader[]): Promise<Application>;
107 /**
108 * Initialize TypeDoc without loading plugins.
109 *
110 * @example
111 * Initialize the application with pretty-printing output disabled.
112 * ```ts
113 * const app = Application.bootstrap({ pretty: false });
114 * ```
115 *
116 * @param options Options to set during initialization
117 * @param readers Option readers to use to discover options from config files.
118 */
119 static bootstrap(options?: Partial<TypeDocOptions>, readers?: readonly OptionsReader[]): Promise<Application>;
120 private _bootstrap;
121 /** @internal */
122 setOptions(options: Partial<TypeDocOptions>, reportErrors?: boolean): boolean;
123 /**
124 * Return the path to the TypeScript compiler.
125 */
126 getTypeScriptPath(): string;
127 getTypeScriptVersion(): string;
128 getEntryPoints(): DocumentationEntryPoint[] | undefined;
129 /**
130 * Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
131 * May return undefined if entry points fail to be expanded.
132 */
133 getDefinedEntryPoints(): DocumentationEntryPoint[] | undefined;
134 /**
135 * Run the converter for the given set of files and return the generated reflections.
136 *
137 * @returns An instance of ProjectReflection on success, undefined otherwise.
138 */
139 convert(): Promise<ProjectReflection | undefined>;
140 convertAndWatch(success: (project: ProjectReflection) => Promise<void>): void;
141 validate(project: ProjectReflection): void;
142 /**
143 * Render outputs selected with options for the specified project
144 */
145 generateOutputs(project: ProjectReflection): Promise<void>;
146 /**
147 * Render HTML for the given project
148 */
149 generateDocs(project: ProjectReflection, out: string): Promise<void>;
150 /**
151 * Write the reflections to a json file.
152 *
153 * @param out The path and file name of the target file.
154 * @returns Whether the JSON file could be written successfully.
155 */
156 generateJson(project: ProjectReflection, out: string): Promise<void>;
157 /**
158 * Print the version number.
159 */
160 toString(): string;
161 private _convertPackages;
162 private _merge;
163}