typedoc 0.28.12 → 0.28.14

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 (47) hide show
  1. package/dist/lib/application.d.ts +4 -0
  2. package/dist/lib/application.js +8 -1
  3. package/dist/lib/converter/comments/index.d.ts +1 -0
  4. package/dist/lib/converter/comments/parser.js +19 -2
  5. package/dist/lib/converter/converter.js +1 -0
  6. package/dist/lib/converter/factories/signature.js +5 -4
  7. package/dist/lib/converter/plugins/CommentPlugin.d.ts +1 -0
  8. package/dist/lib/converter/plugins/CommentPlugin.js +35 -11
  9. package/dist/lib/converter/plugins/ImplementsPlugin.js +25 -12
  10. package/dist/lib/converter/plugins/InheritDocPlugin.js +2 -0
  11. package/dist/lib/converter/plugins/SourcePlugin.d.ts +1 -2
  12. package/dist/lib/converter/plugins/SourcePlugin.js +5 -10
  13. package/dist/lib/converter/symbols.js +7 -0
  14. package/dist/lib/converter/types.js +20 -8
  15. package/dist/lib/internationalization/locales/de.cjs +0 -1
  16. package/dist/lib/internationalization/locales/de.d.cts +0 -1
  17. package/dist/lib/internationalization/locales/en.cjs +6 -2
  18. package/dist/lib/internationalization/locales/en.d.cts +6 -2
  19. package/dist/lib/internationalization/locales/ja.cjs +0 -1
  20. package/dist/lib/internationalization/locales/ja.d.cts +0 -1
  21. package/dist/lib/internationalization/locales/ko.cjs +0 -1
  22. package/dist/lib/internationalization/locales/ko.d.cts +0 -1
  23. package/dist/lib/internationalization/locales/zh.cjs +0 -1
  24. package/dist/lib/internationalization/locales/zh.d.cts +0 -1
  25. package/dist/lib/models/Comment.d.ts +5 -0
  26. package/dist/lib/models/Comment.js +10 -0
  27. package/dist/lib/models/types.d.ts +1 -1
  28. package/dist/lib/models/types.js +4 -2
  29. package/dist/lib/output/themes/MarkedPlugin.js +8 -1
  30. package/dist/lib/output/themes/default/Slugger.d.ts +1 -1
  31. package/dist/lib/output/themes/default/Slugger.js +13 -5
  32. package/dist/lib/output/themes/default/partials/comment.js +1 -0
  33. package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +1 -1
  34. package/dist/lib/output/themes/default/partials/typeAndParent.js +18 -8
  35. package/dist/lib/serialization/schema.d.ts +1 -1
  36. package/dist/lib/utils/ValidatingFileRegistry.d.ts +2 -0
  37. package/dist/lib/utils/ValidatingFileRegistry.js +18 -3
  38. package/dist/lib/utils/entry-point.js +3 -2
  39. package/dist/lib/utils/options/declaration.d.ts +4 -1
  40. package/dist/lib/utils/options/defaults.d.ts +1 -0
  41. package/dist/lib/utils/options/defaults.js +1 -0
  42. package/dist/lib/utils/options/sources/typedoc.js +31 -25
  43. package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
  44. package/dist/lib/utils/options/tsdoc-defaults.js +1 -0
  45. package/dist/lib/utils-common/general.js +2 -0
  46. package/package.json +3 -3
  47. package/tsdoc.json +5 -0
@@ -67,6 +67,10 @@ export declare class Application extends AbstractComponent<Application, Applicat
67
67
  */
68
68
  internationalization: Internationalization;
69
69
  options: Options;
70
+ /**
71
+ * Due for deprecation in 0.29, use the reference to this on {@link ProjectReflection},
72
+ * this was the wrong place for this member to live.
73
+ */
70
74
  files: FileRegistry;
71
75
  /** @internal */
72
76
  accessor lang: string;
@@ -158,6 +158,10 @@ let Application = (() => {
158
158
  */
159
159
  internationalization = new Internationalization();
160
160
  options = new Options();
161
+ /**
162
+ * Due for deprecation in 0.29, use the reference to this on {@link ProjectReflection},
163
+ * this was the wrong place for this member to live.
164
+ */
161
165
  files = new ValidatingFileRegistry();
162
166
  #lang_accessor_storage = __runInitializers(this, _lang_initializers, void 0);
163
167
  /** @internal */
@@ -260,6 +264,9 @@ let Application = (() => {
260
264
  else {
261
265
  this.logger.level = this.options.getValue("logLevel");
262
266
  }
267
+ if (this.files instanceof ValidatingFileRegistry) {
268
+ this.files.basePath = this.options.getValue("basePath");
269
+ }
263
270
  for (const [lang, locales] of Object.entries(this.options.getValue("locales"))) {
264
271
  this.internationalization.addTranslations(lang, locales);
265
272
  }
@@ -630,7 +637,7 @@ let Application = (() => {
630
637
  for (const { dir, options } of projectsToConvert) {
631
638
  this.logger.info(i18n.converting_project_at_0(nicePath(dir)));
632
639
  this.options = options;
633
- this.files = new ValidatingFileRegistry();
640
+ this.files = new ValidatingFileRegistry(options.getValue("basePath"));
634
641
  let project = await this.convert();
635
642
  if (project) {
636
643
  this.validate(project);
@@ -8,6 +8,7 @@ export interface CommentParserConfig {
8
8
  blockTags: Set<string>;
9
9
  inlineTags: Set<string>;
10
10
  modifierTags: Set<string>;
11
+ preservedTypeAnnotationTags: Set<string>;
11
12
  jsDocCompatibility: JsDocCompatibility;
12
13
  suppressCommentWarningsInDeclarationFiles: boolean;
13
14
  useTsLinkResolution: boolean;
@@ -206,6 +206,9 @@ function postProcessComment(comment, i18n, getPosition, warning) {
206
206
  if ((inlineInheritDoc.length || inheritDoc.length) && remarks.length) {
207
207
  warning(i18n.content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0(getPosition()));
208
208
  }
209
+ if ((inlineInheritDoc.length || inheritDoc.length) && returns.length) {
210
+ warning(i18n.content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0(getPosition()));
211
+ }
209
212
  }
210
213
  const aliasedTags = new Map([["@return", "@returns"]]);
211
214
  function blockTag(comment, lexer, config, i18n, warning, files) {
@@ -219,14 +222,28 @@ function blockTag(comment, lexer, config, i18n, warning, files) {
219
222
  if (tagName === "@example") {
220
223
  return exampleBlock(comment, lexer, config, i18n, warning, files);
221
224
  }
222
- else if (["@default", "@defaultValue"].includes(tagName) &&
225
+ let typeAnnotation;
226
+ if (!lexer.done() &&
227
+ config.preservedTypeAnnotationTags.has(tagName)) {
228
+ if (lexer.peek().kind === TokenSyntaxKind.Text && /^\s+$/.test(lexer.peek().text)) {
229
+ lexer.take();
230
+ }
231
+ if (lexer.peek().kind === TokenSyntaxKind.TypeAnnotation) {
232
+ typeAnnotation = lexer.take().text;
233
+ }
234
+ }
235
+ if (["@default", "@defaultValue"].includes(tagName) &&
223
236
  config.jsDocCompatibility.defaultTag) {
224
237
  content = defaultBlockContent(comment, lexer, config, i18n, warning, files);
225
238
  }
226
239
  else {
227
240
  content = blockContent(comment, lexer, config, i18n, warning, files);
228
241
  }
229
- return new CommentTag(tagName, content);
242
+ const tag = new CommentTag(tagName, content);
243
+ if (typeAnnotation) {
244
+ tag.typeAnnotation = typeAnnotation;
245
+ }
246
+ return tag;
230
247
  }
231
248
  /**
232
249
  * The `@default` tag gets a special case because otherwise we will produce many warnings
@@ -609,6 +609,7 @@ let Converter = (() => {
609
609
  blockTags: new Set(this.application.options.getValue("blockTags")),
610
610
  inlineTags: new Set(this.application.options.getValue("inlineTags")),
611
611
  modifierTags: new Set(this.application.options.getValue("modifierTags")),
612
+ preservedTypeAnnotationTags: new Set(this.application.options.getValue("preservedTypeAnnotationTags")),
612
613
  jsDocCompatibility: this.application.options.getValue("jsDocCompatibility"),
613
614
  suppressCommentWarningsInDeclarationFiles: this.application.options.getValue("suppressCommentWarningsInDeclarationFiles"),
614
615
  useTsLinkResolution: this.application.options.getValue("useTsLinkResolution"),
@@ -113,7 +113,7 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
113
113
  assert(!declaration ||
114
114
  ts.isParameter(declaration) ||
115
115
  ts.isJSDocParameterTag(declaration));
116
- const paramRefl = new ParameterReflection(/__\d+/.test(param.name) ? "__namedParameters" : param.name, ReflectionKind.Parameter, sigRef);
116
+ const paramRefl = new ParameterReflection(/^__\d+$/.test(param.name) ? "__namedParameters" : param.name, ReflectionKind.Parameter, sigRef);
117
117
  if (declaration && ts.isJSDocParameterTag(declaration)) {
118
118
  paramRefl.comment = context.getJsDocComment(declaration);
119
119
  }
@@ -132,7 +132,7 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
132
132
  }
133
133
  }
134
134
  else {
135
- type = param.type;
135
+ type = context.checker.getTypeOfSymbol(param);
136
136
  }
137
137
  if (declaration &&
138
138
  ts.isParameter(declaration) &&
@@ -160,8 +160,9 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
160
160
  paramRefl.defaultValue = convertDefaultValue(parameterNodes?.[i + parameterNodeOffset]);
161
161
  paramRefl.setFlag(ReflectionFlag.Optional, isOptional);
162
162
  // If we have no declaration, then this is an implicitly defined parameter in JS land
163
- // because the method body uses `arguments`... which is always a rest argument
164
- let isRest = true;
163
+ // because the method body uses `arguments`... which is always a rest argument,
164
+ // unless it is a this parameter defined with @this in JSDoc.
165
+ let isRest = param.name !== "this";
165
166
  if (declaration) {
166
167
  isRest = ts.isParameter(declaration)
167
168
  ? !!declaration.dotDotDotToken
@@ -61,6 +61,7 @@ export declare class CommentPlugin extends ConverterComponent {
61
61
  accessor cascadedModifierTags: TagString[];
62
62
  accessor excludeInternal: boolean;
63
63
  accessor excludePrivate: boolean;
64
+ accessor excludePrivateClassFields: boolean;
64
65
  accessor excludeProtected: boolean;
65
66
  accessor excludeNotDocumented: boolean;
66
67
  accessor excludeCategories: string[];
@@ -44,9 +44,9 @@ import { CategoryPlugin } from "./CategoryPlugin.js";
44
44
  * (for JS users) will be consumed by TypeScript and need not be preserved
45
45
  * in the comment.
46
46
  *
47
- * Note that param/arg/argument/return/returns are not present.
47
+ * Note that param/arg/argument/return/returns/this are not present.
48
48
  * These tags will have their type information stripped when parsing, but still
49
- * provide useful information for documentation.
49
+ * may provide useful information for documentation.
50
50
  */
51
51
  const NEVER_RENDERED = [
52
52
  "@augments",
@@ -55,7 +55,6 @@ const NEVER_RENDERED = [
55
55
  "@constructor",
56
56
  "@enum",
57
57
  "@extends",
58
- "@this",
59
58
  "@type",
60
59
  "@typedef",
61
60
  "@jsx",
@@ -140,6 +139,9 @@ let CommentPlugin = (() => {
140
139
  let _excludePrivate_decorators;
141
140
  let _excludePrivate_initializers = [];
142
141
  let _excludePrivate_extraInitializers = [];
142
+ let _excludePrivateClassFields_decorators;
143
+ let _excludePrivateClassFields_initializers = [];
144
+ let _excludePrivateClassFields_extraInitializers = [];
143
145
  let _excludeProtected_decorators;
144
146
  let _excludeProtected_initializers = [];
145
147
  let _excludeProtected_extraInitializers = [];
@@ -159,6 +161,7 @@ let CommentPlugin = (() => {
159
161
  _cascadedModifierTags_decorators = [Option("cascadedModifierTags")];
160
162
  _excludeInternal_decorators = [Option("excludeInternal")];
161
163
  _excludePrivate_decorators = [Option("excludePrivate")];
164
+ _excludePrivateClassFields_decorators = [Option("excludePrivateClassFields")];
162
165
  _excludeProtected_decorators = [Option("excludeProtected")];
163
166
  _excludeNotDocumented_decorators = [Option("excludeNotDocumented")];
164
167
  _excludeCategories_decorators = [Option("excludeCategories")];
@@ -167,6 +170,7 @@ let CommentPlugin = (() => {
167
170
  __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);
168
171
  __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);
169
172
  __esDecorate(this, null, _excludePrivate_decorators, { kind: "accessor", name: "excludePrivate", static: false, private: false, access: { has: obj => "excludePrivate" in obj, get: obj => obj.excludePrivate, set: (obj, value) => { obj.excludePrivate = value; } }, metadata: _metadata }, _excludePrivate_initializers, _excludePrivate_extraInitializers);
173
+ __esDecorate(this, null, _excludePrivateClassFields_decorators, { kind: "accessor", name: "excludePrivateClassFields", static: false, private: false, access: { has: obj => "excludePrivateClassFields" in obj, get: obj => obj.excludePrivateClassFields, set: (obj, value) => { obj.excludePrivateClassFields = value; } }, metadata: _metadata }, _excludePrivateClassFields_initializers, _excludePrivateClassFields_extraInitializers);
170
174
  __esDecorate(this, null, _excludeProtected_decorators, { kind: "accessor", name: "excludeProtected", static: false, private: false, access: { has: obj => "excludeProtected" in obj, get: obj => obj.excludeProtected, set: (obj, value) => { obj.excludeProtected = value; } }, metadata: _metadata }, _excludeProtected_initializers, _excludeProtected_extraInitializers);
171
175
  __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);
172
176
  __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);
@@ -185,7 +189,10 @@ let CommentPlugin = (() => {
185
189
  #excludePrivate_accessor_storage = (__runInitializers(this, _excludeInternal_extraInitializers), __runInitializers(this, _excludePrivate_initializers, void 0));
186
190
  get excludePrivate() { return this.#excludePrivate_accessor_storage; }
187
191
  set excludePrivate(value) { this.#excludePrivate_accessor_storage = value; }
188
- #excludeProtected_accessor_storage = (__runInitializers(this, _excludePrivate_extraInitializers), __runInitializers(this, _excludeProtected_initializers, void 0));
192
+ #excludePrivateClassFields_accessor_storage = (__runInitializers(this, _excludePrivate_extraInitializers), __runInitializers(this, _excludePrivateClassFields_initializers, void 0));
193
+ get excludePrivateClassFields() { return this.#excludePrivateClassFields_accessor_storage; }
194
+ set excludePrivateClassFields(value) { this.#excludePrivateClassFields_accessor_storage = value; }
195
+ #excludeProtected_accessor_storage = (__runInitializers(this, _excludePrivateClassFields_extraInitializers), __runInitializers(this, _excludeProtected_initializers, void 0));
189
196
  get excludeProtected() { return this.#excludeProtected_accessor_storage; }
190
197
  set excludeProtected(value) { this.#excludeProtected_accessor_storage = value; }
191
198
  #excludeNotDocumented_accessor_storage = (__runInitializers(this, _excludeProtected_extraInitializers), __runInitializers(this, _excludeNotDocumented_initializers, void 0));
@@ -447,19 +454,25 @@ let CommentPlugin = (() => {
447
454
  moveSignatureParamComments(signature, comment = signature.comment) {
448
455
  if (!comment)
449
456
  return;
450
- signature.parameters?.forEach((parameter, index) => {
451
- if (parameter.name === "__namedParameters") {
452
- const commentParams = comment.blockTags.filter((tag) => tag.tag === "@param" && !tag.name?.includes("."));
453
- if (signature.parameters?.length === commentParams.length &&
454
- commentParams[index].name) {
455
- parameter.name = commentParams[index].name;
456
- }
457
+ const unusedCommentParams = comment.blockTags.filter((tag) => tag.tag === "@param" && tag.name && !tag.name.includes(".") &&
458
+ !signature.parameters?.some(p => p.name === tag.name));
459
+ signature.parameters?.forEach((parameter) => {
460
+ if (parameter.name === "__namedParameters" && unusedCommentParams.length) {
461
+ parameter.name = unusedCommentParams[0].name;
462
+ unusedCommentParams.splice(0, 1);
457
463
  }
458
464
  const tag = comment.getIdentifiedTag(parameter.name, "@param");
459
465
  if (tag) {
460
466
  parameter.comment = new Comment(Comment.cloneDisplayParts(tag.content));
461
467
  parameter.comment.sourcePath = comment.sourcePath;
462
468
  }
469
+ else if (parameter.name === "this") {
470
+ const thisTag = comment.getTag("@this");
471
+ if (thisTag) {
472
+ parameter.comment = new Comment(Comment.cloneDisplayParts(thisTag.content));
473
+ parameter.comment.sourcePath = comment.sourcePath;
474
+ }
475
+ }
463
476
  });
464
477
  for (const parameter of signature.typeParameters || []) {
465
478
  const tag = comment.getIdentifiedTag(parameter.name, "@typeParam") ||
@@ -471,6 +484,7 @@ let CommentPlugin = (() => {
471
484
  }
472
485
  }
473
486
  this.validateParamTags(signature, comment, signature.parameters || []);
487
+ comment.removeTags("@this");
474
488
  comment.removeTags("@param");
475
489
  comment.removeTags("@typeParam");
476
490
  comment.removeTags("@template");
@@ -513,6 +527,16 @@ let CommentPlugin = (() => {
513
527
  this.excludePrivate) {
514
528
  return true;
515
529
  }
530
+ // #3017 this isn't quite right as it may incorrectly detect
531
+ // private members named with a hash which aren't actually private
532
+ // class fields (e.g. class Foo { "#hash" = 1 })
533
+ // We can't fix this without storing more information about the name,
534
+ // which I'm going to put off until #3015 is done.
535
+ if (reflection.flags.hasFlag(ReflectionFlag.Private) &&
536
+ reflection.name.startsWith("#") &&
537
+ this.excludePrivateClassFields) {
538
+ return true;
539
+ }
516
540
  if (reflection.flags.hasFlag(ReflectionFlag.Protected) &&
517
541
  this.excludeProtected) {
518
542
  return true;
@@ -4,7 +4,7 @@ import { DeclarationReflection, ReflectionFlag, ReflectionKind, SignatureReflect
4
4
  import { ReferenceType, ReflectionType } from "../../models/types.js";
5
5
  import { filterMap, zip } from "#utils";
6
6
  import { ConverterComponent } from "../components.js";
7
- import { getHumanName } from "../../utils/index.js";
7
+ import { findPackageForPath, getHumanName } from "../../utils/index.js";
8
8
  import { ConverterEvents } from "../converter-events.js";
9
9
  /**
10
10
  * A plugin that detects interface implementations of functions and
@@ -95,22 +95,23 @@ export class ImplementsPlugin extends ConverterComponent {
95
95
  // serialization/deserialization, might point to an unexpected location. (See the mixin
96
96
  // converter tests, I suspect this might actually be an indication of something else slightly
97
97
  // broken there, but don't want to spend more time with this right now.)
98
- // #2982, even more unfortunately, we only want to keep the link if it is pointing to a reflection
99
- // which will receive a link during rendering.
100
- const isValidRef = (ref) => ref.reflection && !ref.reflection.parent?.kindOf(ReflectionKind.TypeLiteral);
98
+ // #2982/#3007, even more unfortunately, we only want to keep the link if it is pointing
99
+ // to a reflection which will receive a link during rendering, we pick this based on it being
100
+ // the type of member we expect to point to.
101
+ const isValidRef = (ref) => !!ref.reflection?.parent?.kindOf(ReflectionKind.ClassOrInterface | ReflectionKind.Method | ReflectionKind.Constructor);
101
102
  for (const child of reflection.children || []) {
102
103
  if (child.inheritedFrom && !isValidRef(child.inheritedFrom)) {
103
- child.inheritedFrom = ReferenceType.createBrokenReference(child.inheritedFrom.name, project);
104
+ child.inheritedFrom = ReferenceType.createBrokenReference(child.inheritedFrom.name, project, child.inheritedFrom.package);
104
105
  }
105
106
  if (child.overwrites && !isValidRef(child.overwrites)) {
106
- child.overwrites = ReferenceType.createBrokenReference(child.overwrites.name, project);
107
+ child.overwrites = ReferenceType.createBrokenReference(child.overwrites.name, project, child.overwrites.package);
107
108
  }
108
109
  for (const childSig of child.getAllSignatures()) {
109
110
  if (childSig.inheritedFrom && !isValidRef(childSig.inheritedFrom)) {
110
- childSig.inheritedFrom = ReferenceType.createBrokenReference(childSig.inheritedFrom.name, project);
111
+ childSig.inheritedFrom = ReferenceType.createBrokenReference(childSig.inheritedFrom.name, project, childSig.inheritedFrom.package);
111
112
  }
112
113
  if (childSig.overwrites && !isValidRef(childSig.overwrites)) {
113
- childSig.overwrites = ReferenceType.createBrokenReference(childSig.overwrites.name, project);
114
+ childSig.overwrites = ReferenceType.createBrokenReference(childSig.overwrites.name, project, childSig.overwrites.package);
114
115
  }
115
116
  }
116
117
  }
@@ -325,15 +326,27 @@ export class ImplementsPlugin extends ConverterComponent {
325
326
  }
326
327
  }
327
328
  }
329
+ function getConstructorPackagePath(context, clause) {
330
+ const symbol = context.getSymbolAtLocation(clause.expression);
331
+ if (!symbol)
332
+ return undefined;
333
+ const resolvedSymbol = context.resolveAliasedSymbol(symbol);
334
+ const symbolPath = resolvedSymbol?.declarations?.[0]?.getSourceFile().fileName;
335
+ if (!symbolPath)
336
+ return undefined;
337
+ return findPackageForPath(symbolPath)?.[0];
338
+ }
328
339
  function constructorInheritance(context, reflection, childDecl, constructorDecl) {
329
340
  const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token === ts.SyntaxKind.ExtendsKeyword);
330
341
  if (!extendsClause)
331
342
  return;
332
- const name = `${extendsClause.types[0].getText()}.constructor`;
343
+ const extendsType = extendsClause.types[0];
344
+ const refPackage = getConstructorPackagePath(context, extendsType);
345
+ const name = `${extendsType.getText()}.constructor`;
333
346
  const key = constructorDecl ? "overwrites" : "inheritedFrom";
334
- reflection[key] ??= ReferenceType.createBrokenReference(name, context.project);
347
+ reflection[key] ??= ReferenceType.createBrokenReference(name, context.project, refPackage);
335
348
  for (const sig of reflection.signatures ?? []) {
336
- sig[key] ??= ReferenceType.createBrokenReference(name, context.project);
349
+ sig[key] ??= ReferenceType.createBrokenReference(name, context.project, refPackage);
337
350
  }
338
351
  }
339
352
  function findProperty(reflection, parent) {
@@ -356,7 +369,7 @@ function createLink(context, reflection, clause, expr, symbol, isInherit) {
356
369
  const rootSymbols = context.checker.getRootSymbols(symbol);
357
370
  const ref = rootSymbols.length && rootSymbols[0] != symbol
358
371
  ? context.createSymbolReference(rootSymbols[0], context, name)
359
- : ReferenceType.createBrokenReference(name, context.project);
372
+ : ReferenceType.createBrokenReference(name, context.project, undefined);
360
373
  link(reflection);
361
374
  link(reflection.getSignature);
362
375
  link(reflection.setSignature);
@@ -149,6 +149,8 @@ let InheritDocPlugin = (() => {
149
149
  return;
150
150
  }
151
151
  target.comment.removeTags("@inheritDoc");
152
+ target.comment.removeTags("@remarks");
153
+ target.comment.removeTags("@returns");
152
154
  target.comment.summary = Comment.cloneDisplayParts(source.comment.summary);
153
155
  const remarks = source.comment.getTag("@remarks");
154
156
  if (remarks) {
@@ -1,6 +1,5 @@
1
1
  import { ConverterComponent } from "../components.js";
2
2
  import type { Converter } from "../converter.js";
3
- import { type NormalizedPath } from "#utils";
4
3
  /**
5
4
  * A handler that attaches source file information to reflections.
6
5
  */
@@ -10,7 +9,7 @@ export declare class SourcePlugin extends ConverterComponent {
10
9
  accessor gitRemote: string;
11
10
  accessor disableGit: boolean;
12
11
  accessor sourceLinkTemplate: string;
13
- accessor basePath: NormalizedPath;
12
+ get displayBasePath(): import("#utils").NormalizedPath;
14
13
  /**
15
14
  * All file names to find the base path from.
16
15
  */
@@ -62,9 +62,6 @@ let SourcePlugin = (() => {
62
62
  let _sourceLinkTemplate_decorators;
63
63
  let _sourceLinkTemplate_initializers = [];
64
64
  let _sourceLinkTemplate_extraInitializers = [];
65
- let _basePath_decorators;
66
- let _basePath_initializers = [];
67
- let _basePath_extraInitializers = [];
68
65
  return class SourcePlugin extends _classSuper {
69
66
  static {
70
67
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
@@ -73,13 +70,11 @@ let SourcePlugin = (() => {
73
70
  _gitRemote_decorators = [Option("gitRemote")];
74
71
  _disableGit_decorators = [Option("disableGit")];
75
72
  _sourceLinkTemplate_decorators = [Option("sourceLinkTemplate")];
76
- _basePath_decorators = [Option("basePath")];
77
73
  __esDecorate(this, null, _disableSources_decorators, { kind: "accessor", name: "disableSources", static: false, private: false, access: { has: obj => "disableSources" in obj, get: obj => obj.disableSources, set: (obj, value) => { obj.disableSources = value; } }, metadata: _metadata }, _disableSources_initializers, _disableSources_extraInitializers);
78
74
  __esDecorate(this, null, _gitRevision_decorators, { kind: "accessor", name: "gitRevision", static: false, private: false, access: { has: obj => "gitRevision" in obj, get: obj => obj.gitRevision, set: (obj, value) => { obj.gitRevision = value; } }, metadata: _metadata }, _gitRevision_initializers, _gitRevision_extraInitializers);
79
75
  __esDecorate(this, null, _gitRemote_decorators, { kind: "accessor", name: "gitRemote", static: false, private: false, access: { has: obj => "gitRemote" in obj, get: obj => obj.gitRemote, set: (obj, value) => { obj.gitRemote = value; } }, metadata: _metadata }, _gitRemote_initializers, _gitRemote_extraInitializers);
80
76
  __esDecorate(this, null, _disableGit_decorators, { kind: "accessor", name: "disableGit", static: false, private: false, access: { has: obj => "disableGit" in obj, get: obj => obj.disableGit, set: (obj, value) => { obj.disableGit = value; } }, metadata: _metadata }, _disableGit_initializers, _disableGit_extraInitializers);
81
77
  __esDecorate(this, null, _sourceLinkTemplate_decorators, { kind: "accessor", name: "sourceLinkTemplate", static: false, private: false, access: { has: obj => "sourceLinkTemplate" in obj, get: obj => obj.sourceLinkTemplate, set: (obj, value) => { obj.sourceLinkTemplate = value; } }, metadata: _metadata }, _sourceLinkTemplate_initializers, _sourceLinkTemplate_extraInitializers);
82
- __esDecorate(this, null, _basePath_decorators, { kind: "accessor", name: "basePath", static: false, private: false, access: { has: obj => "basePath" in obj, get: obj => obj.basePath, set: (obj, value) => { obj.basePath = value; } }, metadata: _metadata }, _basePath_initializers, _basePath_extraInitializers);
83
78
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
84
79
  }
85
80
  #disableSources_accessor_storage = __runInitializers(this, _disableSources_initializers, void 0);
@@ -97,13 +92,13 @@ let SourcePlugin = (() => {
97
92
  #sourceLinkTemplate_accessor_storage = (__runInitializers(this, _disableGit_extraInitializers), __runInitializers(this, _sourceLinkTemplate_initializers, void 0));
98
93
  get sourceLinkTemplate() { return this.#sourceLinkTemplate_accessor_storage; }
99
94
  set sourceLinkTemplate(value) { this.#sourceLinkTemplate_accessor_storage = value; }
100
- #basePath_accessor_storage = (__runInitializers(this, _sourceLinkTemplate_extraInitializers), __runInitializers(this, _basePath_initializers, void 0));
101
- get basePath() { return this.#basePath_accessor_storage; }
102
- set basePath(value) { this.#basePath_accessor_storage = value; }
95
+ get displayBasePath() {
96
+ return this.application.options.getValue("displayBasePath") || this.application.options.getValue("basePath");
97
+ }
103
98
  /**
104
99
  * All file names to find the base path from.
105
100
  */
106
- fileNames = (__runInitializers(this, _basePath_extraInitializers), new Set());
101
+ fileNames = (__runInitializers(this, _sourceLinkTemplate_extraInitializers), new Set());
107
102
  repositories;
108
103
  constructor(owner) {
109
104
  super(owner);
@@ -170,7 +165,7 @@ let SourcePlugin = (() => {
170
165
  !this.gitRevision) {
171
166
  this.application.logger.warn(i18n.disable_git_set_and_git_revision_used());
172
167
  }
173
- const basePath = this.basePath || getCommonDirectory([...this.fileNames]);
168
+ const basePath = this.displayBasePath || getCommonDirectory([...this.fileNames]);
174
169
  this.repositories ||= new RepositoryManager(basePath, this.gitRevision, this.gitRemote, this.sourceLinkTemplate, this.disableGit, this.application.logger);
175
170
  for (const id in context.project.reflections) {
176
171
  const refl = context.project.reflections[id];
@@ -754,6 +754,13 @@ function convertAccessor(context, symbol, exportSymbol) {
754
754
  const declaration = symbol.getDeclarations()?.[0];
755
755
  if (declaration) {
756
756
  setModifiers(symbol, declaration, reflection);
757
+ // #3019, auto accessors `accessor x: string` get the symbol flag for
758
+ // an accessor, but they don't have get/set accessors, so the need a type
759
+ // set on the accessor reflection structure.
760
+ if (ts.isPropertyDeclaration(declaration) &&
761
+ declaration.modifiers?.some(n => n.kind === ts.SyntaxKind.AccessorKeyword)) {
762
+ reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getTypeOfSymbol(symbol), declaration.type);
763
+ }
757
764
  }
758
765
  context.finalizeDeclarationReflection(reflection);
759
766
  const getDeclaration = symbol.getDeclarations()?.find(ts.isGetAccessor);
@@ -410,7 +410,7 @@ const queryConverter = {
410
410
  if (!querySymbol) {
411
411
  // This can happen if someone uses `typeof` on some property
412
412
  // on a variable typed as `any` with a name that doesn't exist.
413
- return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project));
413
+ return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project, undefined));
414
414
  }
415
415
  const ref = context.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText());
416
416
  ref.preferValues = true;
@@ -454,7 +454,7 @@ const referenceConverter = {
454
454
  if (!symbol) {
455
455
  // This happens when we get a reference to a type parameter
456
456
  // created within a mapped type, `K` in: `{ [K in T]: string }`
457
- const ref = ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
457
+ const ref = ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project, undefined);
458
458
  ref.refersToTypeParameter = true;
459
459
  return ref;
460
460
  }
@@ -696,7 +696,7 @@ const unionConverter = {
696
696
  convertType(context, type) {
697
697
  const types = type.types.map((type) => convertType(context, type));
698
698
  normalizeUnion(types);
699
- sortLiteralUnion(types);
699
+ sortUnion(types);
700
700
  return new UnionType(types);
701
701
  },
702
702
  };
@@ -764,14 +764,26 @@ function kindToModifier(kind) {
764
764
  return undefined;
765
765
  }
766
766
  }
767
- function sortLiteralUnion(types) {
768
- if (types.some((t) => t.type !== "literal" || typeof t.value !== "number")) {
767
+ function sortUnion(types) {
768
+ // If every member of the union is a literal numeric type, sort in ascending order
769
+ if (types.every(t => t.type === "literal" && typeof t.value === "number")) {
770
+ types.sort((a, b) => {
771
+ const aLit = a;
772
+ const bLit = b;
773
+ return aLit.value - bLit.value;
774
+ });
769
775
  return;
770
776
  }
777
+ // #3024 Otherwise, leave the union in the converted order with the exception of null
778
+ // and undefined, which should be sorted last, with null before undefined.
771
779
  types.sort((a, b) => {
772
- const aLit = a;
773
- const bLit = b;
774
- return aLit.value - bLit.value;
780
+ const aIsNull = a.type === "literal" && a.value === null;
781
+ const aIsUndef = a.type === "intrinsic" && a.name === "undefined";
782
+ const bIsNull = b.type === "literal" && b.value === null;
783
+ const bIsUndef = b.type === "intrinsic" && b.name === "undefined";
784
+ const aWeight = aIsNull ? 1 : aIsUndef ? 2 : 0;
785
+ const bWeight = bIsNull ? 1 : bIsUndef ? 2 : 0;
786
+ return aWeight - bWeight;
775
787
  });
776
788
  }
777
789
  function normalizeUnion(types) {
@@ -165,7 +165,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
165
165
  help_excludeNotDocumentedKinds: "Arten von Reflections, die von excludeNotDocumented entfernt werden können",
166
166
  help_excludeInternal: "Verhindert, dass Symbole in der Dokumentation erscheinen, die mit @internal markiert sind",
167
167
  help_excludeCategories: "Schließt Symbole aus dieser Kategorie von der Dokumentation aus",
168
- help_excludePrivate: "Ignoriert private Variablen und Methoden, Standardwert ist true.",
169
168
  help_excludeProtected: "Ignoriert geschützte Variablen und Methoden",
170
169
  help_excludeReferences: "Wird ein Symbol mehrfach exportiert, ignoriere alle außer dem ersten Export",
171
170
  help_externalSymbolLinkMappings: "Definiert eigene Links für Symbole, die nicht in der Dokumentation enthalten sind",
@@ -150,7 +150,6 @@ declare const _default: {
150
150
  help_excludeNotDocumentedKinds: string;
151
151
  help_excludeInternal: string;
152
152
  help_excludeCategories: string;
153
- help_excludePrivate: string;
154
153
  help_excludeProtected: string;
155
154
  help_excludeReferences: string;
156
155
  help_externalSymbolLinkMappings: string;
@@ -45,6 +45,7 @@ module.exports = {
45
45
  at_most_one_inheritdoc_tag_expected_in_comment_at_0: "At most one @inheritDoc tag is expected in a comment, ignoring all but the first in comment at {0}",
46
46
  content_in_summary_overwritten_by_inheritdoc_in_comment_at_0: "Content in the summary section will be overwritten by the @inheritDoc tag in comment at {0}",
47
47
  content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @remarks block will be overwritten by the @inheritDoc tag in comment at {0}",
48
+ content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @returns block will be overwritten by the @inheritDoc tag in comment at {0}",
48
49
  example_tag_literal_name: "The first line of an example tag will be taken literally as the example name, and should only contain text",
49
50
  inheritdoc_tag_properly_capitalized: "The @inheritDoc tag should be properly capitalized",
50
51
  treating_unrecognized_tag_0_as_modifier: `Treating unrecognized tag {0} as a modifier tag`,
@@ -167,7 +168,8 @@ module.exports = {
167
168
  help_excludeNotDocumentedKinds: "Specify the type of reflections that can be removed by excludeNotDocumented",
168
169
  help_excludeInternal: "Prevent symbols that are marked with @internal from being documented",
169
170
  help_excludeCategories: "Exclude symbols within this category from the documentation",
170
- help_excludePrivate: "Ignore private variables and methods, defaults to true.",
171
+ help_excludePrivate: "Ignore members marked with the private keyword and #private class fields, defaults to true.",
172
+ help_excludePrivateClassFields: "Ignore #private class fields, defaults to true.",
171
173
  help_excludeProtected: "Ignore protected variables and methods",
172
174
  help_excludeReferences: "If a symbol is exported multiple times, ignore all but the first export",
173
175
  help_externalSymbolLinkMappings: "Define custom links for symbols not included in the documentation",
@@ -195,11 +197,13 @@ module.exports = {
195
197
  help_gitRevision: "Use specified revision instead of the last revision for linking to GitHub/Bitbucket source files. Has no effect if disableSources is set",
196
198
  help_gitRemote: "Use the specified remote for linking to GitHub/Bitbucket source files. Has no effect if disableGit or disableSources is set",
197
199
  help_disableGit: "Assume that all can be linked to with the sourceLinkTemplate, sourceLinkTemplate must be set if this is enabled. {path} will be rooted at basePath",
198
- help_basePath: "Specifies the base path to be used when displaying file paths",
200
+ help_displayBasePath: "Specifies the base path to be used when displaying file paths. If not specified, basePath is used.",
199
201
  help_excludeTags: "Remove the listed block/modifier tags from doc comments",
200
202
  help_notRenderedTags: "Tags which will be preserved in doc comments, but not rendered when creating output",
201
203
  help_cascadedModifierTags: "Modifier tags which should be copied to all children of the parent reflection",
204
+ help_preservedTypeAnnotationTags: "Block tags whose type annotations should be preserved in the output.",
202
205
  help_readme: "Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page",
206
+ help_basePath: "Specifies a path which links may be resolved relative to.",
203
207
  help_cname: "Set the CNAME file text, it's useful for custom domains on GitHub Pages",
204
208
  help_favicon: "Path to favicon to include as the site icon",
205
209
  help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab",
@@ -41,6 +41,7 @@ declare const _default: {
41
41
  readonly at_most_one_inheritdoc_tag_expected_in_comment_at_0: "At most one @inheritDoc tag is expected in a comment, ignoring all but the first in comment at {0}";
42
42
  readonly content_in_summary_overwritten_by_inheritdoc_in_comment_at_0: "Content in the summary section will be overwritten by the @inheritDoc tag in comment at {0}";
43
43
  readonly content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @remarks block will be overwritten by the @inheritDoc tag in comment at {0}";
44
+ readonly content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @returns block will be overwritten by the @inheritDoc tag in comment at {0}";
44
45
  readonly example_tag_literal_name: "The first line of an example tag will be taken literally as the example name, and should only contain text";
45
46
  readonly inheritdoc_tag_properly_capitalized: "The @inheritDoc tag should be properly capitalized";
46
47
  readonly treating_unrecognized_tag_0_as_modifier: "Treating unrecognized tag {0} as a modifier tag";
@@ -154,7 +155,8 @@ declare const _default: {
154
155
  readonly help_excludeNotDocumentedKinds: "Specify the type of reflections that can be removed by excludeNotDocumented";
155
156
  readonly help_excludeInternal: "Prevent symbols that are marked with @internal from being documented";
156
157
  readonly help_excludeCategories: "Exclude symbols within this category from the documentation";
157
- readonly help_excludePrivate: "Ignore private variables and methods, defaults to true.";
158
+ readonly help_excludePrivate: "Ignore members marked with the private keyword and #private class fields, defaults to true.";
159
+ readonly help_excludePrivateClassFields: "Ignore #private class fields, defaults to true.";
158
160
  readonly help_excludeProtected: "Ignore protected variables and methods";
159
161
  readonly help_excludeReferences: "If a symbol is exported multiple times, ignore all but the first export";
160
162
  readonly help_externalSymbolLinkMappings: "Define custom links for symbols not included in the documentation";
@@ -182,11 +184,13 @@ declare const _default: {
182
184
  readonly help_gitRevision: "Use specified revision instead of the last revision for linking to GitHub/Bitbucket source files. Has no effect if disableSources is set";
183
185
  readonly help_gitRemote: "Use the specified remote for linking to GitHub/Bitbucket source files. Has no effect if disableGit or disableSources is set";
184
186
  readonly help_disableGit: "Assume that all can be linked to with the sourceLinkTemplate, sourceLinkTemplate must be set if this is enabled. {path} will be rooted at basePath";
185
- readonly help_basePath: "Specifies the base path to be used when displaying file paths";
187
+ readonly help_displayBasePath: "Specifies the base path to be used when displaying file paths. If not specified, basePath is used.";
186
188
  readonly help_excludeTags: "Remove the listed block/modifier tags from doc comments";
187
189
  readonly help_notRenderedTags: "Tags which will be preserved in doc comments, but not rendered when creating output";
188
190
  readonly help_cascadedModifierTags: "Modifier tags which should be copied to all children of the parent reflection";
191
+ readonly help_preservedTypeAnnotationTags: "Block tags whose type annotations should be preserved in the output.";
189
192
  readonly help_readme: "Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page";
193
+ readonly help_basePath: "Specifies a path which links may be resolved relative to.";
190
194
  readonly help_cname: "Set the CNAME file text, it's useful for custom domains on GitHub Pages";
191
195
  readonly help_favicon: "Path to favicon to include as the site icon";
192
196
  readonly help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab";
@@ -129,7 +129,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
129
129
  help_excludeNotDocumentedKinds: "excludeNotDocumented によって削除できる反射の種類を指定します",
130
130
  help_excludeInternal: "@internal でマークされたシンボルがドキュメント化されないようにする",
131
131
  help_excludeCategories: "このカテゴリ内のシンボルをドキュメントから除外する",
132
- help_excludePrivate: "プライベート変数とメソッドを無視します。デフォルトは true です。",
133
132
  help_excludeProtected: "保護された変数とメソッドを無視する",
134
133
  help_excludeReferences: "シンボルが複数回エクスポートされた場合、最初のエクスポート以外はすべて無視されます。",
135
134
  help_externalSymbolLinkMappings: "ドキュメントに含まれていないシンボルのカスタムリンクを定義する",
@@ -119,7 +119,6 @@ declare const _default: {
119
119
  help_excludeNotDocumentedKinds: string;
120
120
  help_excludeInternal: string;
121
121
  help_excludeCategories: string;
122
- help_excludePrivate: string;
123
122
  help_excludeProtected: string;
124
123
  help_excludeReferences: string;
125
124
  help_externalSymbolLinkMappings: string;
@@ -47,7 +47,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
47
47
  help_excludeNotDocumentedKinds: "excludeNotDocumented로 제거될 리플렉션 유형을 지정합니다",
48
48
  help_excludeInternal: "@internal로 표시된 심볼이 문서화되지 않도록 방지합니다",
49
49
  help_excludeCategories: "문서에서 제외할 카테고리 내의 심볼을 제외합니다",
50
- help_excludePrivate: "비공개 변수와 메서드를 무시합니다. 기본값은 true입니다.",
51
50
  help_excludeProtected: "보호된 변수와 메서드를 무시합니다",
52
51
  help_excludeReferences: "심볼이 여러 번 내보내진 경우 첫 번째 내보내기를 제외하고 모두 무시합니다",
53
52
  help_externalSymbolLinkMappings: "문서에 포함되지 않은 심볼에 대한 사용자 정의 링크를 정의합니다",
@@ -39,7 +39,6 @@ declare const _default: {
39
39
  help_excludeNotDocumentedKinds: string;
40
40
  help_excludeInternal: string;
41
41
  help_excludeCategories: string;
42
- help_excludePrivate: string;
43
42
  help_excludeProtected: string;
44
43
  help_excludeReferences: string;
45
44
  help_externalSymbolLinkMappings: string;
@@ -167,7 +167,6 @@ module.exports = localeUtils.buildIncompleteTranslation({
167
167
  help_excludeNotDocumentedKinds: "指定可以通过 excludeNotDocumented 删除的反射类型",
168
168
  help_excludeInternal: "防止标有 @internal 的符号被记录",
169
169
  help_excludeCategories: "从文档中排除此类别中的符号",
170
- help_excludePrivate: "忽略私有变量和方法,默认为 true。",
171
170
  help_excludeProtected: "忽略受保护的变量和方法",
172
171
  help_excludeReferences: "如果一个符号被导出多次,则忽略除第一次导出之外的所有导出",
173
172
  help_externalSymbolLinkMappings: "为文档中未包含的符号定义自定义链接",
@@ -152,7 +152,6 @@ declare const _default: {
152
152
  help_excludeNotDocumentedKinds: string;
153
153
  help_excludeInternal: string;
154
154
  help_excludeCategories: string;
155
- help_excludePrivate: string;
156
155
  help_excludeProtected: string;
157
156
  help_excludeReferences: string;
158
157
  help_externalSymbolLinkMappings: string;
@@ -85,6 +85,11 @@ export declare class CommentTag {
85
85
  * If this tag is one of those, it will be parsed out and included here.
86
86
  */
87
87
  name?: string;
88
+ /**
89
+ * Optional type annotation associated with this tag. TypeDoc will remove type annotations unless explicitly
90
+ * requested by the user with the `preservedTypeAnnotationTags` option.
91
+ */
92
+ typeAnnotation?: string;
88
93
  /**
89
94
  * The actual body text of this tag.
90
95
  */
@@ -50,6 +50,11 @@ export class CommentTag {
50
50
  * If this tag is one of those, it will be parsed out and included here.
51
51
  */
52
52
  name;
53
+ /**
54
+ * Optional type annotation associated with this tag. TypeDoc will remove type annotations unless explicitly
55
+ * requested by the user with the `preservedTypeAnnotationTags` option.
56
+ */
57
+ typeAnnotation;
53
58
  /**
54
59
  * The actual body text of this tag.
55
60
  */
@@ -83,6 +88,9 @@ export class CommentTag {
83
88
  if (this.name) {
84
89
  tag.name = this.name;
85
90
  }
91
+ if (this.typeAnnotation) {
92
+ tag.typeAnnotation = this.typeAnnotation;
93
+ }
86
94
  return tag;
87
95
  }
88
96
  toObject() {
@@ -90,11 +98,13 @@ export class CommentTag {
90
98
  tag: this.tag,
91
99
  name: this.name,
92
100
  content: Comment.serializeDisplayParts(this.content),
101
+ typeAnnotation: this.typeAnnotation,
93
102
  };
94
103
  }
95
104
  fromObject(de, obj) {
96
105
  // tag already set by Comment.fromObject
97
106
  this.name = obj.name;
107
+ this.typeAnnotation = obj.typeAnnotation;
98
108
  this.content = Comment.deserializeDisplayParts(de, obj.content);
99
109
  }
100
110
  }
@@ -393,7 +393,7 @@ export declare class ReferenceType extends Type {
393
393
  * later during conversion.
394
394
  * @internal
395
395
  */
396
- static createBrokenReference(name: string, project: ProjectReflection): ReferenceType;
396
+ static createBrokenReference(name: string, project: ProjectReflection, packageName: string | undefined): ReferenceType;
397
397
  protected getTypeString(): string;
398
398
  needsParenthesis(): boolean;
399
399
  toObject(serializer: Serializer): JSONOutput.ReferenceType;
@@ -833,8 +833,10 @@ let ReferenceType = (() => {
833
833
  * later during conversion.
834
834
  * @internal
835
835
  */
836
- static createBrokenReference(name, project) {
837
- return new ReferenceType(name, -1, project, name);
836
+ static createBrokenReference(name, project, packageName) {
837
+ const ref = new ReferenceType(name, -1, project, name);
838
+ ref.package = packageName;
839
+ return ref;
838
840
  }
839
841
  getTypeString() {
840
842
  const name = this.reflection ? this.reflection.name : this.name;
@@ -387,10 +387,17 @@ let MarkedPlugin = (() => {
387
387
  })();
388
388
  export { MarkedPlugin };
389
389
  function getTokenTextContent(token) {
390
+ // If there are children, we want their text content, not the full text content
390
391
  if (token.children) {
391
392
  return token.children.map(getTokenTextContent).join("");
392
393
  }
393
- return token.content;
394
+ // If this is a simple text fragment, use its content
395
+ if (token.type === "text") {
396
+ return token.content;
397
+ }
398
+ // Otherwise this is some type of metadata token (e.g. header_open)
399
+ // or a HTML tag token. Don't include it in the text content.
400
+ return "";
394
401
  }
395
402
  const kindNames = ["note", "tip", "important", "warning", "caution"];
396
403
  const iconNames = ["alertNote", "alertTip", "alertImportant", "alertWarning", "alertCaution"];
@@ -1,4 +1,4 @@
1
- import type { TypeDocOptionMap } from "../../../utils/index.js";
1
+ import type { TypeDocOptionMap } from "#node-utils";
2
2
  /**
3
3
  * Responsible for getting a unique anchor for elements within a page.
4
4
  */
@@ -6,15 +6,23 @@ export class Slugger {
6
6
  options;
7
7
  seen = new Map();
8
8
  serialize(value) {
9
- // Notes:
10
- // There are quite a few trade-offs here.
9
+ // There are quite a few trade-offs here. We used to remove HTML tags here,
10
+ // but TypeDoc now removes the HTML tags before passing text into the slug
11
+ // method, which allows us to skip doing that here. This improves the slugger
12
+ // generation for headers which look like the following:
13
+ // (html allowed in markdown)
14
+ // # test &lt;t&gt;
15
+ // (html disallowed in markdown)
16
+ // # test <t>
17
+ // both of the above should slug to test-t
11
18
  return (value
12
19
  .trim()
13
- // remove html tags
14
- .replace(/<[!/a-z].*?>/gi, "")
15
20
  // remove unwanted chars
16
21
  .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "")
17
- .replace(/\s/g, "-"));
22
+ // change whitespace to dash
23
+ .replace(/\s/g, "-")
24
+ // combine adjacent dashes
25
+ .replace(/--+/, "-"));
18
26
  }
19
27
  constructor(options) {
20
28
  this.options = options;
@@ -58,6 +58,7 @@ export function commentTags(context, props) {
58
58
  JSX.createElement("h4", { class: "tsd-anchor-link", id: anchor },
59
59
  name,
60
60
  anchorIcon(context, anchor)),
61
+ item.typeAnnotation && JSX.createElement("span", { class: "tsd-type-annotation" }, item.typeAnnotation),
61
62
  JSX.createElement(JSX.Raw, { html: context.markdown(item.content) }))));
62
63
  });
63
64
  return (JSX.createElement(JSX.Fragment, null,
@@ -1,4 +1,4 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext.js";
2
- import { type Type } from "../../../../models/index.js";
2
+ import { type Type } from "#models";
3
3
  import { JSX } from "#utils";
4
4
  export declare const typeAndParent: (context: DefaultThemeRenderContext, props: Type) => JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ArrayType, ReferenceType, SignatureReflection } from "../../../../models/index.js";
1
+ import { ArrayType, ReferenceType, SignatureReflection } from "#models";
2
2
  import { JSX } from "#utils";
3
3
  export const typeAndParent = (context, props) => {
4
4
  if (props instanceof ArrayType) {
@@ -6,13 +6,23 @@ export const typeAndParent = (context, props) => {
6
6
  context.typeAndParent(props.elementType),
7
7
  "[]"));
8
8
  }
9
- if (props instanceof ReferenceType && props.reflection) {
10
- const refl = props.reflection instanceof SignatureReflection ? props.reflection.parent : props.reflection;
11
- const parent = refl.parent;
12
- return (JSX.createElement(JSX.Fragment, null,
13
- JSX.createElement("a", { href: context.urlTo(parent) }, parent.name),
14
- ".",
15
- JSX.createElement("a", { href: context.urlTo(refl) }, refl.name)));
9
+ if (props instanceof ReferenceType) {
10
+ if (props.reflection) {
11
+ const refl = props.reflection instanceof SignatureReflection ? props.reflection.parent : props.reflection;
12
+ const parent = refl.parent;
13
+ return (JSX.createElement(JSX.Fragment, null,
14
+ JSX.createElement("a", { href: context.urlTo(parent) }, parent.name),
15
+ ".",
16
+ JSX.createElement("a", { href: context.urlTo(refl) }, refl.name)));
17
+ }
18
+ else if (props.externalUrl) {
19
+ if (props.externalUrl === "#") {
20
+ return JSX.createElement(JSX.Fragment, null, props.toString());
21
+ }
22
+ else {
23
+ return JSX.createElement("a", { href: props.externalUrl, class: "external", target: "_blank" }, props.name);
24
+ }
25
+ }
16
26
  }
17
27
  return JSX.createElement(JSX.Fragment, null, props.toString());
18
28
  };
@@ -226,7 +226,7 @@ export interface Comment extends Partial<S<M.Comment, "blockTags" | "label">> {
226
226
  modifierTags?: TagString[];
227
227
  }
228
228
  /** @category Comments */
229
- export interface CommentTag extends S<M.CommentTag, "tag" | "name"> {
229
+ export interface CommentTag extends S<M.CommentTag, "tag" | "name" | "typeAnnotation"> {
230
230
  content: CommentDisplayPart[];
231
231
  }
232
232
  /**
@@ -2,6 +2,8 @@ import { type FileId, FileRegistry } from "../models/FileRegistry.js";
2
2
  import type { Deserializer, JSONOutput } from "#serialization";
3
3
  import { type NormalizedPath } from "#utils";
4
4
  export declare class ValidatingFileRegistry extends FileRegistry {
5
+ basePath: NormalizedPath;
6
+ constructor(basePath?: NormalizedPath);
5
7
  register(sourcePath: NormalizedPath, relativePath: NormalizedPath): {
6
8
  target: FileId;
7
9
  anchor: string | undefined;
@@ -2,14 +2,29 @@ import { FileRegistry } from "../models/FileRegistry.js";
2
2
  import { i18n, NormalizedPathUtils } from "#utils";
3
3
  import { existsSync } from "fs";
4
4
  export class ValidatingFileRegistry extends FileRegistry {
5
+ basePath;
6
+ constructor(basePath = "") {
7
+ super();
8
+ this.basePath = basePath;
9
+ }
5
10
  register(sourcePath, relativePath) {
6
- const absolute = NormalizedPathUtils.resolve(NormalizedPathUtils.dirname(sourcePath), relativePath);
7
- const absoluteWithoutAnchor = absolute.replace(/#.*/, "");
11
+ let absolute = NormalizedPathUtils.resolve(NormalizedPathUtils.dirname(sourcePath), relativePath);
12
+ let absoluteWithoutAnchor = absolute.replace(/#.*/, "");
8
13
  // Note: We allow paths to directories to be registered here, but the AssetsPlugin will not
9
14
  // copy them to the output path. This is so that we can link to directories and associate them
10
15
  // with reflections in packages mode.
11
16
  if (!existsSync(absoluteWithoutAnchor)) {
12
- return;
17
+ // If the relative path didn't exist normally, also check the path relative to the assetBasePath option
18
+ if (this.basePath != "") {
19
+ absolute = NormalizedPathUtils.resolve(this.basePath, relativePath);
20
+ absoluteWithoutAnchor = absolute.replace(/#.*/, "");
21
+ if (!existsSync(absoluteWithoutAnchor)) {
22
+ return;
23
+ }
24
+ }
25
+ else {
26
+ return;
27
+ }
13
28
  }
14
29
  return this.registerAbsolute(absolute);
15
30
  }
@@ -124,7 +124,7 @@ export function getDocumentEntryPoints(logger, options) {
124
124
  // that have at some point or another been used for markdown: https://superuser.com/a/285878
125
125
  const supportedFileRegex = /\.(md|markdown)$/;
126
126
  const expanded = expandInputFiles(logger, docPaths, options, supportedFileRegex);
127
- const baseDir = options.getValue("basePath") || getCommonDirectory(expanded);
127
+ const baseDir = options.getValue("displayBasePath") || options.getValue("basePath") || getCommonDirectory(expanded);
128
128
  return expanded.map((path) => {
129
129
  return {
130
130
  displayName: relative(baseDir, path).replace(/\.[^.]+$/, ""),
@@ -184,7 +184,8 @@ function getModuleName(fileName, baseDir) {
184
184
  * This is in contrast with the package-oriented `getEntryPointsForPackages`
185
185
  */
186
186
  function getEntryPointsForPaths(logger, inputFiles, options, programs = getEntryPrograms(inputFiles, logger, options)) {
187
- const baseDir = options.getValue("basePath") || getCommonDirectory(inputFiles);
187
+ const baseDir = options.getValue("displayBasePath") || options.getValue("basePath") ||
188
+ getCommonDirectory(inputFiles);
188
189
  const entryPoints = [];
189
190
  let expandSuggestion = true;
190
191
  entryLoop: for (const fileOrDir of inputFiles.map(normalizePath)) {
@@ -93,6 +93,7 @@ export interface TypeDocOptionMap {
93
93
  excludeNotDocumented: boolean;
94
94
  excludeNotDocumentedKinds: ReflectionKind.KindString[];
95
95
  excludeInternal: boolean;
96
+ excludePrivateClassFields: boolean;
96
97
  excludePrivate: boolean;
97
98
  excludeProtected: boolean;
98
99
  excludeReferences: boolean;
@@ -108,6 +109,7 @@ export interface TypeDocOptionMap {
108
109
  gitRevision: string;
109
110
  gitRemote: string;
110
111
  readme: string;
112
+ basePath: NormalizedPath;
111
113
  outputs: ManuallyValidatedOption<Array<OutputSpecification>>;
112
114
  out: NormalizedPath;
113
115
  html: NormalizedPath;
@@ -145,7 +147,7 @@ export interface TypeDocOptionMap {
145
147
  * strictly typed here.
146
148
  */
147
149
  markdownItLoader: ManuallyValidatedOption<(parser: any) => void>;
148
- basePath: NormalizedPath;
150
+ displayBasePath: NormalizedPath;
149
151
  cname: string;
150
152
  favicon: NormalizedPath;
151
153
  githubPages: boolean;
@@ -199,6 +201,7 @@ export interface TypeDocOptionMap {
199
201
  notRenderedTags: TagString[];
200
202
  externalSymbolLinkMappings: ManuallyValidatedOption<Record<string, Record<string, string>>>;
201
203
  cascadedModifierTags: TagString[];
204
+ preservedTypeAnnotationTags: TagString[];
202
205
  categorizeByGroup: boolean;
203
206
  groupReferencesByType: boolean;
204
207
  defaultCategory: string;
@@ -11,6 +11,7 @@ export declare const blockTags: readonly TagString[];
11
11
  export declare const inlineTags: readonly TagString[];
12
12
  export declare const modifierTags: readonly TagString[];
13
13
  export declare const cascadedModifierTags: readonly TagString[];
14
+ export declare const preservedTypeAnnotationTags: readonly TagString[];
14
15
  export declare const notRenderedTags: readonly TagString[];
15
16
  export declare const highlightLanguages: readonly BundledLanguage[];
16
17
  export declare const ignoredHighlightLanguages: readonly string[];
@@ -37,6 +37,7 @@ export const cascadedModifierTags = [
37
37
  "@beta",
38
38
  "@experimental",
39
39
  ];
40
+ export const preservedTypeAnnotationTags = [];
40
41
  export const notRenderedTags = [
41
42
  "@showCategories",
42
43
  "@showGroups",
@@ -16,9 +16,7 @@ function makeTagArrayValidator(name) {
16
16
  }
17
17
  // For convenience, added in the same order as they are documented on the website.
18
18
  export function addTypeDocOptions(options) {
19
- ///////////////////////////
20
- // Configuration Options //
21
- ///////////////////////////
19
+ // MARK: Configuration Options
22
20
  options.addDeclaration({
23
21
  type: ParameterType.Path,
24
22
  name: "options",
@@ -84,9 +82,7 @@ export function addTypeDocOptions(options) {
84
82
  }
85
83
  },
86
84
  });
87
- ///////////////////////////
88
- ////// Input Options //////
89
- ///////////////////////////
85
+ // MARK: Input Options
90
86
  options.addDeclaration({
91
87
  name: "entryPoints",
92
88
  help: () => i18n.help_entryPoints(),
@@ -171,6 +167,12 @@ export function addTypeDocOptions(options) {
171
167
  type: ParameterType.Boolean,
172
168
  defaultValue: true,
173
169
  });
170
+ options.addDeclaration({
171
+ name: "excludePrivateClassFields",
172
+ help: () => i18n.help_excludePrivateClassFields(),
173
+ type: ParameterType.Boolean,
174
+ defaultValue: true,
175
+ });
174
176
  options.addDeclaration({
175
177
  name: "excludeProtected",
176
178
  help: () => i18n.help_excludeProtected(),
@@ -202,9 +204,17 @@ export function addTypeDocOptions(options) {
202
204
  }
203
205
  },
204
206
  });
205
- ///////////////////////////
206
- ///// Output Options //////
207
- ///////////////////////////
207
+ options.addDeclaration({
208
+ name: "readme",
209
+ help: () => i18n.help_readme(),
210
+ type: ParameterType.Path,
211
+ });
212
+ options.addDeclaration({
213
+ name: "basePath",
214
+ help: () => i18n.help_basePath(),
215
+ type: ParameterType.Path,
216
+ });
217
+ // MARK: Output Options
208
218
  options.addDeclaration({
209
219
  name: "outputs",
210
220
  help: () => i18n.help_out(),
@@ -396,13 +406,8 @@ export function addTypeDocOptions(options) {
396
406
  type: ParameterType.Boolean,
397
407
  });
398
408
  options.addDeclaration({
399
- name: "basePath",
400
- help: () => i18n.help_basePath(),
401
- type: ParameterType.Path,
402
- });
403
- options.addDeclaration({
404
- name: "readme",
405
- help: () => i18n.help_readme(),
409
+ name: "displayBasePath",
410
+ help: () => i18n.help_displayBasePath(),
406
411
  type: ParameterType.Path,
407
412
  });
408
413
  options.addDeclaration({
@@ -622,9 +627,7 @@ export function addTypeDocOptions(options) {
622
627
  help: () => i18n.help_useFirstParagraphOfCommentAsSummary(),
623
628
  type: ParameterType.Boolean,
624
629
  });
625
- ///////////////////////////
626
- ///// Comment Options /////
627
- ///////////////////////////
630
+ // MARK: Comment Options
628
631
  options.addDeclaration({
629
632
  name: "jsDocCompatibility",
630
633
  help: () => i18n.help_jsDocCompatibility(),
@@ -703,9 +706,14 @@ export function addTypeDocOptions(options) {
703
706
  defaultValue: OptionDefaults.cascadedModifierTags,
704
707
  validate: makeTagArrayValidator("cascadedModifierTags"),
705
708
  });
706
- ///////////////////////////
707
- // Organization Options ///
708
- ///////////////////////////
709
+ options.addDeclaration({
710
+ name: "preservedTypeAnnotationTags",
711
+ help: () => i18n.help_preservedTypeAnnotationTags(),
712
+ type: ParameterType.Array,
713
+ defaultValue: OptionDefaults.preservedTypeAnnotationTags,
714
+ validate: makeTagArrayValidator("preservedTypeAnnotationTags"),
715
+ });
716
+ // MARK: Organization Options
709
717
  options.addDeclaration({
710
718
  name: "categorizeByGroup",
711
719
  help: () => i18n.help_categorizeByGroup(),
@@ -764,9 +772,7 @@ export function addTypeDocOptions(options) {
764
772
  }
765
773
  },
766
774
  });
767
- ///////////////////////////
768
- ///// General Options /////
769
- ///////////////////////////
775
+ // MARK: General Options
770
776
  options.addDeclaration({
771
777
  name: "watch",
772
778
  help: () => i18n.help_watch(),
@@ -1,5 +1,5 @@
1
1
  export declare const tsdocBlockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam"];
2
- export declare const blockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam", "@author", "@callback", "@category", "@categoryDescription", "@default", "@document", "@extends", "@augments", "@yields", "@group", "@groupDescription", "@import", "@inheritDoc", "@jsx", "@license", "@module", "@mergeModuleWith", "@prop", "@property", "@return", "@satisfies", "@since", "@sortStrategy", "@template", "@type", "@typedef", "@summary", "@preventInline", "@inlineType", "@preventExpand", "@expandType"];
2
+ export declare const blockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam", "@author", "@callback", "@category", "@categoryDescription", "@default", "@document", "@extends", "@augments", "@yields", "@group", "@groupDescription", "@import", "@inheritDoc", "@jsx", "@license", "@module", "@mergeModuleWith", "@prop", "@property", "@return", "@satisfies", "@since", "@sortStrategy", "@template", "@this", "@type", "@typedef", "@summary", "@preventInline", "@inlineType", "@preventExpand", "@expandType"];
3
3
  export declare const tsdocInlineTags: readonly ["@link", "@inheritDoc", "@label"];
4
4
  export declare const inlineTags: readonly ["@link", "@inheritDoc", "@label", "@linkcode", "@linkplain", "@include", "@includeCode"];
5
5
  export declare const tsdocModifierTags: readonly ["@alpha", "@beta", "@eventProperty", "@experimental", "@internal", "@override", "@packageDocumentation", "@public", "@readonly", "@sealed", "@virtual"];
@@ -37,6 +37,7 @@ export const blockTags = [
37
37
  "@since",
38
38
  "@sortStrategy",
39
39
  "@template", // Alias for @typeParam
40
+ "@this",
40
41
  "@type",
41
42
  "@typedef",
42
43
  "@summary",
@@ -6,6 +6,8 @@ export function assertNever(x) {
6
6
  }
7
7
  export function assert(x, message = "Assertion failed") {
8
8
  if (!x) {
9
+ // eslint-disable-next-line no-debugger
10
+ debugger;
9
11
  throw new Error(message);
10
12
  }
11
13
  }
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.12",
4
+ "version": "0.28.14",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {
@@ -111,9 +111,9 @@
111
111
  "test": "mocha --config .config/mocha.fast.json",
112
112
  "test:cov": "c8 -r lcov mocha --config .config/mocha.fast.json",
113
113
  "doc:c": "node bin/typedoc --tsconfig src/test/converter/tsconfig.json",
114
- "doc:cd": "node --inspect-brk bin/typedoc --tsconfig src/test/converter/tsconfig.json",
114
+ "doc:cd": "node --inspect-brk dist/lib/cli.js --tsconfig src/test/converter/tsconfig.json",
115
115
  "doc:c2": "node bin/typedoc --options src/test/converter2 --tsconfig src/test/converter2/tsconfig.json",
116
- "doc:c2d": "node --inspect-brk bin/typedoc --options src/test/converter2 --tsconfig src/test/converter2/tsconfig.json",
116
+ "doc:c2d": "node --inspect-brk dist/lib/cli.js --options src/test/converter2 --tsconfig src/test/converter2/tsconfig.json",
117
117
  "example": "cd example && node ../bin/typedoc",
118
118
  "test:full": "c8 -r lcov -r text-summary mocha --config .config/mocha.full.json",
119
119
  "rebuild_specs": "node scripts/rebuild_specs.js",
package/tsdoc.json CHANGED
@@ -146,6 +146,11 @@
146
146
  "syntaxKind": "block",
147
147
  "allowMultiple": true
148
148
  },
149
+ {
150
+ "tagName": "@this",
151
+ "syntaxKind": "block",
152
+ "allowMultiple": false
153
+ },
149
154
  {
150
155
  "tagName": "@linkcode",
151
156
  "syntaxKind": "inline",