typedoc 0.26.4 → 0.26.5

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/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export * from "./lib/models";
20
20
  export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, type ConverterEvents, } from "./lib/converter";
21
21
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, Slugger, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
22
22
  export type { RenderTemplate, RendererHooks, NavigationElement, RendererEvents, PageHeading, } from "./lib/output";
23
- export { ArgumentsReader, Option, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils";
23
+ export { ArgumentsReader, Option, CommentStyle, JSX, LogLevel, Logger, Options, OptionDefaults, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils";
24
24
  export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, JsDocCompatibility, } from "./lib/utils";
25
25
  export { JSONOutput, Serializer, type SerializerEvents, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
26
26
  export * as Internationalization from "./lib/internationalization/index";
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.TypeScript = exports.Internationalization = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.Slugger = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.EventDispatcher = exports.Application = void 0;
32
+ exports.TypeScript = exports.Internationalization = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.OptionDefaults = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.Slugger = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.EventDispatcher = exports.Application = void 0;
33
33
  var application_1 = require("./lib/application");
34
34
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
35
35
  var events_1 = require("./lib/utils/events");
@@ -74,6 +74,7 @@ Object.defineProperty(exports, "JSX", { enumerable: true, get: function () { ret
74
74
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return utils_1.LogLevel; } });
75
75
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return utils_1.Logger; } });
76
76
  Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return utils_1.Options; } });
77
+ Object.defineProperty(exports, "OptionDefaults", { enumerable: true, get: function () { return utils_1.OptionDefaults; } });
77
78
  Object.defineProperty(exports, "PackageJsonReader", { enumerable: true, get: function () { return utils_1.PackageJsonReader; } });
78
79
  Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: function () { return utils_1.ParameterHint; } });
79
80
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return utils_1.ParameterType; } });
@@ -308,6 +308,11 @@ function declarationToCommentNodeIgnoringParents(node) {
308
308
  // ts.SourceFile is a counterexample
309
309
  if (!node.parent)
310
310
  return node;
311
+ // function foo(x: number)
312
+ // ^^^^^^^^^
313
+ if (node.kind === typescript_1.default.SyntaxKind.Parameter) {
314
+ return node;
315
+ }
311
316
  // const abc = 123
312
317
  // ^^^
313
318
  if (node.parent.kind === typescript_1.default.SyntaxKind.VariableDeclarationList) {
@@ -140,8 +140,8 @@ function parseCommentString(tokens, config, file, logger, files) {
140
140
  }
141
141
  // Check for frontmatter
142
142
  let frontmatterData = {};
143
- const firstBlock = content[0];
144
- if (firstBlock.text.startsWith("---\n")) {
143
+ const firstBlock = content.at(0);
144
+ if (firstBlock?.text.startsWith("---\n")) {
145
145
  const end = firstBlock.text.indexOf("\n---\n");
146
146
  if (end !== -1) {
147
147
  const yamlText = firstBlock.text.slice("---\n".length, end);
@@ -6,6 +6,7 @@ import { ConverterComponent } from "../components";
6
6
  export declare class ImplementsPlugin extends ConverterComponent {
7
7
  private resolved;
8
8
  private postponed;
9
+ private revivingSerialized;
9
10
  /**
10
11
  * Create a new ImplementsPlugin instance.
11
12
  */
@@ -16,6 +17,7 @@ export declare class ImplementsPlugin extends ConverterComponent {
16
17
  private analyzeImplements;
17
18
  private analyzeInheritance;
18
19
  private onResolveEnd;
20
+ private onRevive;
19
21
  private resolve;
20
22
  private tryResolve;
21
23
  private doResolve;
@@ -28,4 +30,14 @@ export declare class ImplementsPlugin extends ConverterComponent {
28
30
  * during the resolve step with links which actually point to the right place.
29
31
  */
30
32
  private onDeclaration;
33
+ /**
34
+ * Responsible for copying comments from "parent" reflections defined
35
+ * in either a base class or implemented interface to the child class.
36
+ */
37
+ private handleInheritedComments;
38
+ /**
39
+ * Copy the comment of the source reflection to the target reflection with a JSDoc style copy
40
+ * function. The TSDoc copy function is in the InheritDocPlugin.
41
+ */
42
+ private copyComment;
31
43
  }
@@ -65,6 +65,7 @@ let ImplementsPlugin = (() => {
65
65
  super(...arguments);
66
66
  this.resolved = new WeakSet();
67
67
  this.postponed = new WeakMap();
68
+ this.revivingSerialized = false;
68
69
  }
69
70
  /**
70
71
  * Create a new ImplementsPlugin instance.
@@ -73,13 +74,13 @@ let ImplementsPlugin = (() => {
73
74
  this.owner.on(converter_1.Converter.EVENT_RESOLVE_END, this.onResolveEnd.bind(this));
74
75
  this.owner.on(converter_1.Converter.EVENT_CREATE_DECLARATION, this.onDeclaration.bind(this), -1000);
75
76
  this.owner.on(converter_1.Converter.EVENT_CREATE_SIGNATURE, this.onSignature.bind(this), 1000);
76
- this.application.on(application_events_1.ApplicationEvents.REVIVE, this.resolve.bind(this));
77
+ this.application.on(application_events_1.ApplicationEvents.REVIVE, this.onRevive.bind(this));
77
78
  }
78
79
  /**
79
80
  * Mark all members of the given class to be the implementation of the matching interface member.
80
81
  */
81
82
  analyzeImplements(project, classReflection, interfaceReflection) {
82
- handleInheritedComments(classReflection, interfaceReflection);
83
+ this.handleInheritedComments(classReflection, interfaceReflection);
83
84
  if (!interfaceReflection.children) {
84
85
  return;
85
86
  }
@@ -110,7 +111,7 @@ let ImplementsPlugin = (() => {
110
111
  }
111
112
  }
112
113
  }
113
- handleInheritedComments(classMember, interfaceMember);
114
+ this.handleInheritedComments(classMember, interfaceMember);
114
115
  });
115
116
  }
116
117
  analyzeInheritance(project, reflection) {
@@ -121,7 +122,7 @@ let ImplementsPlugin = (() => {
121
122
  : void 0;
122
123
  });
123
124
  for (const parent of extendedTypes) {
124
- handleInheritedComments(reflection, parent.reflection);
125
+ this.handleInheritedComments(reflection, parent.reflection);
125
126
  for (const parentMember of parent.reflection.children ?? []) {
126
127
  const child = findMatchingMember(parentMember, reflection);
127
128
  if (child) {
@@ -132,7 +133,7 @@ let ImplementsPlugin = (() => {
132
133
  childSig[key] = types_1.ReferenceType.createResolvedReference(`${parent.name}.${parentMember.name}`, parentSig, project);
133
134
  }
134
135
  child[key] = types_1.ReferenceType.createResolvedReference(`${parent.name}.${parentMember.name}`, parentMember, project);
135
- handleInheritedComments(child, parentMember);
136
+ this.handleInheritedComments(child, parentMember);
136
137
  }
137
138
  }
138
139
  }
@@ -140,6 +141,11 @@ let ImplementsPlugin = (() => {
140
141
  onResolveEnd(context) {
141
142
  this.resolve(context.project);
142
143
  }
144
+ onRevive(project) {
145
+ this.revivingSerialized = true;
146
+ this.resolve(project);
147
+ this.revivingSerialized = false;
148
+ }
143
149
  resolve(project) {
144
150
  for (const id in project.reflections) {
145
151
  const refl = project.reflections[id];
@@ -262,6 +268,73 @@ let ImplementsPlugin = (() => {
262
268
  }
263
269
  }
264
270
  }
271
+ /**
272
+ * Responsible for copying comments from "parent" reflections defined
273
+ * in either a base class or implemented interface to the child class.
274
+ */
275
+ handleInheritedComments(child, parent) {
276
+ this.copyComment(child, parent);
277
+ if (parent.kindOf(index_1.ReflectionKind.Property) &&
278
+ child.kindOf(index_1.ReflectionKind.Accessor)) {
279
+ if (child.getSignature) {
280
+ this.copyComment(child.getSignature, parent);
281
+ child.getSignature.implementationOf = child.implementationOf;
282
+ }
283
+ if (child.setSignature) {
284
+ this.copyComment(child.setSignature, parent);
285
+ child.setSignature.implementationOf = child.implementationOf;
286
+ }
287
+ }
288
+ if (parent.kindOf(index_1.ReflectionKind.Accessor) &&
289
+ child.kindOf(index_1.ReflectionKind.Accessor)) {
290
+ if (parent.getSignature && child.getSignature) {
291
+ this.copyComment(child.getSignature, parent.getSignature);
292
+ }
293
+ if (parent.setSignature && child.setSignature) {
294
+ this.copyComment(child.setSignature, parent.setSignature);
295
+ }
296
+ }
297
+ if (parent.kindOf(index_1.ReflectionKind.FunctionOrMethod) &&
298
+ parent.signatures &&
299
+ child.signatures) {
300
+ for (const [cs, ps] of (0, array_1.zip)(child.signatures, parent.signatures)) {
301
+ this.copyComment(cs, ps);
302
+ }
303
+ }
304
+ else if (parent.kindOf(index_1.ReflectionKind.Property) &&
305
+ parent.type instanceof types_1.ReflectionType &&
306
+ parent.type.declaration.signatures &&
307
+ child.signatures) {
308
+ for (const [cs, ps] of (0, array_1.zip)(child.signatures, parent.type.declaration.signatures)) {
309
+ this.copyComment(cs, ps);
310
+ }
311
+ }
312
+ }
313
+ /**
314
+ * Copy the comment of the source reflection to the target reflection with a JSDoc style copy
315
+ * function. The TSDoc copy function is in the InheritDocPlugin.
316
+ */
317
+ copyComment(target, source) {
318
+ if (!shouldCopyComment(target, source, this.revivingSerialized)) {
319
+ return;
320
+ }
321
+ target.comment = source.comment.clone();
322
+ if (target instanceof index_1.DeclarationReflection &&
323
+ source instanceof index_1.DeclarationReflection) {
324
+ for (const [tt, ts] of (0, array_1.zip)(target.typeParameters || [], source.typeParameters || [])) {
325
+ this.copyComment(tt, ts);
326
+ }
327
+ }
328
+ if (target instanceof index_1.SignatureReflection &&
329
+ source instanceof index_1.SignatureReflection) {
330
+ for (const [tt, ts] of (0, array_1.zip)(target.typeParameters || [], source.typeParameters || [])) {
331
+ this.copyComment(tt, ts);
332
+ }
333
+ for (const [pt, ps] of (0, array_1.zip)(target.parameters || [], source.parameters || [])) {
334
+ this.copyComment(pt, ps);
335
+ }
336
+ }
337
+ }
265
338
  };
266
339
  __setFunctionName(_classThis, "ImplementsPlugin");
267
340
  (() => {
@@ -305,7 +378,9 @@ function createLink(context, reflection, clause, expr, symbol, isInherit) {
305
378
  link(sig);
306
379
  }
307
380
  // Intentionally create broken links here. These will be replaced with real links during
308
- // resolution if we can do so.
381
+ // resolution if we can do so. We create broken links rather than real links because in the
382
+ // case of an inherited symbol, we'll end up referencing a single symbol ID rather than one
383
+ // for each class.
309
384
  function link(target) {
310
385
  if (!target)
311
386
  return;
@@ -322,79 +397,23 @@ function createLink(context, reflection, clause, expr, symbol, isInherit) {
322
397
  }
323
398
  }
324
399
  }
325
- /**
326
- * Responsible for copying comments from "parent" reflections defined
327
- * in either a base class or implemented interface to the child class.
328
- */
329
- function handleInheritedComments(child, parent) {
330
- copyComment(child, parent);
331
- if (parent.kindOf(index_1.ReflectionKind.Property) &&
332
- child.kindOf(index_1.ReflectionKind.Accessor)) {
333
- if (child.getSignature) {
334
- copyComment(child.getSignature, parent);
335
- child.getSignature.implementationOf = child.implementationOf;
336
- }
337
- if (child.setSignature) {
338
- copyComment(child.setSignature, parent);
339
- child.setSignature.implementationOf = child.implementationOf;
340
- }
341
- }
342
- if (parent.kindOf(index_1.ReflectionKind.Accessor) &&
343
- child.kindOf(index_1.ReflectionKind.Accessor)) {
344
- if (parent.getSignature && child.getSignature) {
345
- copyComment(child.getSignature, parent.getSignature);
346
- }
347
- if (parent.setSignature && child.setSignature) {
348
- copyComment(child.setSignature, parent.setSignature);
349
- }
350
- }
351
- if (parent.kindOf(index_1.ReflectionKind.FunctionOrMethod) &&
352
- parent.signatures &&
353
- child.signatures) {
354
- for (const [cs, ps] of (0, array_1.zip)(child.signatures, parent.signatures)) {
355
- copyComment(cs, ps);
356
- }
357
- }
358
- else if (parent.kindOf(index_1.ReflectionKind.Property) &&
359
- parent.type instanceof types_1.ReflectionType &&
360
- parent.type.declaration.signatures &&
361
- child.signatures) {
362
- for (const [cs, ps] of (0, array_1.zip)(child.signatures, parent.type.declaration.signatures)) {
363
- copyComment(cs, ps);
364
- }
400
+ function shouldCopyComment(target, source, revivingSerialized) {
401
+ if (!source.comment) {
402
+ return false;
365
403
  }
366
- }
367
- /**
368
- * Copy the comment of the source reflection to the target reflection with a JSDoc style copy
369
- * function. The TSDoc copy function is in the InheritDocPlugin.
370
- */
371
- function copyComment(target, source) {
372
404
  if (target.comment) {
405
+ // If we're reviving, then the revived project might have a better comment
406
+ // on source, so copy it.
407
+ if (revivingSerialized && source.comment.similarTo(target.comment)) {
408
+ return true;
409
+ }
373
410
  // We might still want to copy, if the child has a JSDoc style inheritDoc tag.
374
411
  const tag = target.comment.getTag("@inheritDoc");
375
412
  if (!tag || tag.name) {
376
- return;
377
- }
378
- }
379
- if (!source.comment) {
380
- return;
381
- }
382
- target.comment = source.comment.clone();
383
- if (target instanceof index_1.DeclarationReflection &&
384
- source instanceof index_1.DeclarationReflection) {
385
- for (const [tt, ts] of (0, array_1.zip)(target.typeParameters || [], source.typeParameters || [])) {
386
- copyComment(tt, ts);
387
- }
388
- }
389
- if (target instanceof index_1.SignatureReflection &&
390
- source instanceof index_1.SignatureReflection) {
391
- for (const [tt, ts] of (0, array_1.zip)(target.typeParameters || [], source.typeParameters || [])) {
392
- copyComment(tt, ts);
393
- }
394
- for (const [pt, ps] of (0, array_1.zip)(target.parameters || [], source.parameters || [])) {
395
- copyComment(pt, ps);
413
+ return false;
396
414
  }
397
415
  }
416
+ return true;
398
417
  }
399
418
  function findMatchingMember(toMatch, container) {
400
419
  return container.children?.find((child) => child.name == toMatch.name &&
@@ -93,6 +93,12 @@ export declare class CommentTag {
93
93
  * Create a new CommentTag instance.
94
94
  */
95
95
  constructor(tag: `@${string}`, text: CommentDisplayPart[]);
96
+ /**
97
+ * Checks if this block tag is roughly equal to the other tag.
98
+ * This isn't exactly equal, but just "roughly equal" by the tag
99
+ * text.
100
+ */
101
+ similarTo(other: CommentTag): boolean;
96
102
  clone(): CommentTag;
97
103
  toObject(serializer: Serializer): JSONOutput.CommentTag;
98
104
  fromObject(de: Deserializer, obj: JSONOutput.CommentTag): void;
@@ -191,6 +197,12 @@ export declare class Comment {
191
197
  * Creates a new Comment instance.
192
198
  */
193
199
  constructor(summary?: CommentDisplayPart[], blockTags?: CommentTag[], modifierTags?: Set<`@${string}`>);
200
+ /**
201
+ * Checks if this comment is roughly equal to the other comment.
202
+ * This isn't exactly equal, but just "roughly equal" by the comment
203
+ * text.
204
+ */
205
+ similarTo(other: Comment): boolean;
194
206
  /**
195
207
  * Create a deep clone of this comment.
196
208
  */
@@ -58,6 +58,17 @@ class CommentTag {
58
58
  this.tag = tag;
59
59
  this.content = text;
60
60
  }
61
+ /**
62
+ * Checks if this block tag is roughly equal to the other tag.
63
+ * This isn't exactly equal, but just "roughly equal" by the tag
64
+ * text.
65
+ */
66
+ similarTo(other) {
67
+ return (this.tag === other.tag &&
68
+ this.name === other.tag &&
69
+ Comment.combineDisplayParts(this.content) ===
70
+ Comment.combineDisplayParts(other.content));
71
+ }
61
72
  clone() {
62
73
  const tag = new CommentTag(this.tag, Comment.cloneDisplayParts(this.content));
63
74
  if (this.name) {
@@ -317,6 +328,28 @@ let Comment = (() => {
317
328
  this.modifierTags = modifierTags;
318
329
  extractLabelTag(this);
319
330
  }
331
+ /**
332
+ * Checks if this comment is roughly equal to the other comment.
333
+ * This isn't exactly equal, but just "roughly equal" by the comment
334
+ * text.
335
+ */
336
+ similarTo(other) {
337
+ if (_a.combineDisplayParts(this.summary) !==
338
+ _a.combineDisplayParts(other.summary)) {
339
+ return false;
340
+ }
341
+ // Ignore modifier tags, as they could cause false negatives
342
+ // if a cascaded modifier tag is present in one comment but not the other.
343
+ if (this.blockTags.length !== other.blockTags.length) {
344
+ return false;
345
+ }
346
+ for (let i = 0; i < this.blockTags.length; ++i) {
347
+ if (!this.blockTags[i].similarTo(other.blockTags[i])) {
348
+ return false;
349
+ }
350
+ }
351
+ return true;
352
+ }
320
353
  /**
321
354
  * Create a deep clone of this comment.
322
355
  */
@@ -1,7 +1,7 @@
1
1
  export declare const emptyArray: readonly [];
2
2
  /**
3
3
  * Inserts an item into an array sorted by priority. If two items have the same priority,
4
- * the item will be inserted later will be placed earlier in the array.
4
+ * the item will be inserted later will be placed later in the array.
5
5
  * @param arr modified by inserting item.
6
6
  * @param item
7
7
  */
@@ -15,12 +15,12 @@ exports.filter = filter;
15
15
  exports.emptyArray = [];
16
16
  /**
17
17
  * Inserts an item into an array sorted by priority. If two items have the same priority,
18
- * the item will be inserted later will be placed earlier in the array.
18
+ * the item will be inserted later will be placed later in the array.
19
19
  * @param arr modified by inserting item.
20
20
  * @param item
21
21
  */
22
22
  function insertPrioritySorted(arr, item) {
23
- const index = binaryFindPartition(arr, (v) => v.priority <= item.priority);
23
+ const index = binaryFindPartition(arr, (v) => v.priority < item.priority);
24
24
  arr.splice(index === -1 ? arr.length : index, 0, item);
25
25
  return arr;
26
26
  }
@@ -8,7 +8,7 @@ export type { IfInternal, NeverIfInternal, Chars } from "./general";
8
8
  export { assertNever } from "./general";
9
9
  export { ConsoleLogger, Logger, LogLevel } from "./loggers";
10
10
  export { DefaultMap } from "./map";
11
- export { ArgumentsReader, Option, CommentStyle, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, } from "./options";
11
+ export { ArgumentsReader, Option, CommentStyle, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, OptionDefaults, } from "./options";
12
12
  export type { ArrayDeclarationOption, BooleanDeclarationOption, DeclarationOption, DeclarationOptionBase, DeclarationOptionToOptionType, KeyToDeclaration, MapDeclarationOption, MixedDeclarationOption, NumberDeclarationOption, FlagsDeclarationOption, ObjectDeclarationOption, OptionsReader, StringDeclarationOption, TypeDocOptionMap, TypeDocOptions, ValidationOptions, TypeDocOptionValues, ParameterTypeToOptionTypeMap, ManuallyValidatedOption, JsDocCompatibility, } from "./options";
13
13
  export { loadPlugins } from "./plugins";
14
14
  export { getSortFunction } from "./sort";
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.MinimalSourceFile = exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.getSortFunction = exports.loadPlugins = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.assertNever = exports.normalizePath = exports.discoverPackageJson = exports.discoverInParentDir = exports.writeFileSync = exports.writeFile = exports.readFile = exports.getCommonDirectory = exports.copySync = exports.copy = exports.isFile = exports.EventDispatcher = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0;
29
+ exports.MinimalSourceFile = exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.getSortFunction = exports.loadPlugins = exports.OptionDefaults = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.CommentStyle = exports.Option = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.assertNever = exports.normalizePath = exports.discoverPackageJson = exports.discoverInParentDir = exports.writeFileSync = exports.writeFile = exports.readFile = exports.getCommonDirectory = exports.copySync = exports.copy = exports.isFile = exports.EventDispatcher = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0;
30
30
  var array_1 = require("./array");
31
31
  Object.defineProperty(exports, "filterMap", { enumerable: true, get: function () { return array_1.filterMap; } });
32
32
  Object.defineProperty(exports, "insertPrioritySorted", { enumerable: true, get: function () { return array_1.insertPrioritySorted; } });
@@ -71,6 +71,7 @@ Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: functio
71
71
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return options_1.ParameterType; } });
72
72
  Object.defineProperty(exports, "TSConfigReader", { enumerable: true, get: function () { return options_1.TSConfigReader; } });
73
73
  Object.defineProperty(exports, "TypeDocReader", { enumerable: true, get: function () { return options_1.TypeDocReader; } });
74
+ Object.defineProperty(exports, "OptionDefaults", { enumerable: true, get: function () { return options_1.OptionDefaults; } });
74
75
  var plugins_1 = require("./plugins");
75
76
  Object.defineProperty(exports, "loadPlugins", { enumerable: true, get: function () { return plugins_1.loadPlugins; } });
76
77
  var sort_1 = require("./sort");
@@ -0,0 +1,23 @@
1
+ import type { BundledLanguage } from "shiki" with { "resolution-mode": "import" };
2
+ import type { EnumKeys } from "../enum";
3
+ import type { ReflectionKind } from "../../models/index";
4
+ /**
5
+ * Default values for TypeDoc options. This object should not be modified.
6
+ *
7
+ * @privateRemarks
8
+ * These are declared here, rather than within the option declaration, so that
9
+ * they can be exposed as a part of the public API. The unfortunate type declaration
10
+ * is to control the type which appears in the generated documentation.
11
+ */
12
+ export declare const OptionDefaults: {
13
+ excludeNotDocumentedKinds: readonly EnumKeys<typeof ReflectionKind>[];
14
+ excludeTags: readonly `@${string}`[];
15
+ blockTags: readonly `@${string}`[];
16
+ inlineTags: readonly `@${string}`[];
17
+ modifierTags: readonly `@${string}`[];
18
+ cascadedModifierTags: readonly `@${string}`[];
19
+ highlightLanguages: readonly BundledLanguage[];
20
+ sort: readonly string[];
21
+ kindSortOrder: readonly EnumKeys<typeof ReflectionKind>[];
22
+ requiredToBeDocumented: readonly EnumKeys<typeof ReflectionKind>[];
23
+ };
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.OptionDefaults = void 0;
27
+ const TagDefaults = __importStar(require("./tsdoc-defaults"));
28
+ /**
29
+ * Default values for TypeDoc options. This object should not be modified.
30
+ *
31
+ * @privateRemarks
32
+ * These are declared here, rather than within the option declaration, so that
33
+ * they can be exposed as a part of the public API. The unfortunate type declaration
34
+ * is to control the type which appears in the generated documentation.
35
+ */
36
+ exports.OptionDefaults = {
37
+ excludeNotDocumentedKinds: [
38
+ "Module",
39
+ "Namespace",
40
+ "Enum",
41
+ // Not including enum member here by default
42
+ "Variable",
43
+ "Function",
44
+ "Class",
45
+ "Interface",
46
+ "Constructor",
47
+ "Property",
48
+ "Method",
49
+ "CallSignature",
50
+ "IndexSignature",
51
+ "ConstructorSignature",
52
+ "Accessor",
53
+ "GetSignature",
54
+ "SetSignature",
55
+ "TypeAlias",
56
+ "Reference",
57
+ ],
58
+ excludeTags: [
59
+ "@override",
60
+ "@virtual",
61
+ "@privateRemarks",
62
+ "@satisfies",
63
+ "@overload",
64
+ ],
65
+ blockTags: TagDefaults.blockTags,
66
+ inlineTags: TagDefaults.inlineTags,
67
+ modifierTags: TagDefaults.modifierTags,
68
+ cascadedModifierTags: ["@alpha", "@beta", "@experimental"],
69
+ highlightLanguages: [
70
+ "bash",
71
+ "console",
72
+ "css",
73
+ "html",
74
+ "javascript",
75
+ "json",
76
+ "jsonc",
77
+ "json5",
78
+ "tsx",
79
+ "typescript",
80
+ ],
81
+ sort: ["kind", "instance-first", "alphabetical"],
82
+ kindSortOrder: [
83
+ "Document",
84
+ "Reference",
85
+ "Project",
86
+ "Module",
87
+ "Namespace",
88
+ "Enum",
89
+ "EnumMember",
90
+ "Class",
91
+ "Interface",
92
+ "TypeAlias",
93
+ "Constructor",
94
+ "Property",
95
+ "Variable",
96
+ "Function",
97
+ "Accessor",
98
+ "Method",
99
+ "Parameter",
100
+ "TypeParameter",
101
+ "TypeLiteral",
102
+ "CallSignature",
103
+ "ConstructorSignature",
104
+ "IndexSignature",
105
+ "GetSignature",
106
+ "SetSignature",
107
+ ],
108
+ requiredToBeDocumented: [
109
+ "Enum",
110
+ "EnumMember",
111
+ "Variable",
112
+ "Function",
113
+ "Class",
114
+ "Interface",
115
+ "Property",
116
+ "Method",
117
+ "Accessor",
118
+ "TypeAlias",
119
+ ],
120
+ };
@@ -3,3 +3,4 @@ export type { OptionsReader } from "./options";
3
3
  export { ArgumentsReader, PackageJsonReader, TypeDocReader, TSConfigReader, } from "./readers";
4
4
  export { CommentStyle, EmitStrategy, ParameterType, ParameterHint, } from "./declaration";
5
5
  export type { TypeDocOptions, TypeDocOptionMap, ValidationOptions, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, TypeDocOptionValues, ParameterTypeToOptionTypeMap, ManuallyValidatedOption, JsDocCompatibility, } from "./declaration";
6
+ export { OptionDefaults } from "./defaults";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.CommentStyle = exports.TSConfigReader = exports.TypeDocReader = exports.PackageJsonReader = exports.ArgumentsReader = exports.Option = exports.Options = void 0;
3
+ exports.OptionDefaults = exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.CommentStyle = exports.TSConfigReader = exports.TypeDocReader = exports.PackageJsonReader = exports.ArgumentsReader = exports.Option = exports.Options = void 0;
4
4
  var options_1 = require("./options");
5
5
  Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return options_1.Options; } });
6
6
  Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return options_1.Option; } });
@@ -14,3 +14,5 @@ Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function
14
14
  Object.defineProperty(exports, "EmitStrategy", { enumerable: true, get: function () { return declaration_1.EmitStrategy; } });
15
15
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return declaration_1.ParameterType; } });
16
16
  Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: function () { return declaration_1.ParameterHint; } });
17
+ var defaults_1 = require("./defaults");
18
+ Object.defineProperty(exports, "OptionDefaults", { enumerable: true, get: function () { return defaults_1.OptionDefaults; } });
@@ -30,10 +30,10 @@ const sort_1 = require("../../sort");
30
30
  const entry_point_1 = require("../../entry-point");
31
31
  const kind_1 = require("../../../models/reflections/kind");
32
32
  const Validation = __importStar(require("../../validation"));
33
- const tsdoc_defaults_1 = require("../tsdoc-defaults");
34
33
  const enum_1 = require("../../enum");
35
34
  const highlighter_1 = require("../../highlighter");
36
35
  const set_1 = require("../../set");
36
+ const defaults_1 = require("../defaults");
37
37
  // For convenience, added in the same order as they are documented on the website.
38
38
  function addTypeDocOptions(options) {
39
39
  ///////////////////////////
@@ -172,27 +172,7 @@ function addTypeDocOptions(options) {
172
172
  throw new Error(i18n.exclude_not_documented_specified_0_valid_values_are_1(Array.from(invalid).join(", "), Array.from(valid).join(", ")));
173
173
  }
174
174
  },
175
- defaultValue: [
176
- kind_1.ReflectionKind[kind_1.ReflectionKind.Module],
177
- kind_1.ReflectionKind[kind_1.ReflectionKind.Namespace],
178
- kind_1.ReflectionKind[kind_1.ReflectionKind.Enum],
179
- // Not including enum member here by default
180
- kind_1.ReflectionKind[kind_1.ReflectionKind.Variable],
181
- kind_1.ReflectionKind[kind_1.ReflectionKind.Function],
182
- kind_1.ReflectionKind[kind_1.ReflectionKind.Class],
183
- kind_1.ReflectionKind[kind_1.ReflectionKind.Interface],
184
- kind_1.ReflectionKind[kind_1.ReflectionKind.Constructor],
185
- kind_1.ReflectionKind[kind_1.ReflectionKind.Property],
186
- kind_1.ReflectionKind[kind_1.ReflectionKind.Method],
187
- kind_1.ReflectionKind[kind_1.ReflectionKind.CallSignature],
188
- kind_1.ReflectionKind[kind_1.ReflectionKind.IndexSignature],
189
- kind_1.ReflectionKind[kind_1.ReflectionKind.ConstructorSignature],
190
- kind_1.ReflectionKind[kind_1.ReflectionKind.Accessor],
191
- kind_1.ReflectionKind[kind_1.ReflectionKind.GetSignature],
192
- kind_1.ReflectionKind[kind_1.ReflectionKind.SetSignature],
193
- kind_1.ReflectionKind[kind_1.ReflectionKind.TypeAlias],
194
- kind_1.ReflectionKind[kind_1.ReflectionKind.Reference],
195
- ],
175
+ defaultValue: defaults_1.OptionDefaults.excludeNotDocumentedKinds,
196
176
  });
197
177
  options.addDeclaration({
198
178
  name: "excludeInternal",
@@ -305,18 +285,7 @@ function addTypeDocOptions(options) {
305
285
  name: "highlightLanguages",
306
286
  help: (i18n) => i18n.help_highlightLanguages(),
307
287
  type: declaration_1.ParameterType.Array,
308
- defaultValue: [
309
- "bash",
310
- "console",
311
- "css",
312
- "html",
313
- "javascript",
314
- "json",
315
- "jsonc",
316
- "json5",
317
- "tsx",
318
- "typescript",
319
- ],
288
+ defaultValue: defaults_1.OptionDefaults.highlightLanguages,
320
289
  validate(value, i18n) {
321
290
  const invalid = (0, set_1.setDifference)(value, (0, highlighter_1.getSupportedLanguagesWithoutAliases)());
322
291
  if (invalid.size) {
@@ -403,13 +372,7 @@ function addTypeDocOptions(options) {
403
372
  name: "excludeTags",
404
373
  help: (i18n) => i18n.help_excludeTags(),
405
374
  type: declaration_1.ParameterType.Array,
406
- defaultValue: [
407
- "@override",
408
- "@virtual",
409
- "@privateRemarks",
410
- "@satisfies",
411
- "@overload",
412
- ],
375
+ defaultValue: defaults_1.OptionDefaults.excludeTags,
413
376
  validate(value, i18n) {
414
377
  if (!Validation.validate([Array, Validation.isTagString], value)) {
415
378
  throw new Error(i18n.option_0_values_must_be_array_of_tags("excludeTags"));
@@ -638,7 +601,7 @@ function addTypeDocOptions(options) {
638
601
  name: "blockTags",
639
602
  help: (i18n) => i18n.help_blockTags(),
640
603
  type: declaration_1.ParameterType.Array,
641
- defaultValue: tsdoc_defaults_1.blockTags,
604
+ defaultValue: defaults_1.OptionDefaults.blockTags,
642
605
  validate(value, i18n) {
643
606
  if (!Validation.validate([Array, Validation.isTagString], value)) {
644
607
  throw new Error(i18n.option_0_values_must_be_array_of_tags("blockTags"));
@@ -649,7 +612,7 @@ function addTypeDocOptions(options) {
649
612
  name: "inlineTags",
650
613
  help: (i18n) => i18n.help_inlineTags(),
651
614
  type: declaration_1.ParameterType.Array,
652
- defaultValue: tsdoc_defaults_1.inlineTags,
615
+ defaultValue: defaults_1.OptionDefaults.inlineTags,
653
616
  validate(value, i18n) {
654
617
  if (!Validation.validate([Array, Validation.isTagString], value)) {
655
618
  throw new Error(i18n.option_0_values_must_be_array_of_tags("inlineTags"));
@@ -660,7 +623,7 @@ function addTypeDocOptions(options) {
660
623
  name: "modifierTags",
661
624
  help: (i18n) => i18n.help_modifierTags(),
662
625
  type: declaration_1.ParameterType.Array,
663
- defaultValue: tsdoc_defaults_1.modifierTags,
626
+ defaultValue: defaults_1.OptionDefaults.modifierTags,
664
627
  validate(value, i18n) {
665
628
  if (!Validation.validate([Array, Validation.isTagString], value)) {
666
629
  throw new Error(i18n.option_0_values_must_be_array_of_tags("modifierTags"));
@@ -671,7 +634,7 @@ function addTypeDocOptions(options) {
671
634
  name: "cascadedModifierTags",
672
635
  help: (i18n) => i18n.help_modifierTags(),
673
636
  type: declaration_1.ParameterType.Array,
674
- defaultValue: ["@alpha", "@beta", "@experimental"],
637
+ defaultValue: defaults_1.OptionDefaults.cascadedModifierTags,
675
638
  validate(value, i18n) {
676
639
  if (!Validation.validate([Array, Validation.isTagString], value)) {
677
640
  throw new Error(i18n.option_0_values_must_be_array_of_tags("cascadedModifierTags"));
@@ -707,7 +670,7 @@ function addTypeDocOptions(options) {
707
670
  name: "sort",
708
671
  help: (i18n) => i18n.help_sort(),
709
672
  type: declaration_1.ParameterType.Array,
710
- defaultValue: ["kind", "instance-first", "alphabetical"],
673
+ defaultValue: defaults_1.OptionDefaults.sort,
711
674
  validate(value, i18n) {
712
675
  const invalid = new Set(value);
713
676
  for (const v of sort_1.SORT_STRATEGIES) {
@@ -730,13 +693,9 @@ function addTypeDocOptions(options) {
730
693
  type: declaration_1.ParameterType.Array,
731
694
  defaultValue: [],
732
695
  validate(value, i18n) {
733
- const invalid = new Set(value);
734
- const valid = (0, enum_1.getEnumKeys)(kind_1.ReflectionKind);
735
- for (const v of valid) {
736
- invalid.delete(v);
737
- }
696
+ const invalid = (0, set_1.setDifference)(value, (0, enum_1.getEnumKeys)(kind_1.ReflectionKind));
738
697
  if (invalid.size !== 0) {
739
- throw new Error(i18n.option_0_specified_1_but_only_2_is_valid(`kindSortOrder`, Array.from(invalid).join(", "), valid.join(", ")));
698
+ throw new Error(i18n.option_0_specified_1_but_only_2_is_valid(`kindSortOrder`, Array.from(invalid).join(", "), (0, enum_1.getEnumKeys)(kind_1.ReflectionKind).join(", ")));
740
699
  }
741
700
  },
742
701
  });
@@ -814,18 +773,7 @@ function addTypeDocOptions(options) {
814
773
  }
815
774
  }
816
775
  },
817
- defaultValue: [
818
- kind_1.ReflectionKind[kind_1.ReflectionKind.Enum],
819
- kind_1.ReflectionKind[kind_1.ReflectionKind.EnumMember],
820
- kind_1.ReflectionKind[kind_1.ReflectionKind.Variable],
821
- kind_1.ReflectionKind[kind_1.ReflectionKind.Function],
822
- kind_1.ReflectionKind[kind_1.ReflectionKind.Class],
823
- kind_1.ReflectionKind[kind_1.ReflectionKind.Interface],
824
- kind_1.ReflectionKind[kind_1.ReflectionKind.Property],
825
- kind_1.ReflectionKind[kind_1.ReflectionKind.Method],
826
- kind_1.ReflectionKind[kind_1.ReflectionKind.Accessor],
827
- kind_1.ReflectionKind[kind_1.ReflectionKind.TypeAlias],
828
- ],
776
+ defaultValue: defaults_1.OptionDefaults.requiredToBeDocumented,
829
777
  });
830
778
  options.addDeclaration({
831
779
  name: "validation",
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SORT_STRATEGIES = void 0;
8
8
  exports.getSortFunction = getSortFunction;
9
9
  const kind_1 = require("../models/reflections/kind");
10
+ const defaults_1 = require("./options/defaults");
10
11
  exports.SORT_STRATEGIES = [
11
12
  "source-order",
12
13
  "alphabetical",
@@ -23,32 +24,6 @@ exports.SORT_STRATEGIES = [
23
24
  "documents-first",
24
25
  "documents-last",
25
26
  ];
26
- const defaultKindSortOrder = [
27
- kind_1.ReflectionKind.Document,
28
- kind_1.ReflectionKind.Reference,
29
- kind_1.ReflectionKind.Project,
30
- kind_1.ReflectionKind.Module,
31
- kind_1.ReflectionKind.Namespace,
32
- kind_1.ReflectionKind.Enum,
33
- kind_1.ReflectionKind.EnumMember,
34
- kind_1.ReflectionKind.Class,
35
- kind_1.ReflectionKind.Interface,
36
- kind_1.ReflectionKind.TypeAlias,
37
- kind_1.ReflectionKind.Constructor,
38
- kind_1.ReflectionKind.Property,
39
- kind_1.ReflectionKind.Variable,
40
- kind_1.ReflectionKind.Function,
41
- kind_1.ReflectionKind.Accessor,
42
- kind_1.ReflectionKind.Method,
43
- kind_1.ReflectionKind.Parameter,
44
- kind_1.ReflectionKind.TypeParameter,
45
- kind_1.ReflectionKind.TypeLiteral,
46
- kind_1.ReflectionKind.CallSignature,
47
- kind_1.ReflectionKind.ConstructorSignature,
48
- kind_1.ReflectionKind.IndexSignature,
49
- kind_1.ReflectionKind.GetSignature,
50
- kind_1.ReflectionKind.SetSignature,
51
- ];
52
27
  // Return true if a < b
53
28
  const sorts = {
54
29
  "source-order"(a, b) {
@@ -152,9 +127,9 @@ function getSortFunction(opts) {
152
127
  const kindSortOrder = opts
153
128
  .getValue("kindSortOrder")
154
129
  .map((k) => kind_1.ReflectionKind[k]);
155
- for (const kind of defaultKindSortOrder) {
156
- if (!kindSortOrder.includes(kind)) {
157
- kindSortOrder.push(kind);
130
+ for (const kind of defaults_1.OptionDefaults.kindSortOrder) {
131
+ if (!kindSortOrder.includes(kind_1.ReflectionKind[kind])) {
132
+ kindSortOrder.push(kind_1.ReflectionKind[kind]);
158
133
  }
159
134
  }
160
135
  const strategies = opts.getValue("sort");
@@ -71,7 +71,11 @@ function validateDocumentation(project, logger, requiredToBeDocumented) {
71
71
  }
72
72
  }
73
73
  const symbolId = project.getSymbolIdFromReflection(ref);
74
- if (!ref.hasComment() && symbolId) {
74
+ // #2644, signatures may be documented by their parent reflection.
75
+ const hasComment = ref.hasComment() ||
76
+ (ref.kindOf(models_1.ReflectionKind.SomeSignature) &&
77
+ ref.parent?.hasComment());
78
+ if (!hasComment && symbolId) {
75
79
  if (symbolId.fileName.includes("node_modules")) {
76
80
  continue;
77
81
  }
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.26.4",
4
+ "version": "0.26.5",
5
5
  "homepage": "https://typedoc.org",
6
6
  "exports": {
7
7
  ".": "./dist/index.js",