typedoc 0.28.16 → 0.28.17

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.
@@ -13,6 +13,9 @@ export function resolveDeclarationReference(reflection, ref) {
13
13
  if (ref.moduleSource) {
14
14
  high = reflection.project.children?.filter((c) => c.kindOf(ReflectionKind.SomeModule) &&
15
15
  c.name === ref.moduleSource) || [];
16
+ if (!high.length && reflection.project.packageName === ref.moduleSource) {
17
+ high.push(reflection.project);
18
+ }
16
19
  }
17
20
  else if (ref.resolutionStart === "global") {
18
21
  high.push(reflection.project);
@@ -23,6 +23,8 @@ const variablePropertyKinds = [
23
23
  // Comments from @typedef and @callback tags are handled specially by
24
24
  // the JSDoc converter because we only want part of the comment when
25
25
  // getting them.
26
+ // This also does NOT include kinds which should be checked after the
27
+ // first kind/kinds have been checked for a comment.
26
28
  const wantedKinds = {
27
29
  [ReflectionKind.Project]: [
28
30
  ts.SyntaxKind.SourceFile,
@@ -38,24 +40,12 @@ const wantedKinds = {
38
40
  ts.SyntaxKind.BindingElement,
39
41
  ts.SyntaxKind.ExportSpecifier,
40
42
  ts.SyntaxKind.NamespaceExport,
41
- // @namespace support
42
- ts.SyntaxKind.VariableDeclaration,
43
- ts.SyntaxKind.BindingElement,
44
- ts.SyntaxKind.ExportAssignment,
45
- ts.SyntaxKind.PropertyAccessExpression,
46
- ts.SyntaxKind.PropertyDeclaration,
47
- ts.SyntaxKind.PropertyAssignment,
48
- ts.SyntaxKind.ShorthandPropertyAssignment,
49
43
  ],
50
44
  [ReflectionKind.Enum]: [
51
45
  ts.SyntaxKind.EnumDeclaration,
52
- ts.SyntaxKind.VariableDeclaration,
53
46
  ],
54
47
  [ReflectionKind.EnumMember]: [
55
48
  ts.SyntaxKind.EnumMember,
56
- // These here so that @enum gets comments
57
- ts.SyntaxKind.PropertyAssignment,
58
- ts.SyntaxKind.PropertySignature,
59
49
  ],
60
50
  [ReflectionKind.Variable]: variablePropertyKinds,
61
51
  [ReflectionKind.Function]: [
@@ -71,15 +61,9 @@ const wantedKinds = {
71
61
  [ReflectionKind.Class]: [
72
62
  ts.SyntaxKind.ClassDeclaration,
73
63
  ts.SyntaxKind.BindingElement,
74
- // If marked with @class
75
- ts.SyntaxKind.VariableDeclaration,
76
- ts.SyntaxKind.ExportAssignment,
77
- ts.SyntaxKind.FunctionDeclaration,
78
64
  ],
79
65
  [ReflectionKind.Interface]: [
80
66
  ts.SyntaxKind.InterfaceDeclaration,
81
- ts.SyntaxKind.TypeAliasDeclaration,
82
- ts.SyntaxKind.ClassDeclaration, // type only exports
83
67
  ],
84
68
  [ReflectionKind.Constructor]: [ts.SyntaxKind.Constructor],
85
69
  [ReflectionKind.Property]: variablePropertyKinds,
@@ -106,9 +90,6 @@ const wantedKinds = {
106
90
  [ReflectionKind.SetSignature]: [ts.SyntaxKind.SetAccessor],
107
91
  [ReflectionKind.TypeAlias]: [
108
92
  ts.SyntaxKind.TypeAliasDeclaration,
109
- ts.SyntaxKind.FunctionDeclaration, // type only exports
110
- // Intentionally not included to avoid comments being copied for variable/alias combos
111
- // ts.SyntaxKind.VariableDeclaration,
112
93
  ],
113
94
  [ReflectionKind.Reference]: [
114
95
  ts.SyntaxKind.NamespaceExport,
@@ -117,6 +98,72 @@ const wantedKinds = {
117
98
  // Non-TS kind, will never have comments.
118
99
  [ReflectionKind.Document]: [],
119
100
  };
101
+ // These kinds are checked after wantedKinds if wantedKinds doesn't result in
102
+ // discovering a comment. This is a rather unfortunate tradeoff between discovering
103
+ // comments for values in unusual circumstances (#2970) and avoiding duplicate
104
+ // comments being discovered for declaration merging nastiness (#3064)
105
+ const backupWantedKinds = {
106
+ [ReflectionKind.Project]: [],
107
+ [ReflectionKind.Module]: [],
108
+ [ReflectionKind.Namespace]: [
109
+ // @namespace support
110
+ ts.SyntaxKind.VariableDeclaration,
111
+ ts.SyntaxKind.BindingElement,
112
+ ts.SyntaxKind.ExportAssignment,
113
+ ts.SyntaxKind.PropertyAccessExpression,
114
+ ts.SyntaxKind.PropertyDeclaration,
115
+ ts.SyntaxKind.PropertyAssignment,
116
+ ts.SyntaxKind.ShorthandPropertyAssignment,
117
+ ],
118
+ [ReflectionKind.Enum]: [
119
+ ts.SyntaxKind.VariableDeclaration,
120
+ ],
121
+ [ReflectionKind.EnumMember]: [
122
+ // These here so that @enum gets comments
123
+ ts.SyntaxKind.PropertyAssignment,
124
+ ts.SyntaxKind.PropertySignature,
125
+ ],
126
+ [ReflectionKind.Variable]: [],
127
+ [ReflectionKind.Function]: [
128
+ ts.SyntaxKind.FunctionDeclaration,
129
+ ts.SyntaxKind.BindingElement,
130
+ ts.SyntaxKind.VariableDeclaration,
131
+ ts.SyntaxKind.ExportAssignment,
132
+ ts.SyntaxKind.PropertyAccessExpression,
133
+ ts.SyntaxKind.PropertyDeclaration,
134
+ ts.SyntaxKind.PropertyAssignment,
135
+ ts.SyntaxKind.ShorthandPropertyAssignment,
136
+ ],
137
+ [ReflectionKind.Class]: [
138
+ // If marked with @class
139
+ ts.SyntaxKind.VariableDeclaration,
140
+ ts.SyntaxKind.ExportAssignment,
141
+ ts.SyntaxKind.FunctionDeclaration,
142
+ ],
143
+ [ReflectionKind.Interface]: [
144
+ ts.SyntaxKind.TypeAliasDeclaration,
145
+ ts.SyntaxKind.ClassDeclaration, // type only exports
146
+ ],
147
+ [ReflectionKind.Constructor]: [],
148
+ [ReflectionKind.Property]: [],
149
+ [ReflectionKind.Method]: [],
150
+ [ReflectionKind.CallSignature]: [],
151
+ [ReflectionKind.IndexSignature]: [],
152
+ [ReflectionKind.ConstructorSignature]: [],
153
+ [ReflectionKind.Parameter]: [],
154
+ [ReflectionKind.TypeLiteral]: [],
155
+ [ReflectionKind.TypeParameter]: [],
156
+ [ReflectionKind.Accessor]: [],
157
+ [ReflectionKind.GetSignature]: [],
158
+ [ReflectionKind.SetSignature]: [],
159
+ [ReflectionKind.TypeAlias]: [
160
+ ts.SyntaxKind.FunctionDeclaration, // type only exports
161
+ ts.SyntaxKind.VariableDeclaration, // type only exports
162
+ ],
163
+ [ReflectionKind.Reference]: [],
164
+ // Non-TS kind, will never have comments.
165
+ [ReflectionKind.Document]: [],
166
+ };
120
167
  export function discoverFileComments(node, commentStyle) {
121
168
  const text = node.text;
122
169
  const comments = collectCommentRanges(ts.getLeadingCommentRanges(text, node.pos));
@@ -165,10 +212,20 @@ function checkCommentDeclarations(commentNodes, reverse, commentStyle) {
165
212
  return discovered;
166
213
  }
167
214
  export function discoverComment(symbol, kind, logger, commentStyle, checker, declarationWarnings) {
215
+ const discovered = discoverCommentWorker(symbol, kind, logger, commentStyle, checker, declarationWarnings, wantedKinds[kind]);
216
+ if (discovered) {
217
+ return discovered;
218
+ }
219
+ return discoverCommentWorker(symbol, kind, logger, commentStyle, checker, declarationWarnings, backupWantedKinds[kind]);
220
+ }
221
+ function discoverCommentWorker(symbol, kind, logger, commentStyle, checker, declarationWarnings, wanted) {
222
+ if (wanted.length === 0) {
223
+ return;
224
+ }
168
225
  // For a module comment, we want the first one defined in the file,
169
226
  // not the last one, since that will apply to the import or declaration.
170
227
  const reverse = !symbol.declarations?.some(ts.isSourceFile);
171
- const wantedDeclarations = filter(symbol.declarations, (decl) => wantedKinds[kind].includes(decl.kind));
228
+ const wantedDeclarations = filter(symbol.declarations, (decl) => wanted.includes(decl.kind));
172
229
  const commentNodes = wantedDeclarations.flatMap((decl) => declarationToCommentNodes(decl, checker));
173
230
  // Special behavior here!
174
231
  // Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
@@ -66,6 +66,7 @@ export declare class CommentPlugin extends ConverterComponent {
66
66
  accessor excludeNotDocumented: boolean;
67
67
  accessor excludeCategories: string[];
68
68
  accessor defaultCategory: string;
69
+ accessor suppressCommentWarningsInDeclarationFiles: boolean;
69
70
  private _excludeKinds;
70
71
  private get excludeNotDocumentedKinds();
71
72
  constructor(owner: Converter);
@@ -123,4 +124,5 @@ export declare class CommentPlugin extends ConverterComponent {
123
124
  private isHidden;
124
125
  private excludedByCategory;
125
126
  private validateParamTags;
127
+ private suppressCommentWarnings;
126
128
  }
@@ -154,6 +154,9 @@ let CommentPlugin = (() => {
154
154
  let _defaultCategory_decorators;
155
155
  let _defaultCategory_initializers = [];
156
156
  let _defaultCategory_extraInitializers = [];
157
+ let _suppressCommentWarningsInDeclarationFiles_decorators;
158
+ let _suppressCommentWarningsInDeclarationFiles_initializers = [];
159
+ let _suppressCommentWarningsInDeclarationFiles_extraInitializers = [];
157
160
  return class CommentPlugin extends _classSuper {
158
161
  static {
159
162
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
@@ -166,6 +169,7 @@ let CommentPlugin = (() => {
166
169
  _excludeNotDocumented_decorators = [Option("excludeNotDocumented")];
167
170
  _excludeCategories_decorators = [Option("excludeCategories")];
168
171
  _defaultCategory_decorators = [Option("defaultCategory")];
172
+ _suppressCommentWarningsInDeclarationFiles_decorators = [Option("suppressCommentWarningsInDeclarationFiles")];
169
173
  __esDecorate(this, null, _excludeTags_decorators, { kind: "accessor", name: "excludeTags", static: false, private: false, access: { has: obj => "excludeTags" in obj, get: obj => obj.excludeTags, set: (obj, value) => { obj.excludeTags = value; } }, metadata: _metadata }, _excludeTags_initializers, _excludeTags_extraInitializers);
170
174
  __esDecorate(this, null, _cascadedModifierTags_decorators, { kind: "accessor", name: "cascadedModifierTags", static: false, private: false, access: { has: obj => "cascadedModifierTags" in obj, get: obj => obj.cascadedModifierTags, set: (obj, value) => { obj.cascadedModifierTags = value; } }, metadata: _metadata }, _cascadedModifierTags_initializers, _cascadedModifierTags_extraInitializers);
171
175
  __esDecorate(this, null, _excludeInternal_decorators, { kind: "accessor", name: "excludeInternal", static: false, private: false, access: { has: obj => "excludeInternal" in obj, get: obj => obj.excludeInternal, set: (obj, value) => { obj.excludeInternal = value; } }, metadata: _metadata }, _excludeInternal_initializers, _excludeInternal_extraInitializers);
@@ -175,6 +179,7 @@ let CommentPlugin = (() => {
175
179
  __esDecorate(this, null, _excludeNotDocumented_decorators, { kind: "accessor", name: "excludeNotDocumented", static: false, private: false, access: { has: obj => "excludeNotDocumented" in obj, get: obj => obj.excludeNotDocumented, set: (obj, value) => { obj.excludeNotDocumented = value; } }, metadata: _metadata }, _excludeNotDocumented_initializers, _excludeNotDocumented_extraInitializers);
176
180
  __esDecorate(this, null, _excludeCategories_decorators, { kind: "accessor", name: "excludeCategories", static: false, private: false, access: { has: obj => "excludeCategories" in obj, get: obj => obj.excludeCategories, set: (obj, value) => { obj.excludeCategories = value; } }, metadata: _metadata }, _excludeCategories_initializers, _excludeCategories_extraInitializers);
177
181
  __esDecorate(this, null, _defaultCategory_decorators, { kind: "accessor", name: "defaultCategory", static: false, private: false, access: { has: obj => "defaultCategory" in obj, get: obj => obj.defaultCategory, set: (obj, value) => { obj.defaultCategory = value; } }, metadata: _metadata }, _defaultCategory_initializers, _defaultCategory_extraInitializers);
182
+ __esDecorate(this, null, _suppressCommentWarningsInDeclarationFiles_decorators, { kind: "accessor", name: "suppressCommentWarningsInDeclarationFiles", static: false, private: false, access: { has: obj => "suppressCommentWarningsInDeclarationFiles" in obj, get: obj => obj.suppressCommentWarningsInDeclarationFiles, set: (obj, value) => { obj.suppressCommentWarningsInDeclarationFiles = value; } }, metadata: _metadata }, _suppressCommentWarningsInDeclarationFiles_initializers, _suppressCommentWarningsInDeclarationFiles_extraInitializers);
178
183
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
179
184
  }
180
185
  #excludeTags_accessor_storage = __runInitializers(this, _excludeTags_initializers, void 0);
@@ -204,7 +209,10 @@ let CommentPlugin = (() => {
204
209
  #defaultCategory_accessor_storage = (__runInitializers(this, _excludeCategories_extraInitializers), __runInitializers(this, _defaultCategory_initializers, void 0));
205
210
  get defaultCategory() { return this.#defaultCategory_accessor_storage; }
206
211
  set defaultCategory(value) { this.#defaultCategory_accessor_storage = value; }
207
- _excludeKinds = __runInitializers(this, _defaultCategory_extraInitializers);
212
+ #suppressCommentWarningsInDeclarationFiles_accessor_storage = (__runInitializers(this, _defaultCategory_extraInitializers), __runInitializers(this, _suppressCommentWarningsInDeclarationFiles_initializers, void 0));
213
+ get suppressCommentWarningsInDeclarationFiles() { return this.#suppressCommentWarningsInDeclarationFiles_accessor_storage; }
214
+ set suppressCommentWarningsInDeclarationFiles(value) { this.#suppressCommentWarningsInDeclarationFiles_accessor_storage = value; }
215
+ _excludeKinds = __runInitializers(this, _suppressCommentWarningsInDeclarationFiles_extraInitializers);
208
216
  get excludeNotDocumentedKinds() {
209
217
  this._excludeKinds ??= this.application.options
210
218
  .getValue("excludeNotDocumentedKinds")
@@ -407,12 +415,13 @@ let CommentPlugin = (() => {
407
415
  onResolve(context, reflection) {
408
416
  if (reflection.comment) {
409
417
  if (reflection.comment.label &&
410
- !/[A-Z_][A-Z0-9_]/.test(reflection.comment.label)) {
418
+ !/[A-Z_][A-Z0-9_]/.test(reflection.comment.label) &&
419
+ !this.suppressCommentWarnings(reflection.comment)) {
411
420
  context.logger.warn(i18n.label_0_for_1_cannot_be_referenced(reflection.comment.label, reflection.getFriendlyFullName()));
412
421
  }
413
422
  for (const group of MUTUALLY_EXCLUSIVE_MODIFIERS) {
414
423
  const intersect = setIntersection(group, reflection.comment.modifierTags);
415
- if (intersect.size > 1) {
424
+ if (intersect.size > 1 && !this.suppressCommentWarnings(reflection.comment)) {
416
425
  const [a, b] = intersect;
417
426
  context.logger.warn(i18n.modifier_tag_0_is_mutually_exclusive_with_1_in_comment_for_2(a, b, reflection.getFriendlyFullName()));
418
427
  }
@@ -637,12 +646,16 @@ let CommentPlugin = (() => {
637
646
  const paramTags = comment.blockTags.filter((tag) => tag.tag === "@param");
638
647
  removeIf(paramTags, (tag) => params.some((param) => param.name === tag.name));
639
648
  moveNestedParamTags(/* in-out */ paramTags, params, comment.sourcePath);
640
- if (!comment.inheritedFromParentDeclaration) {
649
+ if (!comment.inheritedFromParentDeclaration && !this.suppressCommentWarnings(comment)) {
641
650
  for (const tag of paramTags) {
642
651
  this.application.logger.warn(i18n.signature_0_has_unused_param_with_name_1(signature.getFriendlyFullName(), tag.name ?? "(missing)"));
643
652
  }
644
653
  }
645
654
  }
655
+ suppressCommentWarnings(comment) {
656
+ return this.suppressCommentWarningsInDeclarationFiles &&
657
+ /\.d\.(ts|mts|cts)$/.test(comment.sourcePath || "");
658
+ }
646
659
  };
647
660
  })();
648
661
  export { CommentPlugin };
@@ -477,7 +477,7 @@ const referenceConverter = {
477
477
  return convertTypeInlined(context, type);
478
478
  }
479
479
  const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
480
- if (type.flags & ts.TypeFlags.Substitution) {
480
+ if ((type.flags & ts.TypeFlags.Substitution) && name === "NoInfer" && ref.package === "typescript") {
481
481
  // NoInfer<T>
482
482
  ref.typeArguments = [
483
483
  convertType(context, type.baseType),
@@ -15,14 +15,20 @@ export class Slugger {
15
15
  // (html disallowed in markdown)
16
16
  // # test <t>
17
17
  // both of the above should slug to test-t
18
- return (value
18
+ const slug = value
19
19
  .trim()
20
20
  // remove unwanted chars
21
21
  .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "")
22
22
  // change whitespace to dash
23
23
  .replace(/\s/g, "-")
24
24
  // combine adjacent dashes
25
- .replace(/--+/, "-"));
25
+ .replace(/--+/, "-");
26
+ // #3065 unfortunately some headers might result in a desired slug which is
27
+ // completely empty. In that case, we still need to return *something* so that
28
+ // we don't end up generating an empty anchor, which is invalid according to the
29
+ // spec. GitHub's slugger rules don't handle this, so I've somewhat arbitrarily
30
+ // chosen "_" here. If GitHub ever fixes that issue, this might need to be adjusted.
31
+ return slug || "_";
26
32
  }
27
33
  constructor(options) {
28
34
  this.options = options;
@@ -41,7 +41,7 @@ export declare const rootPackageOptions: readonly ["plugin", "packageOptions", "
41
41
  * @interface
42
42
  */
43
43
  export type TypeDocOptions = {
44
- [K in keyof TypeDocOptionMap]?: unknown extends TypeDocOptionMap[K] ? unknown : TypeDocOptionMap[K] extends ManuallyValidatedOption<infer ManuallyValidated> ? ManuallyValidated : TypeDocOptionMap[K] extends NormalizedPath[] | NormalizedPathOrModule[] | NormalizedPathOrModuleOrFunction[] | GlobString[] ? string[] : TypeDocOptionMap[K] extends NormalizedPath ? string : TypeDocOptionMap[K] extends string | string[] | number | boolean ? TypeDocOptionMap[K] : TypeDocOptionMap[K] extends Record<string, boolean> ? Partial<TypeDocOptionMap[K]> | boolean : keyof TypeDocOptionMap[K] | TypeDocOptionMap[K][keyof TypeDocOptionMap[K]];
44
+ [K in keyof TypeDocOptionMap]?: unknown extends TypeDocOptionMap[K] ? unknown : TypeDocOptionMap[K] extends ManuallyValidatedOption<infer ManuallyValidated> ? ManuallyValidated : TypeDocOptionMap[K] extends NormalizedPathOrModuleOrFunction[] ? Array<string | ((app: Application) => Promise<void> | void)> : TypeDocOptionMap[K] extends NormalizedPath[] | NormalizedPathOrModule[] | GlobString[] ? string[] : TypeDocOptionMap[K] extends NormalizedPath ? string : TypeDocOptionMap[K] extends string | string[] | number | boolean ? TypeDocOptionMap[K] : TypeDocOptionMap[K] extends Record<string, boolean> ? Partial<TypeDocOptionMap[K]> | boolean : keyof TypeDocOptionMap[K] | TypeDocOptionMap[K][keyof TypeDocOptionMap[K]];
45
45
  };
46
46
  /**
47
47
  * Describes all TypeDoc specific options as returned by {@link Options.getValue}, this is
@@ -38,4 +38,5 @@ export declare namespace NormalizedPathUtils {
38
38
  name: string;
39
39
  ext: string;
40
40
  };
41
+ function isDeclarationFilePath(path: NormalizedPath): boolean;
41
42
  }
@@ -123,4 +123,8 @@ export var NormalizedPathUtils;
123
123
  return { name: name.substring(0, lastDot), ext: name.substring(lastDot) };
124
124
  }
125
125
  NormalizedPathUtils.splitFilename = splitFilename;
126
+ function isDeclarationFilePath(path) {
127
+ return /\.d\.(ts|mts|cts)$/.test(path);
128
+ }
129
+ NormalizedPathUtils.isDeclarationFilePath = isDeclarationFilePath;
126
130
  })(NormalizedPathUtils || (NormalizedPathUtils = {}));
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.16",
4
+ "version": "0.28.17",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {