typedoc 0.28.9 → 0.28.11
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/dist/lib/application.js +2 -2
- package/dist/lib/converter/comments/discovery.js +14 -3
- package/dist/lib/converter/comments/textParser.js +7 -1
- package/dist/lib/converter/converter.d.ts +1 -1
- package/dist/lib/converter/converter.js +4 -0
- package/dist/lib/internationalization/locales/en.cjs +2 -1
- package/dist/lib/internationalization/locales/en.d.cts +2 -1
- package/dist/lib/models/ProjectReflection.js +373 -301
- package/dist/lib/output/formatter.js +1 -0
- package/dist/lib/output/themes/default/partials/member.declaration.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/member.declaration.js +17 -15
- package/dist/lib/output/themes/default/partials/moduleReflection.js +1 -1
- package/dist/lib/utils/entry-point.js +5 -5
- package/dist/lib/utils/options/options.d.ts +3 -3
- package/dist/lib/utils/options/options.js +15 -4
- package/package.json +1 -1
package/dist/lib/application.js
CHANGED
|
@@ -409,7 +409,7 @@ let Application = (() => {
|
|
|
409
409
|
if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
|
|
410
410
|
this.logger.warn(i18n.unsupported_ts_version_0(supportedVersionMajorMinor.join(", ")));
|
|
411
411
|
}
|
|
412
|
-
if (Object.keys(this.options.getCompilerOptions()).length === 0) {
|
|
412
|
+
if (Object.keys(this.options.getCompilerOptions(this.logger)).length === 0) {
|
|
413
413
|
this.logger.warn(i18n.no_compiler_options_set());
|
|
414
414
|
}
|
|
415
415
|
// Doing this is considerably more complicated, we'd need to manage an array of programs, not convert until all programs
|
|
@@ -429,7 +429,7 @@ let Application = (() => {
|
|
|
429
429
|
// We don't want to do it the first time to preserve initial debug status messages. They'll be lost
|
|
430
430
|
// after the user saves a file, but better than nothing...
|
|
431
431
|
let firstStatusReport = true;
|
|
432
|
-
const host = ts.createWatchCompilerHost(tsconfigFile, this.options.fixCompilerOptions({}), ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (d) => diagnostic(this.logger, d), (status, newLine, _options, errorCount) => {
|
|
432
|
+
const host = ts.createWatchCompilerHost(tsconfigFile, this.options.fixCompilerOptions({}, this.logger), ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (d) => diagnostic(this.logger, d), (status, newLine, _options, errorCount) => {
|
|
433
433
|
if (!firstStatusReport &&
|
|
434
434
|
errorCount === void 0 &&
|
|
435
435
|
!this.options.getValue("preserveWatchOutput") &&
|
|
@@ -263,9 +263,7 @@ function findJsDocForComment(node, ranges) {
|
|
|
263
263
|
.map((doc) => ts.findAncestor(doc, ts.isJSDoc));
|
|
264
264
|
if (ts.isSourceFile(node)) {
|
|
265
265
|
if (node.statements.length) {
|
|
266
|
-
jsDocs.push(...ts
|
|
267
|
-
.getJSDocCommentsAndTags(node.statements[0])
|
|
268
|
-
.map((doc) => ts.findAncestor(doc, ts.isJSDoc)));
|
|
266
|
+
jsDocs.push(...node.statements[0].getChildren().filter(ts.isJSDoc));
|
|
269
267
|
}
|
|
270
268
|
}
|
|
271
269
|
return jsDocs.find((doc) => doc.pos === ranges[0].pos);
|
|
@@ -405,6 +403,19 @@ function declarationToCommentNodes(node, checker) {
|
|
|
405
403
|
inheritedFromParentDeclaration: true,
|
|
406
404
|
});
|
|
407
405
|
}
|
|
406
|
+
// #2999 automatically pick up comments from the value symbol for shorthand assignments
|
|
407
|
+
if (ts.isShorthandPropertyAssignment(node)) {
|
|
408
|
+
const sourceSymbol = checker.getShorthandAssignmentValueSymbol(node);
|
|
409
|
+
if (sourceSymbol?.valueDeclaration) {
|
|
410
|
+
const commentNode = declarationToCommentNodeIgnoringParents(sourceSymbol.valueDeclaration);
|
|
411
|
+
if (commentNode) {
|
|
412
|
+
result.push({
|
|
413
|
+
node: commentNode,
|
|
414
|
+
inheritedFromParentDeclaration: true,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
408
419
|
// With overloaded functions/methods, TypeScript will use the comment on the first signature
|
|
409
420
|
// declaration
|
|
410
421
|
if ((ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) &&
|
|
@@ -195,7 +195,13 @@ function checkReference(data) {
|
|
|
195
195
|
while (/[ \t]/.test(token.text[lookahead])) {
|
|
196
196
|
++lookahead;
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
// #2991, we check that this reference also doesn't look like a footnote reference
|
|
199
|
+
// as it is unlikely that someone uses that syntax without intending for footnote behavior.
|
|
200
|
+
// This introduces a problem if someone has an [^ref] and doesn't intend for that to
|
|
201
|
+
// be interpreted as a footnote, but as a reference, but we can't have it both ways,
|
|
202
|
+
// and having people rename their reference to not be confused with a footnote isn't a
|
|
203
|
+
// horrible workaround.
|
|
204
|
+
if (token.text[lookahead] === "[" && token.text[lookahead + 1] !== "^") {
|
|
199
205
|
while (lookahead < token.text.length &&
|
|
200
206
|
/[^\n\]]/.test(token.text[lookahead])) {
|
|
201
207
|
++lookahead;
|
|
@@ -5,7 +5,7 @@ import { Context } from "./context.js";
|
|
|
5
5
|
import { AbstractComponent } from "../utils/component.js";
|
|
6
6
|
import { type GlobString, MinimalSourceFile } from "#utils";
|
|
7
7
|
import type { DocumentationEntryPoint } from "../utils/entry-point.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type CommentParserConfig } from "./comments/index.js";
|
|
9
9
|
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration.js";
|
|
10
10
|
import { type ExternalResolveResult, type ExternalSymbolResolver } from "./comments/linkResolver.js";
|
|
11
11
|
import { type DeclarationReference } from "#utils";
|
|
@@ -43,6 +43,7 @@ import { ConverterEvents } from "./converter-events.js";
|
|
|
43
43
|
import { convertSymbol } from "./symbols.js";
|
|
44
44
|
import { MinimatchSet, nicePath, normalizePath } from "../utils/paths.js";
|
|
45
45
|
import { hasAllFlags, hasAnyFlag, i18n, MinimalSourceFile, NormalizedPathUtils, partition, unique, } from "#utils";
|
|
46
|
+
import { clearCommentCache } from "./comments/index.js";
|
|
46
47
|
import { parseCommentString } from "./comments/parser.js";
|
|
47
48
|
import { lexCommentString } from "./comments/rawLexer.js";
|
|
48
49
|
import { resolveLinks, resolvePartLinks, } from "./comments/linkResolver.js";
|
|
@@ -320,6 +321,9 @@ let Converter = (() => {
|
|
|
320
321
|
delete this._config;
|
|
321
322
|
delete this.excludeCache;
|
|
322
323
|
delete this.externalPatternCache;
|
|
324
|
+
// Also clear the comment cache so if we convert this ts.Program again
|
|
325
|
+
// later we will re-parse comments.
|
|
326
|
+
clearCommentCache();
|
|
323
327
|
return project;
|
|
324
328
|
}
|
|
325
329
|
/** @internal */
|
|
@@ -144,6 +144,7 @@ module.exports = {
|
|
|
144
144
|
invalid_tsdoc_json_0: `The file {0} is not a valid tsdoc.json file`,
|
|
145
145
|
options_file_0_does_not_exist: `The options file {0} does not exist`,
|
|
146
146
|
failed_read_options_file_0: `Failed to parse {0}, ensure it exists and exports an object`,
|
|
147
|
+
failed_to_apply_compilerOptions_overrides_0: "Failed to apply compilerOptions overrides: {0}",
|
|
147
148
|
// plugins
|
|
148
149
|
invalid_plugin_0_missing_load_function: `Invalid structure in plugin {0}, no load function found`,
|
|
149
150
|
plugin_0_could_not_be_loaded: `The plugin {0} could not be loaded`,
|
|
@@ -360,7 +361,7 @@ module.exports = {
|
|
|
360
361
|
// Page headings/labels
|
|
361
362
|
theme_implements: "Implements",
|
|
362
363
|
theme_indexable: "Indexable",
|
|
363
|
-
theme_type_declaration: "Type
|
|
364
|
+
theme_type_declaration: "Type Declaration",
|
|
364
365
|
theme_index: "Index",
|
|
365
366
|
theme_hierarchy: "Hierarchy",
|
|
366
367
|
theme_hierarchy_summary: "Hierarchy Summary",
|
|
@@ -133,6 +133,7 @@ declare const _default: {
|
|
|
133
133
|
readonly invalid_tsdoc_json_0: "The file {0} is not a valid tsdoc.json file";
|
|
134
134
|
readonly options_file_0_does_not_exist: "The options file {0} does not exist";
|
|
135
135
|
readonly failed_read_options_file_0: "Failed to parse {0}, ensure it exists and exports an object";
|
|
136
|
+
readonly failed_to_apply_compilerOptions_overrides_0: "Failed to apply compilerOptions overrides: {0}";
|
|
136
137
|
readonly invalid_plugin_0_missing_load_function: "Invalid structure in plugin {0}, no load function found";
|
|
137
138
|
readonly plugin_0_could_not_be_loaded: "The plugin {0} could not be loaded";
|
|
138
139
|
readonly help_options: "Specify a json option file that should be loaded. If not specified TypeDoc will look for 'typedoc.json' in the current directory";
|
|
@@ -336,7 +337,7 @@ declare const _default: {
|
|
|
336
337
|
readonly flag_inherited: "Inherited";
|
|
337
338
|
readonly theme_implements: "Implements";
|
|
338
339
|
readonly theme_indexable: "Indexable";
|
|
339
|
-
readonly theme_type_declaration: "Type
|
|
340
|
+
readonly theme_type_declaration: "Type Declaration";
|
|
340
341
|
readonly theme_index: "Index";
|
|
341
342
|
readonly theme_hierarchy: "Hierarchy";
|
|
342
343
|
readonly theme_hierarchy_summary: "Hierarchy Summary";
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
1
35
|
import { TraverseProperty } from "./Reflection.js";
|
|
2
36
|
import { ContainerReflection } from "./ContainerReflection.js";
|
|
3
37
|
import { ReferenceReflection } from "./ReferenceReflection.js";
|
|
@@ -5,7 +39,7 @@ import { IntrinsicType, makeRecursiveVisitor } from "./types.js";
|
|
|
5
39
|
import { ReflectionKind } from "./kind.js";
|
|
6
40
|
import { Comment } from "./Comment.js";
|
|
7
41
|
import { ReflectionSymbolId } from "./ReflectionSymbolId.js";
|
|
8
|
-
import { assertNever, DefaultMap, i18n, removeIfPresent, StableKeyMap } from "#utils";
|
|
42
|
+
import { assertNever, DefaultMap, i18n, NonEnumerable, removeIfPresent, StableKeyMap, } from "#utils";
|
|
9
43
|
// Keep this in sync with JSONOutput.SCHEMA_VERSION
|
|
10
44
|
export const JSON_SCHEMA_VERSION = "2.0";
|
|
11
45
|
/**
|
|
@@ -15,331 +49,369 @@ export const JSON_SCHEMA_VERSION = "2.0";
|
|
|
15
49
|
* and source files of the processed project through this reflection.
|
|
16
50
|
* @category Reflections
|
|
17
51
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.reflections[this.id] = this;
|
|
55
|
-
this.files = registry;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Return whether this reflection is the root / project reflection.
|
|
59
|
-
*/
|
|
60
|
-
isProject() {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Return a list of all reflections in this project of a certain kind.
|
|
65
|
-
*
|
|
66
|
-
* @param kind The desired kind of reflection.
|
|
67
|
-
* @returns An array containing all reflections with the desired kind.
|
|
68
|
-
*/
|
|
69
|
-
getReflectionsByKind(kind) {
|
|
70
|
-
return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
74
|
-
* Should be called for *every* reflection added to the project.
|
|
75
|
-
*
|
|
76
|
-
* Note: During conversion, `Context.registerReflection` should be used instead so
|
|
77
|
-
* that symbols can be saved for later use.
|
|
78
|
-
*/
|
|
79
|
-
registerReflection(reflection, id, filePath) {
|
|
80
|
-
this.referenceGraph = undefined;
|
|
81
|
-
if (reflection.parent) {
|
|
82
|
-
this.reflectionChildren
|
|
83
|
-
.get(reflection.parent.id)
|
|
84
|
-
.push(reflection.id);
|
|
52
|
+
let ProjectReflection = (() => {
|
|
53
|
+
let _classSuper = ContainerReflection;
|
|
54
|
+
let _symbolToReflectionIdMap_decorators;
|
|
55
|
+
let _symbolToReflectionIdMap_initializers = [];
|
|
56
|
+
let _symbolToReflectionIdMap_extraInitializers = [];
|
|
57
|
+
let _reflectionIdToSymbolIdMap_decorators;
|
|
58
|
+
let _reflectionIdToSymbolIdMap_initializers = [];
|
|
59
|
+
let _reflectionIdToSymbolIdMap_extraInitializers = [];
|
|
60
|
+
let _removedSymbolIds_decorators;
|
|
61
|
+
let _removedSymbolIds_initializers = [];
|
|
62
|
+
let _removedSymbolIds_extraInitializers = [];
|
|
63
|
+
let _referenceGraph_decorators;
|
|
64
|
+
let _referenceGraph_initializers = [];
|
|
65
|
+
let _referenceGraph_extraInitializers = [];
|
|
66
|
+
let _reflectionChildren_decorators;
|
|
67
|
+
let _reflectionChildren_initializers = [];
|
|
68
|
+
let _reflectionChildren_extraInitializers = [];
|
|
69
|
+
let _reflections_decorators;
|
|
70
|
+
let _reflections_initializers = [];
|
|
71
|
+
let _reflections_extraInitializers = [];
|
|
72
|
+
return class ProjectReflection extends _classSuper {
|
|
73
|
+
static {
|
|
74
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
75
|
+
_symbolToReflectionIdMap_decorators = [NonEnumerable];
|
|
76
|
+
_reflectionIdToSymbolIdMap_decorators = [NonEnumerable];
|
|
77
|
+
_removedSymbolIds_decorators = [NonEnumerable];
|
|
78
|
+
_referenceGraph_decorators = [NonEnumerable];
|
|
79
|
+
_reflectionChildren_decorators = [NonEnumerable];
|
|
80
|
+
_reflections_decorators = [NonEnumerable];
|
|
81
|
+
__esDecorate(null, null, _symbolToReflectionIdMap_decorators, { kind: "field", name: "symbolToReflectionIdMap", static: false, private: false, access: { has: obj => "symbolToReflectionIdMap" in obj, get: obj => obj.symbolToReflectionIdMap, set: (obj, value) => { obj.symbolToReflectionIdMap = value; } }, metadata: _metadata }, _symbolToReflectionIdMap_initializers, _symbolToReflectionIdMap_extraInitializers);
|
|
82
|
+
__esDecorate(null, null, _reflectionIdToSymbolIdMap_decorators, { kind: "field", name: "reflectionIdToSymbolIdMap", static: false, private: false, access: { has: obj => "reflectionIdToSymbolIdMap" in obj, get: obj => obj.reflectionIdToSymbolIdMap, set: (obj, value) => { obj.reflectionIdToSymbolIdMap = value; } }, metadata: _metadata }, _reflectionIdToSymbolIdMap_initializers, _reflectionIdToSymbolIdMap_extraInitializers);
|
|
83
|
+
__esDecorate(null, null, _removedSymbolIds_decorators, { kind: "field", name: "removedSymbolIds", static: false, private: false, access: { has: obj => "removedSymbolIds" in obj, get: obj => obj.removedSymbolIds, set: (obj, value) => { obj.removedSymbolIds = value; } }, metadata: _metadata }, _removedSymbolIds_initializers, _removedSymbolIds_extraInitializers);
|
|
84
|
+
__esDecorate(null, null, _referenceGraph_decorators, { kind: "field", name: "referenceGraph", static: false, private: false, access: { has: obj => "referenceGraph" in obj, get: obj => obj.referenceGraph, set: (obj, value) => { obj.referenceGraph = value; } }, metadata: _metadata }, _referenceGraph_initializers, _referenceGraph_extraInitializers);
|
|
85
|
+
__esDecorate(null, null, _reflectionChildren_decorators, { kind: "field", name: "reflectionChildren", static: false, private: false, access: { has: obj => "reflectionChildren" in obj, get: obj => obj.reflectionChildren, set: (obj, value) => { obj.reflectionChildren = value; } }, metadata: _metadata }, _reflectionChildren_initializers, _reflectionChildren_extraInitializers);
|
|
86
|
+
__esDecorate(null, null, _reflections_decorators, { kind: "field", name: "reflections", static: false, private: false, access: { has: obj => "reflections" in obj, get: obj => obj.reflections, set: (obj, value) => { obj.reflections = value; } }, metadata: _metadata }, _reflections_initializers, _reflections_extraInitializers);
|
|
87
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
variant = "project";
|
|
90
|
+
// Used to resolve references.
|
|
91
|
+
symbolToReflectionIdMap = __runInitializers(this, _symbolToReflectionIdMap_initializers, new StableKeyMap());
|
|
92
|
+
reflectionIdToSymbolIdMap = (__runInitializers(this, _symbolToReflectionIdMap_extraInitializers), __runInitializers(this, _reflectionIdToSymbolIdMap_initializers, new Map()));
|
|
93
|
+
removedSymbolIds = (__runInitializers(this, _reflectionIdToSymbolIdMap_extraInitializers), __runInitializers(this, _removedSymbolIds_initializers, new StableKeyMap()));
|
|
94
|
+
// Maps a reflection ID to all references eventually referring to it.
|
|
95
|
+
referenceGraph = (__runInitializers(this, _removedSymbolIds_extraInitializers), __runInitializers(this, _referenceGraph_initializers, void 0));
|
|
96
|
+
// Maps a reflection ID to all reflections with it as their parent.
|
|
97
|
+
reflectionChildren = (__runInitializers(this, _referenceGraph_extraInitializers), __runInitializers(this, _reflectionChildren_initializers, new DefaultMap(() => [])));
|
|
98
|
+
/**
|
|
99
|
+
* A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
|
|
100
|
+
* All mutation should be done via {@link registerReflection} and {@link removeReflection}
|
|
101
|
+
* to ensure that links to reflections remain valid.
|
|
102
|
+
*
|
|
103
|
+
* This may be replaced with a `Map<number, Reflection>` someday.
|
|
104
|
+
*/
|
|
105
|
+
reflections = (__runInitializers(this, _reflectionChildren_extraInitializers), __runInitializers(this, _reflections_initializers, {}));
|
|
106
|
+
/**
|
|
107
|
+
* The name of the package that this reflection documents according to package.json.
|
|
108
|
+
*/
|
|
109
|
+
packageName = __runInitializers(this, _reflections_extraInitializers);
|
|
110
|
+
/**
|
|
111
|
+
* The version of the package that this reflection documents according to package.json.
|
|
112
|
+
*/
|
|
113
|
+
packageVersion;
|
|
114
|
+
/**
|
|
115
|
+
* The contents of the readme.md file of the project when found.
|
|
116
|
+
*/
|
|
117
|
+
readme;
|
|
118
|
+
/**
|
|
119
|
+
* Object which describes where to find content for relative links.
|
|
120
|
+
*/
|
|
121
|
+
files;
|
|
122
|
+
constructor(name, registry) {
|
|
123
|
+
super(name, ReflectionKind.Project);
|
|
124
|
+
this.reflections[this.id] = this;
|
|
125
|
+
this.files = registry;
|
|
89
126
|
}
|
|
90
|
-
|
|
91
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Return whether this reflection is the root / project reflection.
|
|
129
|
+
*/
|
|
130
|
+
isProject() {
|
|
131
|
+
return true;
|
|
92
132
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// And now try to remove references to it in the parent reflection.
|
|
116
|
-
// This might not find anything if someone called removeReflection on a member of a union
|
|
117
|
-
// but I think that could only be caused by a plugin doing something weird, not by a regular
|
|
118
|
-
// user... so this is probably good enough for now. Reflections that live on types are
|
|
119
|
-
// kind of half-real anyways.
|
|
120
|
-
const parent = reflection.parent;
|
|
121
|
-
parent?.traverse((child, property) => {
|
|
122
|
-
if (child !== reflection) {
|
|
123
|
-
return true; // Continue iteration
|
|
133
|
+
/**
|
|
134
|
+
* Return a list of all reflections in this project of a certain kind.
|
|
135
|
+
*
|
|
136
|
+
* @param kind The desired kind of reflection.
|
|
137
|
+
* @returns An array containing all reflections with the desired kind.
|
|
138
|
+
*/
|
|
139
|
+
getReflectionsByKind(kind) {
|
|
140
|
+
return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
144
|
+
* Should be called for *every* reflection added to the project.
|
|
145
|
+
*
|
|
146
|
+
* Note: During conversion, `Context.registerReflection` should be used instead so
|
|
147
|
+
* that symbols can be saved for later use.
|
|
148
|
+
*/
|
|
149
|
+
registerReflection(reflection, id, filePath) {
|
|
150
|
+
this.referenceGraph = undefined;
|
|
151
|
+
if (reflection.parent) {
|
|
152
|
+
this.reflectionChildren
|
|
153
|
+
.get(reflection.parent.id)
|
|
154
|
+
.push(reflection.id);
|
|
124
155
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
parent.removeChild(reflection);
|
|
129
|
-
break;
|
|
130
|
-
case TraverseProperty.GetSignature:
|
|
131
|
-
delete parent.getSignature;
|
|
132
|
-
break;
|
|
133
|
-
case TraverseProperty.IndexSignature:
|
|
134
|
-
removeIfPresent(parent.indexSignatures, reflection);
|
|
135
|
-
if (!parent.indexSignatures?.length) {
|
|
136
|
-
delete parent.indexSignatures;
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
case TraverseProperty.Parameters:
|
|
140
|
-
removeIfPresent(reflection.parent.parameters, reflection);
|
|
141
|
-
if (!reflection.parent.parameters
|
|
142
|
-
?.length) {
|
|
143
|
-
delete reflection.parent
|
|
144
|
-
.parameters;
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
case TraverseProperty.SetSignature:
|
|
148
|
-
delete parent.setSignature;
|
|
149
|
-
break;
|
|
150
|
-
case TraverseProperty.Signatures:
|
|
151
|
-
removeIfPresent(parent.signatures, reflection);
|
|
152
|
-
if (!parent.signatures?.length) {
|
|
153
|
-
delete parent.signatures;
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case TraverseProperty.TypeLiteral:
|
|
157
|
-
parent.type = new IntrinsicType("Object");
|
|
158
|
-
break;
|
|
159
|
-
case TraverseProperty.TypeParameter:
|
|
160
|
-
removeIfPresent(parent.typeParameters, reflection);
|
|
161
|
-
if (!parent.typeParameters?.length) {
|
|
162
|
-
delete parent.typeParameters;
|
|
163
|
-
}
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
assertNever(property);
|
|
156
|
+
this.reflections[reflection.id] = reflection;
|
|
157
|
+
if (id) {
|
|
158
|
+
this.registerSymbolId(reflection, id);
|
|
167
159
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
/** @internal */
|
|
172
|
-
mergeReflections(source, target) {
|
|
173
|
-
// First, tell the children about their new parent
|
|
174
|
-
delete this.referenceGraph;
|
|
175
|
-
const oldChildrenIds = this.reflectionChildren.getNoInsert(source.id) || [];
|
|
176
|
-
const newChildren = this.reflectionChildren.get(target.id);
|
|
177
|
-
for (const childId of oldChildrenIds) {
|
|
178
|
-
const childRefl = this.getReflectionById(childId);
|
|
179
|
-
// To avoid conflicting with some plugins which do this surgery somewhat incorrectly
|
|
180
|
-
// (typedoc-plugin-merge-modules and likely others I'm not aware of) only move children
|
|
181
|
-
// which are still children
|
|
182
|
-
if (childRefl?.parent === source) {
|
|
183
|
-
childRefl.parent = target;
|
|
184
|
-
newChildren.push(childId);
|
|
185
|
-
target.addChild(childRefl);
|
|
160
|
+
if (filePath) {
|
|
161
|
+
this.files.registerReflection(filePath, reflection);
|
|
186
162
|
}
|
|
187
163
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Removes references to reflections contained within the provided type.
|
|
166
|
+
* Plugins which overwrite types on reflections should pass the type to this
|
|
167
|
+
* method before overwriting the property.
|
|
168
|
+
* @since 0.26.6
|
|
169
|
+
*/
|
|
170
|
+
removeTypeReflections(type) {
|
|
171
|
+
type?.visit(makeRecursiveVisitor({
|
|
172
|
+
reflection: (type) => {
|
|
173
|
+
this.removeReflection(type.declaration);
|
|
174
|
+
},
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Removes a reflection from the documentation. Can be used by plugins to filter reflections
|
|
179
|
+
* out of the generated documentation. Has no effect if the reflection is not present in the
|
|
180
|
+
* project.
|
|
181
|
+
*/
|
|
182
|
+
removeReflection(reflection) {
|
|
183
|
+
// Remove the reflection...
|
|
184
|
+
this._removeReflection(reflection);
|
|
185
|
+
// And now try to remove references to it in the parent reflection.
|
|
186
|
+
// This might not find anything if someone called removeReflection on a member of a union
|
|
187
|
+
// but I think that could only be caused by a plugin doing something weird, not by a regular
|
|
188
|
+
// user... so this is probably good enough for now. Reflections that live on types are
|
|
189
|
+
// kind of half-real anyways.
|
|
190
|
+
const parent = reflection.parent;
|
|
191
|
+
parent?.traverse((child, property) => {
|
|
192
|
+
if (child !== reflection) {
|
|
193
|
+
return true; // Continue iteration
|
|
194
|
+
}
|
|
195
|
+
switch (property) {
|
|
196
|
+
case TraverseProperty.Children:
|
|
197
|
+
case TraverseProperty.Documents:
|
|
198
|
+
parent.removeChild(reflection);
|
|
199
|
+
break;
|
|
200
|
+
case TraverseProperty.GetSignature:
|
|
201
|
+
delete parent.getSignature;
|
|
202
|
+
break;
|
|
203
|
+
case TraverseProperty.IndexSignature:
|
|
204
|
+
removeIfPresent(parent.indexSignatures, reflection);
|
|
205
|
+
if (!parent.indexSignatures?.length) {
|
|
206
|
+
delete parent.indexSignatures;
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
case TraverseProperty.Parameters:
|
|
210
|
+
removeIfPresent(reflection.parent.parameters, reflection);
|
|
211
|
+
if (!reflection.parent.parameters
|
|
212
|
+
?.length) {
|
|
213
|
+
delete reflection.parent
|
|
214
|
+
.parameters;
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case TraverseProperty.SetSignature:
|
|
218
|
+
delete parent.setSignature;
|
|
219
|
+
break;
|
|
220
|
+
case TraverseProperty.Signatures:
|
|
221
|
+
removeIfPresent(parent.signatures, reflection);
|
|
222
|
+
if (!parent.signatures?.length) {
|
|
223
|
+
delete parent.signatures;
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case TraverseProperty.TypeLiteral:
|
|
227
|
+
parent.type = new IntrinsicType("Object");
|
|
228
|
+
break;
|
|
229
|
+
case TraverseProperty.TypeParameter:
|
|
230
|
+
removeIfPresent(parent.typeParameters, reflection);
|
|
231
|
+
if (!parent.typeParameters?.length) {
|
|
232
|
+
delete parent.typeParameters;
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
default:
|
|
236
|
+
assertNever(property);
|
|
237
|
+
}
|
|
238
|
+
return false; // Stop iteration
|
|
239
|
+
});
|
|
209
240
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this
|
|
241
|
+
/** @internal */
|
|
242
|
+
mergeReflections(source, target) {
|
|
243
|
+
// First, tell the children about their new parent
|
|
244
|
+
delete this.referenceGraph;
|
|
245
|
+
const oldChildrenIds = this.reflectionChildren.getNoInsert(source.id) || [];
|
|
246
|
+
const newChildren = this.reflectionChildren.get(target.id);
|
|
247
|
+
for (const childId of oldChildrenIds) {
|
|
248
|
+
const childRefl = this.getReflectionById(childId);
|
|
249
|
+
// To avoid conflicting with some plugins which do this surgery somewhat incorrectly
|
|
250
|
+
// (typedoc-plugin-merge-modules and likely others I'm not aware of) only move children
|
|
251
|
+
// which are still children
|
|
252
|
+
if (childRefl?.parent === source) {
|
|
253
|
+
childRefl.parent = target;
|
|
254
|
+
newChildren.push(childId);
|
|
255
|
+
target.addChild(childRefl);
|
|
256
|
+
}
|
|
219
257
|
}
|
|
258
|
+
// Then remove the now-empty parent
|
|
259
|
+
this.reflectionChildren.delete(source.id);
|
|
260
|
+
this.removeReflection(source);
|
|
261
|
+
// And remove any outdated collections of children on the new parent.
|
|
262
|
+
// So long as this is used before REVIVE(-100) or EVENT_BEGIN_RESOLVE(-100)
|
|
263
|
+
// this will make the appropriate plugin rebuild the lists.
|
|
264
|
+
delete target.groups;
|
|
265
|
+
delete target.categories;
|
|
220
266
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Remove a reflection without updating the parent reflection to remove references to the removed reflection.
|
|
269
|
+
*/
|
|
270
|
+
_removeReflection(reflection) {
|
|
271
|
+
this.files.removeReflection(reflection);
|
|
272
|
+
// Remove references pointing to this reflection
|
|
273
|
+
const graph = this.getReferenceGraph();
|
|
274
|
+
for (const id of graph.get(reflection.id) ?? []) {
|
|
275
|
+
const ref = this.getReflectionById(id);
|
|
276
|
+
if (ref) {
|
|
277
|
+
this.removeReflection(ref);
|
|
278
|
+
}
|
|
229
279
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
280
|
+
graph.delete(reflection.id);
|
|
281
|
+
// Remove children of this reflection
|
|
282
|
+
for (const childId of this.reflectionChildren.getNoInsert(reflection.id) || []) {
|
|
283
|
+
const child = this.getReflectionById(childId);
|
|
284
|
+
// Only remove if the child's parent is still actually this reflection.
|
|
285
|
+
// This might not be the case if a plugin has moved this reflection to another parent.
|
|
286
|
+
// (typedoc-plugin-merge-modules)
|
|
287
|
+
if (child?.parent === reflection) {
|
|
288
|
+
this._removeReflection(child);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
this.reflectionChildren.delete(reflection.id);
|
|
292
|
+
// Remove references from the TS symbol to this reflection.
|
|
293
|
+
const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
|
|
294
|
+
if (symbolId) {
|
|
295
|
+
const saved = this.symbolToReflectionIdMap.get(symbolId);
|
|
296
|
+
if (saved === reflection.id) {
|
|
297
|
+
this.symbolToReflectionIdMap.delete(symbolId);
|
|
233
298
|
this.removedSymbolIds.set(symbolId, true);
|
|
234
299
|
}
|
|
300
|
+
else if (typeof saved === "object") {
|
|
301
|
+
removeIfPresent(saved, reflection.id);
|
|
302
|
+
if (saved.length === 0) {
|
|
303
|
+
this.removedSymbolIds.set(symbolId, true);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
235
306
|
}
|
|
307
|
+
this.reflectionIdToSymbolIdMap.delete(reflection.id);
|
|
308
|
+
delete this.reflections[reflection.id];
|
|
236
309
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
*/
|
|
244
|
-
getReflectionById(id) {
|
|
245
|
-
return this.reflections[id];
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Gets the reflection associated with the given symbol id, if it exists.
|
|
249
|
-
* If there are multiple reflections associated with this symbol, gets the first one.
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
getReflectionFromSymbolId(symbolId) {
|
|
253
|
-
return this.getReflectionsFromSymbolId(symbolId)[0];
|
|
254
|
-
}
|
|
255
|
-
/** @internal */
|
|
256
|
-
getReflectionsFromSymbolId(symbolId) {
|
|
257
|
-
const id = this.symbolToReflectionIdMap.get(symbolId);
|
|
258
|
-
if (typeof id === "number") {
|
|
259
|
-
return [this.getReflectionById(id)];
|
|
310
|
+
/**
|
|
311
|
+
* Gets the reflection registered for the given reflection ID, or undefined if it is not present
|
|
312
|
+
* in the project.
|
|
313
|
+
*/
|
|
314
|
+
getReflectionById(id) {
|
|
315
|
+
return this.reflections[id];
|
|
260
316
|
}
|
|
261
|
-
|
|
262
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Gets the reflection associated with the given symbol id, if it exists.
|
|
319
|
+
* If there are multiple reflections associated with this symbol, gets the first one.
|
|
320
|
+
* @internal
|
|
321
|
+
*/
|
|
322
|
+
getReflectionFromSymbolId(symbolId) {
|
|
323
|
+
return this.getReflectionsFromSymbolId(symbolId)[0];
|
|
263
324
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
325
|
+
/** @internal */
|
|
326
|
+
getReflectionsFromSymbolId(symbolId) {
|
|
327
|
+
const id = this.symbolToReflectionIdMap.get(symbolId);
|
|
328
|
+
if (typeof id === "number") {
|
|
329
|
+
return [this.getReflectionById(id)];
|
|
330
|
+
}
|
|
331
|
+
else if (typeof id === "object") {
|
|
332
|
+
return id.map((id) => this.getReflectionById(id));
|
|
333
|
+
}
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
/** @internal */
|
|
337
|
+
getSymbolIdFromReflection(reflection) {
|
|
338
|
+
return this.reflectionIdToSymbolIdMap.get(reflection.id);
|
|
339
|
+
}
|
|
340
|
+
/** @internal */
|
|
341
|
+
registerSymbolId(reflection, id) {
|
|
342
|
+
this.removedSymbolIds.delete(id);
|
|
343
|
+
this.reflectionIdToSymbolIdMap.set(reflection.id, id);
|
|
344
|
+
const previous = this.symbolToReflectionIdMap.get(id);
|
|
345
|
+
if (previous) {
|
|
346
|
+
if (typeof previous === "number") {
|
|
347
|
+
this.symbolToReflectionIdMap.set(id, [previous, reflection.id]);
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
previous.push(reflection.id);
|
|
351
|
+
}
|
|
278
352
|
}
|
|
279
353
|
else {
|
|
280
|
-
|
|
354
|
+
this.symbolToReflectionIdMap.set(id, reflection.id);
|
|
281
355
|
}
|
|
282
356
|
}
|
|
283
|
-
|
|
284
|
-
this.
|
|
357
|
+
symbolIdHasBeenRemoved(id) {
|
|
358
|
+
return this.removedSymbolIds.has(id);
|
|
285
359
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const refs = this.referenceGraph.get(target.id) ?? [];
|
|
299
|
-
refs.push(ref.id);
|
|
300
|
-
this.referenceGraph.set(target.id, refs);
|
|
360
|
+
getReferenceGraph() {
|
|
361
|
+
if (!this.referenceGraph) {
|
|
362
|
+
this.referenceGraph = new Map();
|
|
363
|
+
for (const id in this.reflections) {
|
|
364
|
+
const ref = this.reflections[id];
|
|
365
|
+
if (ref instanceof ReferenceReflection) {
|
|
366
|
+
const target = ref.tryGetTargetReflection();
|
|
367
|
+
if (target) {
|
|
368
|
+
const refs = this.referenceGraph.get(target.id) ?? [];
|
|
369
|
+
refs.push(ref.id);
|
|
370
|
+
this.referenceGraph.set(target.id, refs);
|
|
371
|
+
}
|
|
301
372
|
}
|
|
302
373
|
}
|
|
303
374
|
}
|
|
375
|
+
return this.referenceGraph;
|
|
304
376
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
files: serializer.toObject(this.files),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
fromObject(de, obj) {
|
|
324
|
-
super.fromObject(de, obj);
|
|
325
|
-
// If updating this, also check the block in DeclarationReflection.fromObject.
|
|
326
|
-
this.packageName = obj.packageName;
|
|
327
|
-
this.packageVersion = obj.packageVersion;
|
|
328
|
-
if (obj.readme) {
|
|
329
|
-
this.readme = Comment.deserializeDisplayParts(de, obj.readme);
|
|
377
|
+
toObject(serializer) {
|
|
378
|
+
const symbolIdMap = {};
|
|
379
|
+
this.reflectionIdToSymbolIdMap.forEach((sid, id) => {
|
|
380
|
+
symbolIdMap[id] = sid.toObject();
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
384
|
+
...super.toObject(serializer),
|
|
385
|
+
variant: this.variant,
|
|
386
|
+
packageName: this.packageName,
|
|
387
|
+
packageVersion: this.packageVersion,
|
|
388
|
+
readme: Comment.serializeDisplayParts(this.readme),
|
|
389
|
+
symbolIdMap,
|
|
390
|
+
files: serializer.toObject(this.files),
|
|
391
|
+
};
|
|
330
392
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(id.toString()));
|
|
341
|
-
}
|
|
393
|
+
fromObject(de, obj) {
|
|
394
|
+
super.fromObject(de, obj);
|
|
395
|
+
// If updating this, also check the block in DeclarationReflection.fromObject.
|
|
396
|
+
this.packageName = obj.packageName;
|
|
397
|
+
this.packageVersion = obj.packageVersion;
|
|
398
|
+
if (obj.readme) {
|
|
399
|
+
this.readme = Comment.deserializeDisplayParts(de, obj.readme);
|
|
342
400
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
401
|
+
this.files.fromObject(de, obj.files || {});
|
|
402
|
+
de.defer(() => {
|
|
403
|
+
// Unnecessary conditional in release
|
|
404
|
+
for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
|
|
405
|
+
const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
|
|
406
|
+
if (refl) {
|
|
407
|
+
this.registerSymbolId(refl, new ReflectionSymbolId(sid));
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(id.toString()));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
})();
|
|
417
|
+
export { ProjectReflection };
|
|
@@ -566,6 +566,7 @@ export class FormattedCodeBuilder {
|
|
|
566
566
|
const id = this.newId();
|
|
567
567
|
return group(id, [
|
|
568
568
|
name,
|
|
569
|
+
sig.parent.flags.isOptional ? simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, "?")) : emptyNode,
|
|
569
570
|
this.typeParameters(sig),
|
|
570
571
|
...this.parameters(sig, id),
|
|
571
572
|
nodes(options.arrowStyle ? space() : emptyNode, simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, options.arrowStyle ? "=>" : ":")), space(), this.type(sig.type, TypeContext.none)),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeclarationReflection } from "
|
|
1
|
+
import type { DeclarationReflection } from "#models";
|
|
2
2
|
import { JSX } from "#utils";
|
|
3
3
|
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext.js";
|
|
4
4
|
export declare function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection): JSX.Element;
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import { JSX } from "#utils";
|
|
2
2
|
import { FormattedCodeBuilder, FormattedCodeGenerator, Wrap } from "../../../formatter.js";
|
|
3
3
|
import { hasTypeParameters } from "../../lib.js";
|
|
4
|
+
function shouldRenderDefaultValue(props) {
|
|
5
|
+
const defaultValue = props.defaultValue;
|
|
6
|
+
if (defaultValue === undefined) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
/** Fix for #2717. If type is the same as value the default value is omitted */
|
|
10
|
+
if (props.type && props.type.type === "literal") {
|
|
11
|
+
const reflectionTypeString = props.type.toString();
|
|
12
|
+
if (reflectionTypeString === defaultValue.toString()) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
4
18
|
export function memberDeclaration(context, props) {
|
|
5
19
|
const builder = new FormattedCodeBuilder(context.router, context.model);
|
|
6
20
|
const content = [];
|
|
7
21
|
builder.member(content, props, { topLevelLinks: false });
|
|
8
22
|
const generator = new FormattedCodeGenerator(context.options.getValue("typePrintWidth"));
|
|
9
23
|
generator.node({ type: "nodes", content }, Wrap.Detect);
|
|
10
|
-
/** Fix for #2717. If type is the same as value the default value is omitted */
|
|
11
|
-
function shouldRenderDefaultValue() {
|
|
12
|
-
if (props.type && props.type.type === "literal") {
|
|
13
|
-
const reflectionTypeString = props.type.toString();
|
|
14
|
-
const defaultValue = props.defaultValue;
|
|
15
|
-
if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
24
|
return (JSX.createElement(JSX.Fragment, null,
|
|
22
25
|
JSX.createElement("div", { class: "tsd-signature" },
|
|
23
26
|
generator.toElement(),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
props.defaultValue)))),
|
|
27
|
+
shouldRenderDefaultValue(props) && (JSX.createElement("span", { class: "tsd-signature-symbol" },
|
|
28
|
+
" = ",
|
|
29
|
+
props.defaultValue))),
|
|
28
30
|
context.commentSummary(props),
|
|
29
31
|
hasTypeParameters(props) && context.typeParameters(props.typeParameters),
|
|
30
32
|
props.type && context.typeDeclaration(props, props.type),
|
|
@@ -29,7 +29,7 @@ export function moduleReflection(context, mod) {
|
|
|
29
29
|
})));
|
|
30
30
|
}
|
|
31
31
|
export function moduleMemberSummary(context, member) {
|
|
32
|
-
const id = context.slugger.slug(member.name);
|
|
32
|
+
const id = member.isReference() ? context.getAnchor(member) : context.slugger.slug(member.name);
|
|
33
33
|
context.page.pageHeadings.push({
|
|
34
34
|
link: `#${id}`,
|
|
35
35
|
text: getDisplayName(member),
|
|
@@ -214,7 +214,7 @@ function getEntryPointsForPaths(logger, inputFiles, options, programs = getEntry
|
|
|
214
214
|
return entryPoints;
|
|
215
215
|
}
|
|
216
216
|
export function getExpandedEntryPointsForPaths(logger, inputFiles, options, programs = getEntryPrograms(inputFiles, logger, options)) {
|
|
217
|
-
const compilerOptions = options.getCompilerOptions();
|
|
217
|
+
const compilerOptions = options.getCompilerOptions(logger);
|
|
218
218
|
const supportedFileRegex = compilerOptions.allowJs || compilerOptions.checkJs
|
|
219
219
|
? /\.([cm][tj]s|[tj]sx?)$/
|
|
220
220
|
: /\.([cm]ts|tsx?)$/;
|
|
@@ -252,14 +252,14 @@ function getEntryPrograms(inputFiles, logger, options) {
|
|
|
252
252
|
const rootProgram = noTsConfigFound
|
|
253
253
|
? ts.createProgram({
|
|
254
254
|
rootNames: inputFiles,
|
|
255
|
-
options: options.getCompilerOptions(),
|
|
255
|
+
options: options.getCompilerOptions(logger),
|
|
256
256
|
})
|
|
257
257
|
: ts.createProgram({
|
|
258
258
|
rootNames: options.getFileNames(),
|
|
259
|
-
options: options.getCompilerOptions(),
|
|
259
|
+
options: options.getCompilerOptions(logger),
|
|
260
260
|
projectReferences: options.getProjectReferences(),
|
|
261
261
|
});
|
|
262
|
-
addInferredDeclarationMapPaths(options.getCompilerOptions(), options.getFileNames());
|
|
262
|
+
addInferredDeclarationMapPaths(options.getCompilerOptions(logger), options.getFileNames());
|
|
263
263
|
const programs = [rootProgram];
|
|
264
264
|
// This might be a solution style tsconfig, in which case we need to add a program for each
|
|
265
265
|
// reference so that the converter can look through each of these.
|
|
@@ -270,7 +270,7 @@ function getEntryPrograms(inputFiles, logger, options) {
|
|
|
270
270
|
if (!ref)
|
|
271
271
|
continue; // This indicates bad configuration... will be reported later.
|
|
272
272
|
programs.push(ts.createProgram({
|
|
273
|
-
options: options.fixCompilerOptions(ref.commandLine.options),
|
|
273
|
+
options: options.fixCompilerOptions(ref.commandLine.options, logger),
|
|
274
274
|
rootNames: ref.commandLine.fileNames,
|
|
275
275
|
projectReferences: ref.commandLine.projectReferences,
|
|
276
276
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
import type { Application } from "../../../index.js";
|
|
3
3
|
import { type DeclarationOption, type KeyToDeclaration, type TypeDocOptionMap, type TypeDocOptions, type TypeDocOptionValues } from "./declaration.js";
|
|
4
4
|
import { type Logger, type NeverIfInternal } from "#utils";
|
|
@@ -156,9 +156,9 @@ export declare class Options {
|
|
|
156
156
|
/**
|
|
157
157
|
* Gets the set compiler options.
|
|
158
158
|
*/
|
|
159
|
-
getCompilerOptions(): ts.CompilerOptions;
|
|
159
|
+
getCompilerOptions(logger: Logger): ts.CompilerOptions;
|
|
160
160
|
/** @internal */
|
|
161
|
-
fixCompilerOptions(options: Readonly<ts.CompilerOptions
|
|
161
|
+
fixCompilerOptions(options: Readonly<ts.CompilerOptions>, logger: Logger): ts.CompilerOptions;
|
|
162
162
|
/**
|
|
163
163
|
* Gets the file names discovered through reading a tsconfig file.
|
|
164
164
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
1
2
|
import { resolve } from "path";
|
|
2
3
|
import { ParameterType } from "./declaration.js";
|
|
3
4
|
import { normalizePath } from "../paths.js";
|
|
@@ -185,15 +186,25 @@ export class Options {
|
|
|
185
186
|
/**
|
|
186
187
|
* Gets the set compiler options.
|
|
187
188
|
*/
|
|
188
|
-
getCompilerOptions() {
|
|
189
|
-
return this.fixCompilerOptions(this._compilerOptions);
|
|
189
|
+
getCompilerOptions(logger) {
|
|
190
|
+
return this.fixCompilerOptions(this._compilerOptions, logger);
|
|
190
191
|
}
|
|
191
192
|
/** @internal */
|
|
192
|
-
fixCompilerOptions(options) {
|
|
193
|
+
fixCompilerOptions(options, logger) {
|
|
193
194
|
const overrides = this.getValue("compilerOptions");
|
|
194
195
|
const result = { ...options };
|
|
195
196
|
if (overrides) {
|
|
196
|
-
|
|
197
|
+
const tsOptions = ts.convertCompilerOptionsFromJson(overrides, ".", "typedoc-overrides.json");
|
|
198
|
+
if (tsOptions.errors.length) {
|
|
199
|
+
for (const error of tsOptions.errors) {
|
|
200
|
+
logger.error(i18n.failed_to_apply_compilerOptions_overrides_0(ts.flattenDiagnosticMessageText(error.messageText, "\n")));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
for (const key in overrides) {
|
|
205
|
+
result[key] = tsOptions.options[key];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
197
208
|
}
|
|
198
209
|
if (this.getValue("emit") !== "both") {
|
|
199
210
|
result.noEmit = true;
|