typedoc 0.26.0 → 0.26.2

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.
Files changed (34) hide show
  1. package/dist/lib/application.js +12 -2
  2. package/dist/lib/converter/comments/discovery.d.ts +4 -7
  3. package/dist/lib/converter/comments/discovery.js +144 -75
  4. package/dist/lib/converter/comments/index.d.ts +7 -4
  5. package/dist/lib/converter/comments/index.js +22 -16
  6. package/dist/lib/converter/comments/parser.js +11 -2
  7. package/dist/lib/converter/comments/textParser.d.ts +12 -1
  8. package/dist/lib/converter/comments/textParser.js +72 -25
  9. package/dist/lib/converter/context.js +5 -5
  10. package/dist/lib/converter/converter.d.ts +0 -2
  11. package/dist/lib/converter/converter.js +5 -12
  12. package/dist/lib/converter/plugins/CommentPlugin.js +6 -3
  13. package/dist/lib/internationalization/locales/ko.cjs +154 -0
  14. package/dist/lib/internationalization/locales/ko.d.cts +153 -0
  15. package/dist/lib/models/FileRegistry.d.ts +9 -4
  16. package/dist/lib/models/FileRegistry.js +6 -1
  17. package/dist/lib/models/comments/comment.d.ts +9 -2
  18. package/dist/lib/models/comments/comment.js +15 -1
  19. package/dist/lib/models/reflections/declaration.js +1 -0
  20. package/dist/lib/models/reflections/project.js +1 -1
  21. package/dist/lib/output/themes/MarkedPlugin.js +1 -1
  22. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -4
  23. package/dist/lib/utils/array.d.ts +3 -0
  24. package/dist/lib/utils/array.js +19 -0
  25. package/dist/lib/utils/highlighter.js +2 -2
  26. package/dist/lib/utils/minimalSourceFile.js +1 -1
  27. package/dist/lib/utils/options/declaration.d.ts +1 -0
  28. package/dist/lib/utils/options/options.js +3 -3
  29. package/dist/lib/utils/options/readers/typedoc.js +1 -1
  30. package/dist/lib/utils/options/sources/typedoc.js +5 -0
  31. package/dist/lib/utils/options/tsdoc-defaults.d.ts +3 -3
  32. package/dist/lib/utils/options/tsdoc-defaults.js +11 -12
  33. package/package.json +5 -5
  34. package/tsdoc.json +9 -1
@@ -496,6 +496,7 @@ let Application = (() => {
496
496
  this.logger.error(this.i18n.failed_to_find_packages());
497
497
  return;
498
498
  }
499
+ const origFiles = this.files;
499
500
  const origOptions = this.options;
500
501
  const projects = [];
501
502
  const projectsToConvert = [];
@@ -526,14 +527,23 @@ let Application = (() => {
526
527
  for (const { dir, options } of projectsToConvert) {
527
528
  this.logger.info(this.i18n.converting_project_at_0((0, paths_1.nicePath)(dir)));
528
529
  this.options = options;
529
- const project = await this.convert();
530
+ this.files = new FileRegistry_1.ValidatingFileRegistry();
531
+ let project = await this.convert();
530
532
  if (project) {
531
533
  this.validate(project);
532
- projects.push(this.serializer.projectToObject(project, process.cwd()));
534
+ const serialized = this.serializer.projectToObject(project, process.cwd());
535
+ projects.push(serialized);
533
536
  }
537
+ // When debugging memory issues, it's useful to set these
538
+ // here so that a breakpoint on resetReflectionID below
539
+ // gets the memory as it ought to be with all TS objects released.
540
+ project = undefined;
541
+ this.files = undefined;
542
+ // global.gc!();
534
543
  (0, abstract_1.resetReflectionID)();
535
544
  }
536
545
  this.options = origOptions;
546
+ this.files = origFiles;
537
547
  if (projects.length !== packageDirs.length) {
538
548
  this.logger.error(this.i18n.failed_to_convert_packages());
539
549
  return;
@@ -6,12 +6,9 @@ export interface DiscoveredComment {
6
6
  file: ts.SourceFile;
7
7
  ranges: ts.CommentRange[];
8
8
  jsDoc: ts.JSDoc | undefined;
9
+ inheritedFromParentDeclaration: boolean;
9
10
  }
10
- export declare function discoverFileComments(node: ts.SourceFile, commentStyle: CommentStyle): {
11
- file: ts.SourceFile;
12
- ranges: ts.CommentRange[];
13
- jsDoc: ts.JSDoc | undefined;
14
- }[];
11
+ export declare function discoverFileComments(node: ts.SourceFile, commentStyle: CommentStyle): DiscoveredComment[];
15
12
  export declare function discoverNodeComment(node: ts.Node, commentStyle: CommentStyle): DiscoveredComment | undefined;
16
- export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle): DiscoveredComment | undefined;
17
- export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, commentStyle: CommentStyle): DiscoveredComment | undefined;
13
+ export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker): DiscoveredComment | undefined;
14
+ export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, checker: ts.TypeChecker, commentStyle: CommentStyle): DiscoveredComment | undefined;
@@ -13,6 +13,7 @@ const utils_1 = require("../../utils");
13
13
  const declaration_1 = require("../../utils/options/declaration");
14
14
  const paths_1 = require("../../utils/paths");
15
15
  const assert_1 = require("assert");
16
+ const array_1 = require("../../utils/array");
16
17
  const variablePropertyKinds = [
17
18
  typescript_1.default.SyntaxKind.PropertyDeclaration,
18
19
  typescript_1.default.SyntaxKind.PropertySignature,
@@ -128,6 +129,7 @@ function discoverFileComments(node, commentStyle) {
128
129
  file: node,
129
130
  ranges,
130
131
  jsDoc: findJsDocForComment(node, ranges),
132
+ inheritedFromParentDeclaration: false,
131
133
  };
132
134
  });
133
135
  }
@@ -141,99 +143,119 @@ function discoverNodeComment(node, commentStyle) {
141
143
  file: node.getSourceFile(),
142
144
  ranges: selectedDocComment,
143
145
  jsDoc: findJsDocForComment(node, selectedDocComment),
146
+ inheritedFromParentDeclaration: false,
144
147
  };
145
148
  }
146
149
  }
147
- function discoverComment(symbol, kind, logger, commentStyle) {
150
+ function checkCommentDeclarations(commentNodes, reverse, commentStyle) {
151
+ const discovered = [];
152
+ for (const { node, inheritedFromParentDeclaration } of commentNodes) {
153
+ const text = node.getSourceFile().text;
154
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
155
+ if (reverse) {
156
+ comments.reverse();
157
+ }
158
+ const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
159
+ if (selectedDocComment) {
160
+ discovered.push({
161
+ file: node.getSourceFile(),
162
+ ranges: selectedDocComment,
163
+ jsDoc: findJsDocForComment(node, selectedDocComment),
164
+ inheritedFromParentDeclaration,
165
+ });
166
+ }
167
+ }
168
+ return discovered;
169
+ }
170
+ function discoverComment(symbol, kind, logger, commentStyle, checker) {
148
171
  // For a module comment, we want the first one defined in the file,
149
172
  // not the last one, since that will apply to the import or declaration.
150
173
  const reverse = !symbol.declarations?.some(typescript_1.default.isSourceFile);
151
- const discovered = [];
152
- const seen = new Set();
153
- for (const decl of symbol.declarations || []) {
154
- const text = decl.getSourceFile().text;
155
- if (wantedKinds[kind].includes(decl.kind)) {
156
- const node = declarationToCommentNode(decl);
157
- if (!node || seen.has(node)) {
158
- continue;
159
- }
160
- seen.add(node);
161
- // Special behavior here!
162
- // Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
163
- // This method discovers comments for symbols, and function-likes will only have
164
- // a symbol comment if there is more than one signature (== more than one declaration)
165
- // and there is a comment on the implementation signature.
166
- if (kind & models_1.ReflectionKind.ContainsCallSignatures &&
167
- [
168
- typescript_1.default.SyntaxKind.FunctionDeclaration,
169
- typescript_1.default.SyntaxKind.MethodDeclaration,
170
- typescript_1.default.SyntaxKind.Constructor,
171
- ].includes(node.kind) &&
172
- (symbol.declarations.filter((d) => wantedKinds[kind].includes(d.kind)).length === 1 ||
173
- !node.body)) {
174
- continue;
175
- }
176
- const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
177
- if (reverse) {
178
- comments.reverse();
179
- }
180
- const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
181
- if (selectedDocComment) {
182
- discovered.push({
183
- file: decl.getSourceFile(),
184
- ranges: selectedDocComment,
185
- jsDoc: findJsDocForComment(node, selectedDocComment),
174
+ const wantedDeclarations = (0, array_1.filter)(symbol.declarations, (decl) => wantedKinds[kind].includes(decl.kind));
175
+ const commentNodes = wantedDeclarations.flatMap((decl) => declarationToCommentNodes(decl, checker));
176
+ // Special behavior here!
177
+ // Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
178
+ // This method discovers comments for symbols, and function-likes will only have
179
+ // a symbol comment if there is more than one signature (== more than one declaration)
180
+ // and there is a comment on the implementation signature.
181
+ if (kind & models_1.ReflectionKind.ContainsCallSignatures) {
182
+ const canHaveOverloads = wantedDeclarations.some((node) => [
183
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
184
+ typescript_1.default.SyntaxKind.MethodDeclaration,
185
+ typescript_1.default.SyntaxKind.Constructor,
186
+ ].includes(node.kind));
187
+ const isOverloaded = canHaveOverloads && wantedDeclarations.length > 1;
188
+ if (isOverloaded) {
189
+ commentNodes.length = 0;
190
+ const implementationNode = wantedDeclarations.find((node) => node.body);
191
+ if (implementationNode) {
192
+ commentNodes.push({
193
+ node: implementationNode,
194
+ inheritedFromParentDeclaration: false,
186
195
  });
187
196
  }
188
197
  }
198
+ else if (canHaveOverloads) {
199
+ // Single signature function, function reflection doesn't get a comment,
200
+ // the signatures do.
201
+ commentNodes.length = 0;
202
+ }
203
+ else {
204
+ // Variable declaration which happens to include signatures.
205
+ }
189
206
  }
207
+ const discovered = checkCommentDeclarations(commentNodes, reverse, commentStyle);
190
208
  switch (discovered.length) {
191
209
  case 0:
192
210
  return undefined;
193
211
  case 1:
194
212
  return discovered[0];
195
213
  default: {
196
- logger.warn(logger.i18n.symbol_0_has_multiple_declarations_with_comment(symbol.name));
197
- const locations = discovered.map(({ file, ranges: [{ pos }] }) => {
198
- const path = (0, paths_1.nicePath)(file.fileName);
199
- const line = typescript_1.default.getLineAndCharacterOfPosition(file, pos).line + 1;
200
- return `${path}:${line}`;
201
- });
202
- logger.info(logger.i18n.comments_for_0_are_declared_at_1(symbol.name, locations.join("\n\t")));
214
+ if (discovered.filter((n) => !n.inheritedFromParentDeclaration)
215
+ .length > 1) {
216
+ logger.warn(logger.i18n.symbol_0_has_multiple_declarations_with_comment(symbol.name));
217
+ const locations = discovered.map(({ file, ranges: [{ pos }] }) => {
218
+ const path = (0, paths_1.nicePath)(file.fileName);
219
+ const line = typescript_1.default.getLineAndCharacterOfPosition(file, pos).line +
220
+ 1;
221
+ return `${path}:${line}`;
222
+ });
223
+ logger.info(logger.i18n.comments_for_0_are_declared_at_1(symbol.name, locations.join("\n\t")));
224
+ }
203
225
  return discovered[0];
204
226
  }
205
227
  }
206
228
  }
207
- function discoverSignatureComment(declaration, commentStyle) {
208
- const node = declarationToCommentNode(declaration);
209
- if (!node) {
210
- return;
211
- }
212
- if (typescript_1.default.isJSDocSignature(node)) {
213
- const comment = node.parent.parent;
214
- (0, assert_1.ok)(typescript_1.default.isJSDoc(comment));
215
- return {
216
- file: node.getSourceFile(),
217
- ranges: [
218
- {
219
- kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
220
- pos: comment.pos,
221
- end: comment.end,
222
- },
223
- ],
224
- jsDoc: comment,
225
- };
226
- }
227
- const text = node.getSourceFile().text;
228
- const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
229
- comments.reverse();
230
- const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
231
- if (comment) {
232
- return {
233
- file: node.getSourceFile(),
234
- ranges: comment,
235
- jsDoc: findJsDocForComment(node, comment),
236
- };
229
+ function discoverSignatureComment(declaration, checker, commentStyle) {
230
+ for (const { node, inheritedFromParentDeclaration, } of declarationToCommentNodes(declaration, checker)) {
231
+ if (typescript_1.default.isJSDocSignature(node)) {
232
+ const comment = node.parent.parent;
233
+ (0, assert_1.ok)(typescript_1.default.isJSDoc(comment));
234
+ return {
235
+ file: node.getSourceFile(),
236
+ ranges: [
237
+ {
238
+ kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
239
+ pos: comment.pos,
240
+ end: comment.end,
241
+ },
242
+ ],
243
+ jsDoc: comment,
244
+ inheritedFromParentDeclaration,
245
+ };
246
+ }
247
+ const text = node.getSourceFile().text;
248
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
249
+ comments.reverse();
250
+ const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
251
+ if (comment) {
252
+ return {
253
+ file: node.getSourceFile(),
254
+ ranges: comment,
255
+ jsDoc: findJsDocForComment(node, comment),
256
+ inheritedFromParentDeclaration,
257
+ };
258
+ }
237
259
  }
238
260
  }
239
261
  function findJsDocForComment(node, ranges) {
@@ -282,7 +304,7 @@ function getRootModuleDeclaration(node) {
282
304
  }
283
305
  return node;
284
306
  }
285
- function declarationToCommentNode(node) {
307
+ function declarationToCommentNodeIgnoringParents(node) {
286
308
  // ts.SourceFile is a counterexample
287
309
  if (!node.parent)
288
310
  return node;
@@ -324,7 +346,54 @@ function declarationToCommentNode(node) {
324
346
  if (typescript_1.default.SyntaxKind.NamespaceExport === node.kind) {
325
347
  return node.parent;
326
348
  }
327
- return node;
349
+ }
350
+ function declarationToCommentNodes(node, checker) {
351
+ const commentNode = declarationToCommentNodeIgnoringParents(node);
352
+ if (commentNode) {
353
+ return [
354
+ {
355
+ node: commentNode,
356
+ inheritedFromParentDeclaration: false,
357
+ },
358
+ ];
359
+ }
360
+ const result = [
361
+ {
362
+ node,
363
+ inheritedFromParentDeclaration: false,
364
+ },
365
+ ];
366
+ const seenSymbols = new Set();
367
+ const bases = findBaseOfDeclaration(checker, node, (symbol) => {
368
+ if (!seenSymbols.has(symbol)) {
369
+ seenSymbols.add(symbol);
370
+ return symbol.declarations?.map((node) => declarationToCommentNodeIgnoringParents(node) || node);
371
+ }
372
+ });
373
+ for (const parentCommentNode of bases || []) {
374
+ result.push({
375
+ node: parentCommentNode,
376
+ inheritedFromParentDeclaration: true,
377
+ });
378
+ }
379
+ return result;
380
+ }
381
+ // Lifted from the TS source, with a couple minor modifications
382
+ function findBaseOfDeclaration(checker, declaration, cb) {
383
+ const classOrInterfaceDeclaration = declaration.parent?.kind === typescript_1.default.SyntaxKind.Constructor
384
+ ? declaration.parent.parent
385
+ : declaration.parent;
386
+ if (!classOrInterfaceDeclaration)
387
+ return;
388
+ const isStaticMember = typescript_1.default.getCombinedModifierFlags(declaration) & typescript_1.default.ModifierFlags.Static;
389
+ return (0, array_1.firstDefined)(typescript_1.default.getAllSuperTypeNodes(classOrInterfaceDeclaration), (superTypeNode) => {
390
+ const baseType = checker.getTypeAtLocation(superTypeNode);
391
+ const type = isStaticMember && baseType.symbol
392
+ ? checker.getTypeOfSymbol(baseType.symbol)
393
+ : baseType;
394
+ const symbol = checker.getPropertyOfType(type, declaration.symbol.name);
395
+ return symbol ? cb(symbol) : undefined;
396
+ });
328
397
  }
329
398
  /**
330
399
  * Separate comment ranges into arrays so that multiple line comments are kept together
@@ -8,10 +8,13 @@ export interface CommentParserConfig {
8
8
  inlineTags: Set<string>;
9
9
  modifierTags: Set<string>;
10
10
  jsDocCompatibility: JsDocCompatibility;
11
+ suppressCommentWarningsInDeclarationFiles: boolean;
12
+ useTsLinkResolution: boolean;
13
+ commentStyle: CommentStyle;
11
14
  }
12
15
  export declare function clearCommentCache(): void;
13
- export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
14
- export declare function getNodeComment(node: ts.Node, moduleComment: boolean, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
15
- export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
16
- export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
16
+ export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker, files: FileRegistry): Comment | undefined;
17
+ export declare function getNodeComment(node: ts.Node, moduleComment: boolean, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
18
+ export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
19
+ export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker, files: FileRegistry): Comment | undefined;
17
20
  export declare function getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
@@ -38,7 +38,10 @@ function getCommentWithCache(discovered, config, logger, checker, files) {
38
38
  const { file, ranges, jsDoc } = discovered;
39
39
  const cache = commentCache.get(file) || new Map();
40
40
  if (cache.has(ranges[0].pos)) {
41
- return cache.get(ranges[0].pos).clone();
41
+ const clone = cache.get(ranges[0].pos).clone();
42
+ clone.inheritedFromParentDeclaration =
43
+ discovered.inheritedFromParentDeclaration;
44
+ return clone;
42
45
  }
43
46
  let comment;
44
47
  switch (ranges[0].kind) {
@@ -52,12 +55,14 @@ function getCommentWithCache(discovered, config, logger, checker, files) {
52
55
  (0, utils_1.assertNever)(ranges[0].kind);
53
56
  }
54
57
  comment.discoveryId = ++commentDiscoveryId;
58
+ comment.inheritedFromParentDeclaration =
59
+ discovered.inheritedFromParentDeclaration;
55
60
  cache.set(ranges[0].pos, comment);
56
61
  commentCache.set(file, cache);
57
62
  return comment.clone();
58
63
  }
59
64
  function getCommentImpl(commentSource, config, logger, moduleComment, checker, files) {
60
- const comment = getCommentWithCache(commentSource, config, logger, checker, files);
65
+ const comment = getCommentWithCache(commentSource, config, logger, config.useTsLinkResolution ? checker : undefined, files);
61
66
  if (comment?.getTag("@import") || comment?.getTag("@license")) {
62
67
  return;
63
68
  }
@@ -78,7 +83,7 @@ function getCommentImpl(commentSource, config, logger, moduleComment, checker, f
78
83
  }
79
84
  return comment;
80
85
  }
81
- function getComment(symbol, kind, config, logger, commentStyle, checker, files) {
86
+ function getComment(symbol, kind, config, logger, checker, files) {
82
87
  const declarations = symbol.declarations || [];
83
88
  if (declarations.length &&
84
89
  declarations.every((d) => jsDocCommentKinds.includes(d.kind))) {
@@ -86,7 +91,7 @@ function getComment(symbol, kind, config, logger, commentStyle, checker, files)
86
91
  }
87
92
  const sf = declarations.find(typescript_1.default.isSourceFile);
88
93
  if (sf) {
89
- return getFileComment(sf, config, logger, commentStyle, checker, files);
94
+ return getFileComment(sf, config, logger, checker, files);
90
95
  }
91
96
  const isModule = declarations.some((decl) => {
92
97
  if (typescript_1.default.isModuleDeclaration(decl) && typescript_1.default.isStringLiteral(decl.name)) {
@@ -94,18 +99,18 @@ function getComment(symbol, kind, config, logger, commentStyle, checker, files)
94
99
  }
95
100
  return false;
96
101
  });
97
- const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, isModule, checker, files);
102
+ const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, config.commentStyle, checker), config, logger, isModule, checker, files);
98
103
  if (!comment && kind === models_1.ReflectionKind.Property) {
99
- return getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker, files);
104
+ return getConstructorParamPropertyComment(symbol, config, logger, checker, files);
100
105
  }
101
106
  return comment;
102
107
  }
103
- function getNodeComment(node, moduleComment, config, logger, commentStyle, checker, files) {
104
- return getCommentImpl((0, discovery_1.discoverNodeComment)(node, commentStyle), config, logger, moduleComment, checker, files);
108
+ function getNodeComment(node, moduleComment, config, logger, checker, files) {
109
+ return getCommentImpl((0, discovery_1.discoverNodeComment)(node, config.commentStyle), config, logger, moduleComment, checker, files);
105
110
  }
106
- function getFileComment(file, config, logger, commentStyle, checker, files) {
107
- for (const commentSource of (0, discovery_1.discoverFileComments)(file, commentStyle)) {
108
- const comment = getCommentWithCache(commentSource, config, logger, checker, files);
111
+ function getFileComment(file, config, logger, checker, files) {
112
+ for (const commentSource of (0, discovery_1.discoverFileComments)(file, config.commentStyle)) {
113
+ const comment = getCommentWithCache(commentSource, config, logger, config.useTsLinkResolution ? checker : undefined, files);
109
114
  if (comment?.getTag("@license") || comment?.getTag("@import")) {
110
115
  continue;
111
116
  }
@@ -116,12 +121,12 @@ function getFileComment(file, config, logger, commentStyle, checker, files) {
116
121
  return;
117
122
  }
118
123
  }
119
- function getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker, files) {
124
+ function getConstructorParamPropertyComment(symbol, config, logger, checker, files) {
120
125
  const decl = symbol.declarations?.find(typescript_1.default.isParameter);
121
126
  if (!decl)
122
127
  return;
123
128
  const ctor = decl.parent;
124
- const comment = getSignatureComment(ctor, config, logger, commentStyle, checker, files);
129
+ const comment = getSignatureComment(ctor, config, logger, checker, files);
125
130
  const paramTag = comment?.getIdentifiedTag(symbol.name, "@param");
126
131
  if (paramTag) {
127
132
  const result = new models_1.Comment(paramTag.content);
@@ -129,8 +134,8 @@ function getConstructorParamPropertyComment(symbol, config, logger, commentStyle
129
134
  return result;
130
135
  }
131
136
  }
132
- function getSignatureComment(declaration, config, logger, commentStyle, checker, files) {
133
- return getCommentImpl((0, discovery_1.discoverSignatureComment)(declaration, commentStyle), config, logger, false, checker, files);
137
+ function getSignatureComment(declaration, config, logger, checker, files) {
138
+ return getCommentImpl((0, discovery_1.discoverSignatureComment)(declaration, checker, config.commentStyle), config, logger, false, checker, files);
134
139
  }
135
140
  function getJsDocComment(declaration, config, logger, checker, files) {
136
141
  const file = declaration.getSourceFile();
@@ -150,7 +155,8 @@ function getJsDocComment(declaration, config, logger, checker, files) {
150
155
  },
151
156
  ],
152
157
  jsDoc: parent,
153
- }, config, logger, checker, files);
158
+ inheritedFromParentDeclaration: false,
159
+ }, config, logger, config.useTsLinkResolution ? checker : undefined, files);
154
160
  // And pull out the tag we actually care about.
155
161
  if (typescript_1.default.isJSDocEnumTag(declaration)) {
156
162
  const result = new models_1.Comment(comment.getTag("@enum")?.content);
@@ -79,6 +79,10 @@ function parseComment(tokens, config, file, logger, files) {
79
79
  postProcessComment(comment, logger.i18n, () => `${(0, paths_1.nicePath)(file.fileName)}:${file.getLineAndCharacterOfPosition(tok2.pos).line + 1}`, (message) => logger.warn(message));
80
80
  return comment;
81
81
  function warningImpl(message, token) {
82
+ if (config.suppressCommentWarningsInDeclarationFiles &&
83
+ file.fileName.endsWith(".d.ts")) {
84
+ return;
85
+ }
82
86
  logger.warn(message, token.pos, file);
83
87
  }
84
88
  }
@@ -98,13 +102,16 @@ function parseCommentString(tokens, config, file, logger, files) {
98
102
  ignoreUnescapedBraces: true,
99
103
  inheritDocTag: true,
100
104
  },
105
+ suppressCommentWarningsInDeclarationFiles: true,
101
106
  };
107
+ const reentry = new textParser_1.TextParserReentryState();
102
108
  const content = [];
103
109
  const lexer = makeLookaheadGenerator(tokens);
104
110
  let atNewLine = false;
105
111
  while (!lexer.done()) {
106
112
  let consume = true;
107
113
  const next = lexer.peek();
114
+ reentry.checkState(next);
108
115
  switch (next.kind) {
109
116
  case lexer_1.TokenSyntaxKind.TypeAnnotation:
110
117
  // Shouldn't have been produced by our lexer
@@ -114,7 +121,7 @@ function parseCommentString(tokens, config, file, logger, files) {
114
121
  case lexer_1.TokenSyntaxKind.Text:
115
122
  case lexer_1.TokenSyntaxKind.Tag:
116
123
  case lexer_1.TokenSyntaxKind.CloseBrace:
117
- (0, textParser_1.textContent)(file.fileName, next, logger.i18n, (msg, token) => logger.warn(msg, token.pos, file), content, files, atNewLine);
124
+ (0, textParser_1.textContent)(file.fileName, next, logger.i18n, (msg, token) => logger.warn(msg, token.pos, file), content, files, atNewLine, reentry);
118
125
  break;
119
126
  case lexer_1.TokenSyntaxKind.Code:
120
127
  content.push({ kind: "code", text: next.text });
@@ -367,8 +374,10 @@ function exampleBlock(comment, lexer, config, i18n, warning, files) {
367
374
  function blockContent(comment, lexer, config, i18n, warning, files) {
368
375
  const content = [];
369
376
  let atNewLine = true;
377
+ const reentry = new textParser_1.TextParserReentryState();
370
378
  loop: while (!lexer.done()) {
371
379
  const next = lexer.peek();
380
+ reentry.checkState(next);
372
381
  let consume = true;
373
382
  switch (next.kind) {
374
383
  case lexer_1.TokenSyntaxKind.NewLine:
@@ -376,7 +385,7 @@ function blockContent(comment, lexer, config, i18n, warning, files) {
376
385
  break;
377
386
  case lexer_1.TokenSyntaxKind.Text:
378
387
  (0, textParser_1.textContent)(comment.sourcePath, next, i18n, warning,
379
- /*out*/ content, files, atNewLine);
388
+ /*out*/ content, files, atNewLine, reentry);
380
389
  break;
381
390
  case lexer_1.TokenSyntaxKind.Code:
382
391
  content.push({ kind: "code", text: next.text });
@@ -9,8 +9,19 @@ import type { TranslationProxy, TranslatedString } from "../../internationalizat
9
9
  import type { CommentDisplayPart } from "../../models";
10
10
  import type { FileRegistry } from "../../models/FileRegistry";
11
11
  import { type Token } from "./lexer";
12
+ /**
13
+ * This is incredibly unfortunate. The comment lexer owns the responsibility
14
+ * for splitting up text into text/code, this is totally fine for HTML links
15
+ * but for markdown links, ``[`code`](./link)`` is valid, so we need to keep
16
+ * track of state across calls to {@link textContent}.
17
+ */
18
+ export declare class TextParserReentryState {
19
+ withinLinkLabel: boolean;
20
+ private lastPartWasNewline;
21
+ checkState(token: Token): void;
22
+ }
12
23
  /**
13
24
  * Look for relative links within a piece of text and add them to the {@link FileRegistry}
14
25
  * so that they can be correctly resolved during rendering.
15
26
  */
16
- export declare function textContent(sourcePath: string, token: Token, i18n: TranslationProxy, warning: (msg: TranslatedString, token: Token) => void, outContent: CommentDisplayPart[], files: FileRegistry, atNewLine: boolean): void;
27
+ export declare function textContent(sourcePath: string, token: Token, i18n: TranslationProxy, warning: (msg: TranslatedString, token: Token) => void, outContent: CommentDisplayPart[], files: FileRegistry, atNewLine: boolean, reentry: TextParserReentryState): void;