typedoc 0.28.9 → 0.28.10

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.
@@ -195,7 +195,13 @@ function checkReference(data) {
195
195
  while (/[ \t]/.test(token.text[lookahead])) {
196
196
  ++lookahead;
197
197
  }
198
- if (token.text[lookahead] === "[") {
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 { CommentParserConfig } from "./comments/index.js";
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 */
@@ -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
- export class ProjectReflection extends ContainerReflection {
19
- variant = "project";
20
- // Used to resolve references.
21
- symbolToReflectionIdMap = new StableKeyMap();
22
- reflectionIdToSymbolIdMap = new Map();
23
- removedSymbolIds = new StableKeyMap();
24
- // Maps a reflection ID to all references eventually referring to it.
25
- referenceGraph;
26
- // Maps a reflection ID to all reflections with it as their parent.
27
- reflectionChildren = new DefaultMap(() => []);
28
- /**
29
- * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
30
- * All mutation should be done via {@link registerReflection} and {@link removeReflection}
31
- * to ensure that links to reflections remain valid.
32
- *
33
- * This may be replaced with a `Map<number, Reflection>` someday.
34
- */
35
- reflections = {};
36
- /**
37
- * The name of the package that this reflection documents according to package.json.
38
- */
39
- packageName;
40
- /**
41
- * The version of the package that this reflection documents according to package.json.
42
- */
43
- packageVersion;
44
- /**
45
- * The contents of the readme.md file of the project when found.
46
- */
47
- readme;
48
- /**
49
- * Object which describes where to find content for relative links.
50
- */
51
- files;
52
- constructor(name, registry) {
53
- super(name, ReflectionKind.Project);
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
- this.reflections[reflection.id] = reflection;
87
- if (id) {
88
- this.registerSymbolId(reflection, id);
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
- if (filePath) {
91
- this.files.registerReflection(filePath, reflection);
127
+ /**
128
+ * Return whether this reflection is the root / project reflection.
129
+ */
130
+ isProject() {
131
+ return true;
92
132
  }
93
- }
94
- /**
95
- * Removes references to reflections contained within the provided type.
96
- * Plugins which overwrite types on reflections should pass the type to this
97
- * method before overwriting the property.
98
- * @since 0.26.6
99
- */
100
- removeTypeReflections(type) {
101
- type?.visit(makeRecursiveVisitor({
102
- reflection: (type) => {
103
- this.removeReflection(type.declaration);
104
- },
105
- }));
106
- }
107
- /**
108
- * Removes a reflection from the documentation. Can be used by plugins to filter reflections
109
- * out of the generated documentation. Has no effect if the reflection is not present in the
110
- * project.
111
- */
112
- removeReflection(reflection) {
113
- // Remove the reflection...
114
- this._removeReflection(reflection);
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
- switch (property) {
126
- case TraverseProperty.Children:
127
- case TraverseProperty.Documents:
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
- return false; // Stop iteration
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
- // Then remove the now-empty parent
189
- this.reflectionChildren.delete(source.id);
190
- this.removeReflection(source);
191
- // And remove any outdated collections of children on the new parent.
192
- // So long as this is used before REVIVE(-100) or EVENT_BEGIN_RESOLVE(-100)
193
- // this will make the appropriate plugin rebuild the lists.
194
- delete target.groups;
195
- delete target.categories;
196
- }
197
- /**
198
- * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
199
- */
200
- _removeReflection(reflection) {
201
- this.files.removeReflection(reflection);
202
- // Remove references pointing to this reflection
203
- const graph = this.getReferenceGraph();
204
- for (const id of graph.get(reflection.id) ?? []) {
205
- const ref = this.getReflectionById(id);
206
- if (ref) {
207
- this.removeReflection(ref);
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
- graph.delete(reflection.id);
211
- // Remove children of this reflection
212
- for (const childId of this.reflectionChildren.getNoInsert(reflection.id) || []) {
213
- const child = this.getReflectionById(childId);
214
- // Only remove if the child's parent is still actually this reflection.
215
- // This might not be the case if a plugin has moved this reflection to another parent.
216
- // (typedoc-plugin-merge-modules)
217
- if (child?.parent === reflection) {
218
- this._removeReflection(child);
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
- this.reflectionChildren.delete(reflection.id);
222
- // Remove references from the TS symbol to this reflection.
223
- const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
224
- if (symbolId) {
225
- const saved = this.symbolToReflectionIdMap.get(symbolId);
226
- if (saved === reflection.id) {
227
- this.symbolToReflectionIdMap.delete(symbolId);
228
- this.removedSymbolIds.set(symbolId, true);
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
- else if (typeof saved === "object") {
231
- removeIfPresent(saved, reflection.id);
232
- if (saved.length === 0) {
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
- this.reflectionIdToSymbolIdMap.delete(reflection.id);
238
- delete this.reflections[reflection.id];
239
- }
240
- /**
241
- * Gets the reflection registered for the given reflection ID, or undefined if it is not present
242
- * in the project.
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
- else if (typeof id === "object") {
262
- return id.map((id) => this.getReflectionById(id));
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
- return [];
265
- }
266
- /** @internal */
267
- getSymbolIdFromReflection(reflection) {
268
- return this.reflectionIdToSymbolIdMap.get(reflection.id);
269
- }
270
- /** @internal */
271
- registerSymbolId(reflection, id) {
272
- this.removedSymbolIds.delete(id);
273
- this.reflectionIdToSymbolIdMap.set(reflection.id, id);
274
- const previous = this.symbolToReflectionIdMap.get(id);
275
- if (previous) {
276
- if (typeof previous === "number") {
277
- this.symbolToReflectionIdMap.set(id, [previous, reflection.id]);
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
- previous.push(reflection.id);
354
+ this.symbolToReflectionIdMap.set(id, reflection.id);
281
355
  }
282
356
  }
283
- else {
284
- this.symbolToReflectionIdMap.set(id, reflection.id);
357
+ symbolIdHasBeenRemoved(id) {
358
+ return this.removedSymbolIds.has(id);
285
359
  }
286
- }
287
- symbolIdHasBeenRemoved(id) {
288
- return this.removedSymbolIds.has(id);
289
- }
290
- getReferenceGraph() {
291
- if (!this.referenceGraph) {
292
- this.referenceGraph = new Map();
293
- for (const id in this.reflections) {
294
- const ref = this.reflections[id];
295
- if (ref instanceof ReferenceReflection) {
296
- const target = ref.tryGetTargetReflection();
297
- if (target) {
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
- return this.referenceGraph;
306
- }
307
- toObject(serializer) {
308
- const symbolIdMap = {};
309
- this.reflectionIdToSymbolIdMap.forEach((sid, id) => {
310
- symbolIdMap[id] = sid.toObject();
311
- });
312
- return {
313
- schemaVersion: JSON_SCHEMA_VERSION,
314
- ...super.toObject(serializer),
315
- variant: this.variant,
316
- packageName: this.packageName,
317
- packageVersion: this.packageVersion,
318
- readme: Comment.serializeDisplayParts(this.readme),
319
- symbolIdMap,
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
- this.files.fromObject(de, obj.files || {});
332
- de.defer(() => {
333
- // Unnecessary conditional in release
334
- for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
335
- const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
336
- if (refl) {
337
- this.registerSymbolId(refl, new ReflectionSymbolId(sid));
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 };
@@ -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),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.28.9",
4
+ "version": "0.28.10",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {