typedoc 0.24.8 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -1
- package/dist/lib/application.d.ts +13 -11
- package/dist/lib/application.js +455 -347
- package/dist/lib/cli.js +29 -22
- package/dist/lib/converter/comments/blockLexer.js +10 -1
- package/dist/lib/converter/comments/declarationReference.js +2 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.js +2 -1
- package/dist/lib/converter/comments/discovery.js +0 -1
- package/dist/lib/converter/comments/linkResolver.d.ts +5 -2
- package/dist/lib/converter/comments/linkResolver.js +21 -13
- package/dist/lib/converter/comments/parser.js +7 -12
- package/dist/lib/converter/comments/tagName.d.ts +8 -0
- package/dist/lib/converter/comments/tagName.js +62 -0
- package/dist/lib/converter/context.js +1 -2
- package/dist/lib/converter/converter.d.ts +12 -10
- package/dist/lib/converter/converter.js +440 -309
- package/dist/lib/converter/factories/index-signature.js +2 -1
- package/dist/lib/converter/factories/signature.js +3 -4
- package/dist/lib/converter/plugins/CategoryPlugin.d.ts +8 -8
- package/dist/lib/converter/plugins/CategoryPlugin.js +294 -200
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +8 -5
- package/dist/lib/converter/plugins/CommentPlugin.js +434 -305
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +3 -3
- package/dist/lib/converter/plugins/GroupPlugin.js +216 -145
- package/dist/lib/converter/plugins/ImplementsPlugin.js +240 -192
- package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +2 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.js +202 -132
- package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +1 -1
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +111 -43
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +6 -4
- package/dist/lib/converter/plugins/PackagePlugin.js +192 -96
- package/dist/lib/converter/plugins/SourcePlugin.d.ts +6 -5
- package/dist/lib/converter/plugins/SourcePlugin.js +239 -132
- package/dist/lib/converter/plugins/TypePlugin.js +148 -101
- package/dist/lib/converter/symbols.js +16 -4
- package/dist/lib/converter/types.js +16 -1
- package/dist/lib/converter/utils/nodes.d.ts +2 -2
- package/dist/lib/converter/utils/repository.d.ts +15 -5
- package/dist/lib/converter/utils/repository.js +29 -12
- package/dist/lib/models/ReflectionGroup.d.ts +4 -2
- package/dist/lib/models/ReflectionGroup.js +3 -1
- package/dist/lib/models/comments/comment.d.ts +9 -2
- package/dist/lib/models/comments/comment.js +2 -0
- package/dist/lib/models/reflections/ReflectionSymbolId.js +1 -1
- package/dist/lib/models/reflections/abstract.d.ts +6 -1
- package/dist/lib/models/reflections/abstract.js +15 -2
- package/dist/lib/models/reflections/container.d.ts +3 -0
- package/dist/lib/models/reflections/container.js +4 -1
- package/dist/lib/models/reflections/declaration.d.ts +1 -0
- package/dist/lib/models/reflections/declaration.js +1 -0
- package/dist/lib/models/reflections/index.d.ts +1 -1
- package/dist/lib/models/reflections/kind.d.ts +4 -4
- package/dist/lib/models/reflections/kind.js +5 -7
- package/dist/lib/models/reflections/parameter.d.ts +3 -0
- package/dist/lib/models/reflections/parameter.js +3 -0
- package/dist/lib/models/reflections/project.d.ts +1 -0
- package/dist/lib/models/reflections/project.js +3 -1
- package/dist/lib/models/reflections/reference.d.ts +1 -0
- package/dist/lib/models/reflections/reference.js +1 -0
- package/dist/lib/models/reflections/signature.d.ts +3 -0
- package/dist/lib/models/reflections/signature.js +3 -0
- package/dist/lib/models/reflections/type-parameter.d.ts +3 -0
- package/dist/lib/models/reflections/type-parameter.js +3 -0
- package/dist/lib/models/sources/file.d.ts +2 -0
- package/dist/lib/models/sources/file.js +5 -0
- package/dist/lib/models/types.d.ts +24 -0
- package/dist/lib/models/types.js +21 -0
- package/dist/lib/output/components.d.ts +1 -0
- package/dist/lib/output/components.js +10 -3
- package/dist/lib/output/events.d.ts +2 -2
- package/dist/lib/output/index.d.ts +1 -1
- package/dist/lib/output/plugins/AssetsPlugin.d.ts +1 -1
- package/dist/lib/output/plugins/AssetsPlugin.js +112 -44
- package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +2 -1
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +174 -99
- package/dist/lib/output/plugins/NavigationPlugin.d.ts +6 -0
- package/dist/lib/output/plugins/NavigationPlugin.js +109 -0
- package/dist/lib/output/plugins/index.d.ts +2 -1
- package/dist/lib/output/plugins/index.js +5 -3
- package/dist/lib/output/renderer.d.ts +10 -8
- package/dist/lib/output/renderer.js +317 -203
- package/dist/lib/output/theme.d.ts +1 -1
- package/dist/lib/output/theme.js +64 -18
- package/dist/lib/output/themes/MarkedPlugin.d.ts +4 -4
- package/dist/lib/output/themes/MarkedPlugin.js +224 -145
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +14 -1
- package/dist/lib/output/themes/default/DefaultTheme.js +68 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +43 -44
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +16 -11
- package/dist/lib/output/themes/default/layouts/default.js +2 -0
- package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/comment.js +16 -14
- package/dist/lib/output/themes/default/partials/footer.js +1 -1
- package/dist/lib/output/themes/default/partials/header.js +2 -2
- package/dist/lib/output/themes/default/partials/icon.d.ts +4 -1
- package/dist/lib/output/themes/default/partials/icon.js +40 -38
- package/dist/lib/output/themes/default/partials/member.js +1 -1
- package/dist/lib/output/themes/default/partials/member.signature.body.js +2 -2
- package/dist/lib/output/themes/default/partials/navigation.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/navigation.js +36 -56
- package/dist/lib/output/themes/default/partials/parameter.js +3 -3
- package/dist/lib/output/themes/lib.d.ts +1 -2
- package/dist/lib/output/themes/lib.js +1 -11
- package/dist/lib/serialization/schema.d.ts +37 -1
- package/dist/lib/utils/component.d.ts +1 -1
- package/dist/lib/utils/component.js +3 -1
- package/dist/lib/utils/entry-point.d.ts +0 -6
- package/dist/lib/utils/entry-point.js +27 -113
- package/dist/lib/utils/events.js +1 -1
- package/dist/lib/utils/general.js +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.js +2 -1
- package/dist/lib/utils/jsx.d.ts +1 -1
- package/dist/lib/utils/jsx.js +24 -15
- package/dist/lib/utils/options/declaration.d.ts +5 -1
- package/dist/lib/utils/options/declaration.js +1 -1
- package/dist/lib/utils/options/index.d.ts +1 -1
- package/dist/lib/utils/options/index.js +2 -1
- package/dist/lib/utils/options/options.d.ts +22 -9
- package/dist/lib/utils/options/options.js +27 -15
- package/dist/lib/utils/options/readers/tsconfig.js +2 -7
- package/dist/lib/utils/options/readers/typedoc.d.ts +4 -2
- package/dist/lib/utils/options/readers/typedoc.js +33 -7
- package/dist/lib/utils/options/sources/typedoc.js +25 -4
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
- package/dist/lib/utils/options/tsdoc-defaults.js +4 -0
- package/dist/lib/utils/package-manifest.d.ts +0 -25
- package/dist/lib/utils/package-manifest.js +7 -148
- package/dist/lib/utils/perf.d.ts +1 -1
- package/dist/lib/utils/perf.js +36 -31
- package/dist/lib/utils/sort.js +0 -1
- package/dist/lib/validation/links.js +10 -2
- package/package.json +12 -12
- package/static/main.js +4 -3
- package/static/style.css +26 -10
- package/tsdoc.json +16 -0
package/dist/lib/application.js
CHANGED
|
@@ -15,11 +15,39 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
19
|
+
var useValue = arguments.length > 2;
|
|
20
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
21
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
22
|
+
}
|
|
23
|
+
return useValue ? value : void 0;
|
|
24
|
+
};
|
|
25
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
26
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
27
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
28
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
29
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
30
|
+
var _, done = false;
|
|
31
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
32
|
+
var context = {};
|
|
33
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
34
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
35
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
36
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
37
|
+
if (kind === "accessor") {
|
|
38
|
+
if (result === void 0) continue;
|
|
39
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
40
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
41
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
42
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
43
|
+
}
|
|
44
|
+
else if (_ = accept(result)) {
|
|
45
|
+
if (kind === "field") initializers.unshift(_);
|
|
46
|
+
else descriptor[key] = _;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
50
|
+
done = true;
|
|
23
51
|
};
|
|
24
52
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
53
|
if (mod && mod.__esModule) return mod;
|
|
@@ -28,12 +56,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
56
|
__setModuleDefault(result, mod);
|
|
29
57
|
return result;
|
|
30
58
|
};
|
|
59
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
60
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
61
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
62
|
+
};
|
|
63
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
64
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
65
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
66
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
67
|
+
};
|
|
68
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
69
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
70
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
71
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
72
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
73
|
+
};
|
|
31
74
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
76
|
};
|
|
34
|
-
var Application_1;
|
|
35
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Application = void 0;
|
|
78
|
+
exports.Application = exports.createAppForTesting = void 0;
|
|
37
79
|
const Path = __importStar(require("path"));
|
|
38
80
|
const typescript_1 = __importDefault(require("typescript"));
|
|
39
81
|
const index_1 = require("./converter/index");
|
|
@@ -59,6 +101,17 @@ const packageInfo = require("../../package.json");
|
|
|
59
101
|
const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
|
|
60
102
|
.split("||")
|
|
61
103
|
.map((version) => version.replace(/^\s*|\.x\s*$/g, ""));
|
|
104
|
+
const DETECTOR = Symbol();
|
|
105
|
+
function createAppForTesting() {
|
|
106
|
+
// @ts-expect-error private constructor
|
|
107
|
+
return new Application(DETECTOR);
|
|
108
|
+
}
|
|
109
|
+
exports.createAppForTesting = createAppForTesting;
|
|
110
|
+
const DEFAULT_READERS = [
|
|
111
|
+
new index_2.TypeDocReader(),
|
|
112
|
+
new index_2.PackageJsonReader(),
|
|
113
|
+
new index_2.TSConfigReader(),
|
|
114
|
+
];
|
|
62
115
|
/**
|
|
63
116
|
* The default TypeDoc main application class.
|
|
64
117
|
*
|
|
@@ -72,381 +125,436 @@ const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
|
|
|
72
125
|
* Both the {@link Converter} and the {@link Renderer} emit a series of events while processing the project.
|
|
73
126
|
* Subscribe to these Events to control the application flow or alter the output.
|
|
74
127
|
*/
|
|
75
|
-
let Application =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
128
|
+
let Application = (() => {
|
|
129
|
+
var _Application_skipErrorChecking_accessor_storage, _Application_entryPointStrategy_accessor_storage, _Application_entryPoints_accessor_storage;
|
|
130
|
+
let _classDecorators = [(0, component_1.Component)({ name: "application", internal: true })];
|
|
131
|
+
let _classDescriptor;
|
|
132
|
+
let _classExtraInitializers = [];
|
|
133
|
+
let _classThis;
|
|
134
|
+
let _classSuper = component_1.ChildableComponent;
|
|
135
|
+
let _instanceExtraInitializers = [];
|
|
136
|
+
let _skipErrorChecking_decorators;
|
|
137
|
+
let _skipErrorChecking_initializers = [];
|
|
138
|
+
let _entryPointStrategy_decorators;
|
|
139
|
+
let _entryPointStrategy_initializers = [];
|
|
140
|
+
let _entryPoints_decorators;
|
|
141
|
+
let _entryPoints_initializers = [];
|
|
142
|
+
var Application = _classThis = class extends _classSuper {
|
|
143
|
+
/** @internal */
|
|
144
|
+
get skipErrorChecking() { return __classPrivateFieldGet(this, _Application_skipErrorChecking_accessor_storage, "f"); }
|
|
145
|
+
set skipErrorChecking(value) { __classPrivateFieldSet(this, _Application_skipErrorChecking_accessor_storage, value, "f"); }
|
|
146
|
+
/** @internal */
|
|
147
|
+
get entryPointStrategy() { return __classPrivateFieldGet(this, _Application_entryPointStrategy_accessor_storage, "f"); }
|
|
148
|
+
set entryPointStrategy(value) { __classPrivateFieldSet(this, _Application_entryPointStrategy_accessor_storage, value, "f"); }
|
|
149
|
+
/** @internal */
|
|
150
|
+
get entryPoints() { return __classPrivateFieldGet(this, _Application_entryPoints_accessor_storage, "f"); }
|
|
151
|
+
set entryPoints(value) { __classPrivateFieldSet(this, _Application_entryPoints_accessor_storage, value, "f"); }
|
|
81
152
|
/**
|
|
82
|
-
*
|
|
153
|
+
* Create a new TypeDoc application instance.
|
|
83
154
|
*/
|
|
84
|
-
|
|
155
|
+
constructor(detector) {
|
|
156
|
+
if (detector !== DETECTOR) {
|
|
157
|
+
throw new Error("An application handle must be retrieved with Application.bootstrap or Application.bootstrapWithPlugins");
|
|
158
|
+
}
|
|
159
|
+
super(null); // We own ourselves
|
|
160
|
+
/**
|
|
161
|
+
* The converter used to create the declaration reflections.
|
|
162
|
+
*/
|
|
163
|
+
this.converter = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
164
|
+
/**
|
|
165
|
+
* The serializer used to generate JSON output.
|
|
166
|
+
*/
|
|
167
|
+
this.serializer = new serialization_1.Serializer();
|
|
168
|
+
/**
|
|
169
|
+
* The deserializer used to restore previously serialized JSON output.
|
|
170
|
+
*/
|
|
171
|
+
this.deserializer = new serialization_1.Deserializer(this);
|
|
172
|
+
/**
|
|
173
|
+
* The logger that should be used to output messages.
|
|
174
|
+
*/
|
|
175
|
+
this.logger = new index_2.ConsoleLogger();
|
|
176
|
+
this.options = new utils_1.Options();
|
|
177
|
+
_Application_skipErrorChecking_accessor_storage.set(this, __runInitializers(this, _skipErrorChecking_initializers, void 0));
|
|
178
|
+
_Application_entryPointStrategy_accessor_storage.set(this, __runInitializers(this, _entryPointStrategy_initializers, void 0));
|
|
179
|
+
_Application_entryPoints_accessor_storage.set(this, __runInitializers(this, _entryPoints_initializers, void 0));
|
|
180
|
+
this.converter = this.addComponent("converter", index_1.Converter);
|
|
181
|
+
this.renderer = this.addComponent("renderer", renderer_1.Renderer);
|
|
182
|
+
}
|
|
85
183
|
/**
|
|
86
|
-
*
|
|
184
|
+
* Initialize TypeDoc, loading plugins if applicable.
|
|
87
185
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.options.reset();
|
|
99
|
-
this.setOptions(options, /* reportErrors */ false);
|
|
100
|
-
this.options.read(new index_2.Logger());
|
|
101
|
-
this.logger.level = this.options.getValue("logLevel");
|
|
102
|
-
await (0, index_2.loadPlugins)(this, this.options.getValue("plugin"));
|
|
103
|
-
this.bootstrap(options);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Initialize TypeDoc without loading plugins.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* Initialize the application with pretty-printing output disabled.
|
|
110
|
-
* ```ts
|
|
111
|
-
* const app = new Application();
|
|
112
|
-
* app.bootstrap({ pretty: false });
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @param options - Options to set during initialization
|
|
116
|
-
*/
|
|
117
|
-
bootstrap(options = {}) {
|
|
118
|
-
this.options.reset();
|
|
119
|
-
this.setOptions(options, /* reportErrors */ false);
|
|
120
|
-
this.options.read(this.logger);
|
|
121
|
-
this.setOptions(options);
|
|
122
|
-
this.logger.level = this.options.getValue("logLevel");
|
|
123
|
-
if ((0, general_1.hasBeenLoadedMultipleTimes)()) {
|
|
124
|
-
this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${(0, general_1.getLoadedPaths)().join("\n\t")}`);
|
|
186
|
+
static async bootstrapWithPlugins(options = {}, readers = DEFAULT_READERS) {
|
|
187
|
+
const app = new Application(DETECTOR);
|
|
188
|
+
readers.forEach((r) => app.options.addReader(r));
|
|
189
|
+
app.options.reset();
|
|
190
|
+
app.setOptions(options, /* reportErrors */ false);
|
|
191
|
+
await app.options.read(new index_2.Logger());
|
|
192
|
+
app.logger.level = app.options.getValue("logLevel");
|
|
193
|
+
await (0, index_2.loadPlugins)(app, app.options.getValue("plugin"));
|
|
194
|
+
await app._bootstrap(options);
|
|
195
|
+
return app;
|
|
125
196
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Initialize TypeDoc without loading plugins.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* Initialize the application with pretty-printing output disabled.
|
|
202
|
+
* ```ts
|
|
203
|
+
* const app = Application.bootstrap({ pretty: false });
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @param options Options to set during initialization
|
|
207
|
+
* @param readers Option readers to use to discover options from config files.
|
|
208
|
+
*/
|
|
209
|
+
static async bootstrap(options = {}, readers = DEFAULT_READERS) {
|
|
210
|
+
const app = new Application(DETECTOR);
|
|
211
|
+
readers.forEach((r) => app.options.addReader(r));
|
|
212
|
+
await app._bootstrap(options);
|
|
213
|
+
return app;
|
|
214
|
+
}
|
|
215
|
+
async _bootstrap(options) {
|
|
216
|
+
this.options.reset();
|
|
217
|
+
this.setOptions(options, /* reportErrors */ false);
|
|
218
|
+
await this.options.read(this.logger);
|
|
219
|
+
this.setOptions(options);
|
|
220
|
+
this.logger.level = this.options.getValue("logLevel");
|
|
221
|
+
if ((0, general_1.hasBeenLoadedMultipleTimes)()) {
|
|
222
|
+
this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${(0, general_1.getLoadedPaths)().join("\n\t")}`);
|
|
132
223
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
224
|
+
this.trigger(application_events_1.ApplicationEvents.BOOTSTRAP_END, this);
|
|
225
|
+
}
|
|
226
|
+
setOptions(options, reportErrors = true) {
|
|
227
|
+
for (const [key, val] of Object.entries(options)) {
|
|
228
|
+
try {
|
|
229
|
+
this.options.setValue(key, val);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
(0, assert_1.ok)(error instanceof Error);
|
|
233
|
+
if (reportErrors) {
|
|
234
|
+
this.logger.error(error.message);
|
|
235
|
+
}
|
|
137
236
|
}
|
|
138
237
|
}
|
|
139
238
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return (0, paths_1.nicePath)(Path.dirname(require.resolve("typescript")));
|
|
146
|
-
}
|
|
147
|
-
getTypeScriptVersion() {
|
|
148
|
-
return typescript_1.default.version;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
|
|
152
|
-
* May return undefined if entry points fail to be expanded.
|
|
153
|
-
*/
|
|
154
|
-
getEntryPoints() {
|
|
155
|
-
return (0, entry_point_1.getEntryPoints)(this.logger, this.options);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Run the converter for the given set of files and return the generated reflections.
|
|
159
|
-
*
|
|
160
|
-
* @returns An instance of ProjectReflection on success, undefined otherwise.
|
|
161
|
-
*/
|
|
162
|
-
convert() {
|
|
163
|
-
const start = Date.now();
|
|
164
|
-
// We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
|
|
165
|
-
// with a few different settings.
|
|
166
|
-
this.options.freeze();
|
|
167
|
-
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
168
|
-
if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Merge) {
|
|
169
|
-
return this._merge();
|
|
170
|
-
}
|
|
171
|
-
if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Packages) {
|
|
172
|
-
return this._convertPackages();
|
|
239
|
+
/**
|
|
240
|
+
* Return the path to the TypeScript compiler.
|
|
241
|
+
*/
|
|
242
|
+
getTypeScriptPath() {
|
|
243
|
+
return (0, paths_1.nicePath)(Path.dirname(require.resolve("typescript")));
|
|
173
244
|
}
|
|
174
|
-
|
|
175
|
-
|
|
245
|
+
getTypeScriptVersion() {
|
|
246
|
+
return typescript_1.default.version;
|
|
176
247
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
|
|
250
|
+
* May return undefined if entry points fail to be expanded.
|
|
251
|
+
*/
|
|
252
|
+
getEntryPoints() {
|
|
253
|
+
return (0, entry_point_1.getEntryPoints)(this.logger, this.options);
|
|
181
254
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Run the converter for the given set of files and return the generated reflections.
|
|
257
|
+
*
|
|
258
|
+
* @returns An instance of ProjectReflection on success, undefined otherwise.
|
|
259
|
+
*/
|
|
260
|
+
async convert() {
|
|
261
|
+
const start = Date.now();
|
|
262
|
+
// We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
|
|
263
|
+
// with a few different settings.
|
|
264
|
+
this.options.freeze();
|
|
265
|
+
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
266
|
+
if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Merge) {
|
|
267
|
+
return this._merge();
|
|
268
|
+
}
|
|
269
|
+
if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Packages) {
|
|
270
|
+
return this._convertPackages();
|
|
271
|
+
}
|
|
272
|
+
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
|
|
273
|
+
this.logger.warn(`You are running with an unsupported TypeScript version! If TypeDoc crashes, this is why. TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
|
|
274
|
+
}
|
|
275
|
+
const entryPoints = this.getEntryPoints();
|
|
276
|
+
if (!entryPoints) {
|
|
277
|
+
// Fatal error already reported.
|
|
188
278
|
return;
|
|
189
279
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
program.
|
|
280
|
+
const programs = (0, array_1.unique)(entryPoints.map((e) => e.program));
|
|
281
|
+
this.logger.verbose(`Converting with ${programs.length} programs ${entryPoints.length} entry points`);
|
|
282
|
+
if (this.skipErrorChecking === false) {
|
|
283
|
+
const errors = programs.flatMap((program) => typescript_1.default.getPreEmitDiagnostics(program));
|
|
284
|
+
if (errors.length) {
|
|
285
|
+
this.logger.diagnostics(errors);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
194
288
|
}
|
|
289
|
+
if (this.options.getValue("emit") === "both") {
|
|
290
|
+
for (const program of programs) {
|
|
291
|
+
program.emit();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const startConversion = Date.now();
|
|
295
|
+
this.logger.verbose(`Finished getting entry points in ${Date.now() - start}ms`);
|
|
296
|
+
const project = this.converter.convert(entryPoints);
|
|
297
|
+
this.logger.verbose(`Finished conversion in ${Date.now() - startConversion}ms`);
|
|
298
|
+
return project;
|
|
195
299
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.logger.verbose(`Finished conversion in ${Date.now() - startConversion}ms`);
|
|
200
|
-
return project;
|
|
201
|
-
}
|
|
202
|
-
convertAndWatch(success) {
|
|
203
|
-
this.options.freeze();
|
|
204
|
-
if (!this.options.getValue("preserveWatchOutput") &&
|
|
205
|
-
this.logger instanceof index_2.ConsoleLogger) {
|
|
206
|
-
typescript_1.default.sys.clearScreen?.();
|
|
207
|
-
}
|
|
208
|
-
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
209
|
-
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
|
|
210
|
-
this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
|
|
211
|
-
}
|
|
212
|
-
if (Object.keys(this.options.getCompilerOptions()).length === 0) {
|
|
213
|
-
this.logger.warn(`No compiler options set. This likely means that TypeDoc did not find your tsconfig.json. Generated documentation will probably be empty.`);
|
|
214
|
-
}
|
|
215
|
-
// Doing this is considerably more complicated, we'd need to manage an array of programs, not convert until all programs
|
|
216
|
-
// have reported in the first time... just error out for now. I'm not convinced anyone will actually notice.
|
|
217
|
-
if (this.options.getFileNames().length === 0) {
|
|
218
|
-
this.logger.error("The provided tsconfig file looks like a solution style tsconfig, which is not supported in watch mode.");
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
// Support for packages mode is currently unimplemented
|
|
222
|
-
if (this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Resolve &&
|
|
223
|
-
this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Expand) {
|
|
224
|
-
this.logger.error("entryPointStrategy must be set to either resolve or expand for watch mode.");
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const tsconfigFile = (0, tsconfig_1.findTsConfigFile)(this.options.getValue("tsconfig")) ??
|
|
228
|
-
"tsconfig.json";
|
|
229
|
-
// We don't want to do it the first time to preserve initial debug status messages. They'll be lost
|
|
230
|
-
// after the user saves a file, but better than nothing...
|
|
231
|
-
let firstStatusReport = true;
|
|
232
|
-
const host = typescript_1.default.createWatchCompilerHost(tsconfigFile, {}, typescript_1.default.sys, typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
|
|
233
|
-
if (!firstStatusReport &&
|
|
234
|
-
errorCount === void 0 &&
|
|
235
|
-
!this.options.getValue("preserveWatchOutput") &&
|
|
300
|
+
convertAndWatch(success) {
|
|
301
|
+
this.options.freeze();
|
|
302
|
+
if (!this.options.getValue("preserveWatchOutput") &&
|
|
236
303
|
this.logger instanceof index_2.ConsoleLogger) {
|
|
237
304
|
typescript_1.default.sys.clearScreen?.();
|
|
238
305
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
306
|
+
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
307
|
+
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
|
|
308
|
+
this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
|
|
309
|
+
}
|
|
310
|
+
if (Object.keys(this.options.getCompilerOptions()).length === 0) {
|
|
311
|
+
this.logger.warn(`No compiler options set. This likely means that TypeDoc did not find your tsconfig.json. Generated documentation will probably be empty.`);
|
|
312
|
+
}
|
|
313
|
+
// Doing this is considerably more complicated, we'd need to manage an array of programs, not convert until all programs
|
|
314
|
+
// have reported in the first time... just error out for now. I'm not convinced anyone will actually notice.
|
|
315
|
+
if (this.options.getFileNames().length === 0) {
|
|
316
|
+
this.logger.error("The provided tsconfig file looks like a solution style tsconfig, which is not supported in watch mode.");
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
// Support for packages mode is currently unimplemented
|
|
320
|
+
if (this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Resolve &&
|
|
321
|
+
this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Expand) {
|
|
322
|
+
this.logger.error("entryPointStrategy must be set to either resolve or expand for watch mode.");
|
|
246
323
|
return;
|
|
247
324
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
325
|
+
const tsconfigFile = (0, tsconfig_1.findTsConfigFile)(this.options.getValue("tsconfig")) ??
|
|
326
|
+
"tsconfig.json";
|
|
327
|
+
// We don't want to do it the first time to preserve initial debug status messages. They'll be lost
|
|
328
|
+
// after the user saves a file, but better than nothing...
|
|
329
|
+
let firstStatusReport = true;
|
|
330
|
+
const host = typescript_1.default.createWatchCompilerHost(tsconfigFile, {}, typescript_1.default.sys, typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
|
|
331
|
+
if (!firstStatusReport &&
|
|
332
|
+
errorCount === void 0 &&
|
|
333
|
+
!this.options.getValue("preserveWatchOutput") &&
|
|
334
|
+
this.logger instanceof index_2.ConsoleLogger) {
|
|
335
|
+
typescript_1.default.sys.clearScreen?.();
|
|
251
336
|
}
|
|
252
|
-
|
|
253
|
-
this.logger.
|
|
254
|
-
|
|
255
|
-
|
|
337
|
+
firstStatusReport = false;
|
|
338
|
+
this.logger.info(typescript_1.default.flattenDiagnosticMessageText(status.messageText, newLine));
|
|
339
|
+
});
|
|
340
|
+
let successFinished = true;
|
|
341
|
+
let currentProgram;
|
|
342
|
+
const runSuccess = () => {
|
|
343
|
+
if (!currentProgram) {
|
|
256
344
|
return;
|
|
257
345
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
346
|
+
if (successFinished) {
|
|
347
|
+
if (this.options.getValue("emit") === "both") {
|
|
348
|
+
currentProgram.emit();
|
|
349
|
+
}
|
|
350
|
+
this.logger.resetErrors();
|
|
351
|
+
this.logger.resetWarnings();
|
|
352
|
+
const entryPoints = (0, entry_point_1.getWatchEntryPoints)(this.logger, this.options, currentProgram);
|
|
353
|
+
if (!entryPoints) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const project = this.converter.convert(entryPoints);
|
|
357
|
+
currentProgram = undefined;
|
|
358
|
+
successFinished = false;
|
|
359
|
+
void success(project).then(() => {
|
|
360
|
+
successFinished = true;
|
|
361
|
+
runSuccess();
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
const origCreateProgram = host.createProgram;
|
|
366
|
+
host.createProgram = (rootNames, options, host, oldProgram, configDiagnostics, references) => {
|
|
367
|
+
// If we always do this, we'll get a crash the second time a program is created.
|
|
368
|
+
if (rootNames !== undefined) {
|
|
369
|
+
options = this.options.fixCompilerOptions(options || {});
|
|
370
|
+
}
|
|
371
|
+
return origCreateProgram(rootNames, options, host, oldProgram, configDiagnostics, references);
|
|
372
|
+
};
|
|
373
|
+
const origAfterProgramCreate = host.afterProgramCreate;
|
|
374
|
+
host.afterProgramCreate = (program) => {
|
|
375
|
+
if (typescript_1.default.getPreEmitDiagnostics(program.getProgram()).length === 0) {
|
|
376
|
+
currentProgram = program.getProgram();
|
|
263
377
|
runSuccess();
|
|
264
|
-
}
|
|
378
|
+
}
|
|
379
|
+
origAfterProgramCreate?.(program);
|
|
380
|
+
};
|
|
381
|
+
typescript_1.default.createWatchProgram(host);
|
|
382
|
+
}
|
|
383
|
+
validate(project) {
|
|
384
|
+
const checks = this.options.getValue("validation");
|
|
385
|
+
const start = Date.now();
|
|
386
|
+
// No point in validating exports when merging. Warnings will have already been emitted when
|
|
387
|
+
// creating the project jsons that this run merges together.
|
|
388
|
+
if (checks.notExported &&
|
|
389
|
+
this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Merge) {
|
|
390
|
+
(0, exports_1.validateExports)(project, this.logger, this.options.getValue("intentionallyNotExported"));
|
|
265
391
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
host.createProgram = (rootNames, options, host, oldProgram, configDiagnostics, references) => {
|
|
269
|
-
// If we always do this, we'll get a crash the second time a program is created.
|
|
270
|
-
if (rootNames !== undefined) {
|
|
271
|
-
options = this.options.fixCompilerOptions(options || {});
|
|
392
|
+
if (checks.notDocumented) {
|
|
393
|
+
(0, documentation_1.validateDocumentation)(project, this.logger, this.options.getValue("requiredToBeDocumented"));
|
|
272
394
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const origAfterProgramCreate = host.afterProgramCreate;
|
|
276
|
-
host.afterProgramCreate = (program) => {
|
|
277
|
-
if (typescript_1.default.getPreEmitDiagnostics(program.getProgram()).length === 0) {
|
|
278
|
-
currentProgram = program.getProgram();
|
|
279
|
-
runSuccess();
|
|
395
|
+
if (checks.invalidLink) {
|
|
396
|
+
(0, links_1.validateLinks)(project, this.logger);
|
|
280
397
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
typescript_1.default.createWatchProgram(host);
|
|
284
|
-
}
|
|
285
|
-
validate(project) {
|
|
286
|
-
const checks = this.options.getValue("validation");
|
|
287
|
-
const start = Date.now();
|
|
288
|
-
// No point in validating exports when merging. Warnings will have already been emitted when
|
|
289
|
-
// creating the project jsons that this run merges together.
|
|
290
|
-
if (checks.notExported &&
|
|
291
|
-
this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Merge) {
|
|
292
|
-
(0, exports_1.validateExports)(project, this.logger, this.options.getValue("intentionallyNotExported"));
|
|
293
|
-
}
|
|
294
|
-
if (checks.notDocumented) {
|
|
295
|
-
(0, documentation_1.validateDocumentation)(project, this.logger, this.options.getValue("requiredToBeDocumented"));
|
|
296
|
-
}
|
|
297
|
-
if (checks.invalidLink) {
|
|
298
|
-
(0, links_1.validateLinks)(project, this.logger);
|
|
299
|
-
}
|
|
300
|
-
this.trigger(Application_1.EVENT_VALIDATE_PROJECT, project);
|
|
301
|
-
this.logger.verbose(`Validation took ${Date.now() - start}ms`);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Render HTML for the given project
|
|
305
|
-
*/
|
|
306
|
-
async generateDocs(project, out) {
|
|
307
|
-
const start = Date.now();
|
|
308
|
-
out = Path.resolve(out);
|
|
309
|
-
await this.renderer.render(project, out);
|
|
310
|
-
if (this.logger.hasErrors()) {
|
|
311
|
-
this.logger.error("Documentation could not be generated due to the errors above.");
|
|
398
|
+
this.trigger(Application.EVENT_VALIDATE_PROJECT, project);
|
|
399
|
+
this.logger.verbose(`Validation took ${Date.now() - start}ms`);
|
|
312
400
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
* @returns Whether the JSON file could be written successfully.
|
|
323
|
-
*/
|
|
324
|
-
async generateJson(project, out) {
|
|
325
|
-
const start = Date.now();
|
|
326
|
-
out = Path.resolve(out);
|
|
327
|
-
const ser = this.serializer.projectToObject(project, process.cwd());
|
|
328
|
-
const space = this.options.getValue("pretty") ? "\t" : "";
|
|
329
|
-
await (0, index_2.writeFile)(out, JSON.stringify(ser, null, space));
|
|
330
|
-
this.logger.info(`JSON written to ${(0, paths_1.nicePath)(out)}`);
|
|
331
|
-
this.logger.verbose(`JSON rendering took ${Date.now() - start}ms`);
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Print the version number.
|
|
335
|
-
*/
|
|
336
|
-
toString() {
|
|
337
|
-
return [
|
|
338
|
-
"",
|
|
339
|
-
`TypeDoc ${Application_1.VERSION}`,
|
|
340
|
-
`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,
|
|
341
|
-
"",
|
|
342
|
-
].join("\n");
|
|
343
|
-
}
|
|
344
|
-
_convertPackages() {
|
|
345
|
-
if (!this.options.isSet("entryPoints")) {
|
|
346
|
-
this.logger.error("No entry points provided to packages mode, documentation cannot be generated.");
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
const packageDirs = (0, entry_point_1.getPackageDirectories)(this.logger, this.options, this.options.getValue("entryPoints"));
|
|
350
|
-
if (packageDirs.length === 0) {
|
|
351
|
-
this.logger.error("Failed to find any packages, ensure you have provided at least one directory as an entry point containing package.json");
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
const origOptions = this.options;
|
|
355
|
-
const projects = [];
|
|
356
|
-
// Generate a json file for each package
|
|
357
|
-
for (const dir of packageDirs) {
|
|
358
|
-
this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`);
|
|
359
|
-
const opts = origOptions.copyForPackage(dir);
|
|
360
|
-
// Invalid links should only be reported after everything has been merged.
|
|
361
|
-
opts.setValue("validation", { invalidLink: false });
|
|
362
|
-
opts.read(this.logger, dir);
|
|
363
|
-
if (opts.getValue("entryPointStrategy") ===
|
|
364
|
-
entry_point_1.EntryPointStrategy.Packages) {
|
|
365
|
-
this.logger.error(`Project at ${(0, paths_1.nicePath)(dir)} has entryPointStrategy set to packages, but nested packages are not supported.`);
|
|
366
|
-
continue;
|
|
401
|
+
/**
|
|
402
|
+
* Render HTML for the given project
|
|
403
|
+
*/
|
|
404
|
+
async generateDocs(project, out) {
|
|
405
|
+
const start = Date.now();
|
|
406
|
+
out = Path.resolve(out);
|
|
407
|
+
await this.renderer.render(project, out);
|
|
408
|
+
if (this.logger.hasErrors()) {
|
|
409
|
+
this.logger.error("Documentation could not be generated due to the errors above.");
|
|
367
410
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.validate(project);
|
|
372
|
-
projects.push(this.serializer.projectToObject(project, process.cwd()));
|
|
411
|
+
else {
|
|
412
|
+
this.logger.info(`Documentation generated at ${(0, paths_1.nicePath)(out)}`);
|
|
413
|
+
this.logger.verbose(`HTML rendering took ${Date.now() - start}ms`);
|
|
373
414
|
}
|
|
374
|
-
(0, abstract_1.resetReflectionID)();
|
|
375
415
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Write the reflections to a json file.
|
|
418
|
+
*
|
|
419
|
+
* @param out The path and file name of the target file.
|
|
420
|
+
* @returns Whether the JSON file could be written successfully.
|
|
421
|
+
*/
|
|
422
|
+
async generateJson(project, out) {
|
|
423
|
+
const start = Date.now();
|
|
424
|
+
out = Path.resolve(out);
|
|
425
|
+
const ser = this.serializer.projectToObject(project, process.cwd());
|
|
426
|
+
const space = this.options.getValue("pretty") ? "\t" : "";
|
|
427
|
+
await (0, index_2.writeFile)(out, JSON.stringify(ser, null, space));
|
|
428
|
+
this.logger.info(`JSON written to ${(0, paths_1.nicePath)(out)}`);
|
|
429
|
+
this.logger.verbose(`JSON rendering took ${Date.now() - start}ms`);
|
|
381
430
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
431
|
+
/**
|
|
432
|
+
* Print the version number.
|
|
433
|
+
*/
|
|
434
|
+
toString() {
|
|
435
|
+
return [
|
|
436
|
+
"",
|
|
437
|
+
`TypeDoc ${Application.VERSION}`,
|
|
438
|
+
`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,
|
|
439
|
+
"",
|
|
440
|
+
].join("\n");
|
|
391
441
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
this.logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files.`);
|
|
442
|
+
async _convertPackages() {
|
|
443
|
+
if (!this.options.isSet("entryPoints")) {
|
|
444
|
+
this.logger.error("No entry points provided to packages mode, documentation cannot be generated.");
|
|
445
|
+
return;
|
|
397
446
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
447
|
+
const packageDirs = (0, entry_point_1.getPackageDirectories)(this.logger, this.options, this.options.getValue("entryPoints"));
|
|
448
|
+
if (packageDirs.length === 0) {
|
|
449
|
+
this.logger.error("Failed to find any packages, ensure you have provided at least one directory as an entry point containing package.json");
|
|
450
|
+
return;
|
|
402
451
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
452
|
+
const origOptions = this.options;
|
|
453
|
+
const projects = [];
|
|
454
|
+
// Generate a json file for each package
|
|
455
|
+
for (const dir of packageDirs) {
|
|
456
|
+
this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`);
|
|
457
|
+
const opts = origOptions.copyForPackage(dir);
|
|
458
|
+
// Invalid links should only be reported after everything has been merged.
|
|
459
|
+
opts.setValue("validation", { invalidLink: false });
|
|
460
|
+
await opts.read(this.logger, dir);
|
|
461
|
+
if (opts.getValue("entryPointStrategy") ===
|
|
462
|
+
entry_point_1.EntryPointStrategy.Packages) {
|
|
463
|
+
this.logger.error(`Project at ${(0, paths_1.nicePath)(dir)} has entryPointStrategy set to packages, but nested packages are not supported.`);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
this.options = opts;
|
|
467
|
+
const project = await this.convert();
|
|
468
|
+
if (project) {
|
|
469
|
+
this.validate(project);
|
|
470
|
+
projects.push(this.serializer.projectToObject(project, process.cwd()));
|
|
471
|
+
}
|
|
472
|
+
(0, abstract_1.resetReflectionID)();
|
|
408
473
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
474
|
+
this.options = origOptions;
|
|
475
|
+
this.logger.info(`Merging converted projects`);
|
|
476
|
+
if (projects.length !== packageDirs.length) {
|
|
477
|
+
this.logger.error("Failed to convert one or more packages, result will not be merged together.");
|
|
478
|
+
return;
|
|
412
479
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
return;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
480
|
+
const result = this.deserializer.reviveProjects(this.options.getValue("name") || "Documentation", projects);
|
|
481
|
+
this.trigger(application_events_1.ApplicationEvents.REVIVE, result);
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
484
|
+
_merge() {
|
|
485
|
+
const start = Date.now();
|
|
486
|
+
if (!this.options.isSet("entryPoints")) {
|
|
487
|
+
this.logger.error("No entry points provided to merge.");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const rootDir = (0, fs_1.deriveRootDir)(this.entryPoints);
|
|
491
|
+
const entryPoints = this.entryPoints.flatMap((entry) => {
|
|
492
|
+
const result = (0, fs_1.glob)(entry, rootDir);
|
|
493
|
+
if (result.length === 0) {
|
|
494
|
+
this.logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files.`);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
this.logger.verbose(`Expanded ${(0, paths_1.nicePath)(entry)} to:\n\t${result
|
|
498
|
+
.map(paths_1.nicePath)
|
|
499
|
+
.join("\n\t")}`);
|
|
500
|
+
}
|
|
501
|
+
return result;
|
|
502
|
+
});
|
|
503
|
+
const jsonProjects = entryPoints.map((path) => {
|
|
504
|
+
try {
|
|
505
|
+
return JSON.parse((0, fs_1.readFile)(path));
|
|
506
|
+
}
|
|
507
|
+
catch {
|
|
508
|
+
this.logger.error(`Failed to parse file at ${(0, paths_1.nicePath)(path)} as json.`);
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
if (this.logger.hasErrors())
|
|
513
|
+
return;
|
|
514
|
+
const result = this.deserializer.reviveProjects(this.options.getValue("name"), jsonProjects);
|
|
515
|
+
this.logger.verbose(`Reviving projects took ${Date.now() - start}ms`);
|
|
516
|
+
this.trigger(application_events_1.ApplicationEvents.REVIVE, result);
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
_Application_skipErrorChecking_accessor_storage = new WeakMap();
|
|
521
|
+
_Application_entryPointStrategy_accessor_storage = new WeakMap();
|
|
522
|
+
_Application_entryPoints_accessor_storage = new WeakMap();
|
|
523
|
+
__setFunctionName(_classThis, "Application");
|
|
524
|
+
(() => {
|
|
525
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
526
|
+
_skipErrorChecking_decorators = [(0, utils_1.Option)("skipErrorChecking")];
|
|
527
|
+
_entryPointStrategy_decorators = [(0, utils_1.Option)("entryPointStrategy")];
|
|
528
|
+
_entryPoints_decorators = [(0, utils_1.Option)("entryPoints")];
|
|
529
|
+
__esDecorate(_classThis, null, _skipErrorChecking_decorators, { kind: "accessor", name: "skipErrorChecking", static: false, private: false, access: { has: obj => "skipErrorChecking" in obj, get: obj => obj.skipErrorChecking, set: (obj, value) => { obj.skipErrorChecking = value; } }, metadata: _metadata }, _skipErrorChecking_initializers, _instanceExtraInitializers);
|
|
530
|
+
__esDecorate(_classThis, null, _entryPointStrategy_decorators, { kind: "accessor", name: "entryPointStrategy", static: false, private: false, access: { has: obj => "entryPointStrategy" in obj, get: obj => obj.entryPointStrategy, set: (obj, value) => { obj.entryPointStrategy = value; } }, metadata: _metadata }, _entryPointStrategy_initializers, _instanceExtraInitializers);
|
|
531
|
+
__esDecorate(_classThis, null, _entryPoints_decorators, { kind: "accessor", name: "entryPoints", static: false, private: false, access: { has: obj => "entryPoints" in obj, get: obj => obj.entryPoints, set: (obj, value) => { obj.entryPoints = value; } }, metadata: _metadata }, _entryPoints_initializers, _instanceExtraInitializers);
|
|
532
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
533
|
+
Application = _classThis = _classDescriptor.value;
|
|
534
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
535
|
+
})();
|
|
536
|
+
/**
|
|
537
|
+
* The version number of TypeDoc.
|
|
538
|
+
*/
|
|
539
|
+
_classThis.VERSION = packageInfo.version;
|
|
540
|
+
/**
|
|
541
|
+
* Emitted after plugins have been loaded and options have been read, but before they have been frozen.
|
|
542
|
+
* The listener will be given an instance of {@link Application}.
|
|
543
|
+
*/
|
|
544
|
+
_classThis.EVENT_BOOTSTRAP_END = application_events_1.ApplicationEvents.BOOTSTRAP_END;
|
|
545
|
+
/**
|
|
546
|
+
* Emitted after a project has been deserialized from JSON.
|
|
547
|
+
* The listener will be given an instance of {@link ProjectReflection}.
|
|
548
|
+
*/
|
|
549
|
+
_classThis.EVENT_PROJECT_REVIVE = application_events_1.ApplicationEvents.REVIVE;
|
|
550
|
+
/**
|
|
551
|
+
* Emitted when validation is being run.
|
|
552
|
+
* The listener will be given an instance of {@link ProjectReflection}.
|
|
553
|
+
*/
|
|
554
|
+
_classThis.EVENT_VALIDATE_PROJECT = application_events_1.ApplicationEvents.VALIDATE_PROJECT;
|
|
555
|
+
(() => {
|
|
556
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
557
|
+
})();
|
|
558
|
+
return Application = _classThis;
|
|
559
|
+
})();
|
|
560
|
+
exports.Application = Application;
|