typedoc 0.24.8 → 0.25.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +5 -1
  4. package/dist/lib/application.d.ts +10 -8
  5. package/dist/lib/application.js +47 -20
  6. package/dist/lib/cli.js +25 -21
  7. package/dist/lib/converter/comments/blockLexer.js +10 -1
  8. package/dist/lib/converter/comments/declarationReference.js +2 -0
  9. package/dist/lib/converter/comments/declarationReferenceResolver.js +2 -1
  10. package/dist/lib/converter/comments/discovery.js +0 -1
  11. package/dist/lib/converter/comments/linkResolver.d.ts +5 -2
  12. package/dist/lib/converter/comments/linkResolver.js +21 -13
  13. package/dist/lib/converter/comments/parser.js +2 -1
  14. package/dist/lib/converter/converter.d.ts +2 -0
  15. package/dist/lib/converter/converter.js +14 -8
  16. package/dist/lib/converter/factories/index-signature.js +2 -1
  17. package/dist/lib/converter/plugins/CategoryPlugin.js +2 -1
  18. package/dist/lib/converter/plugins/CommentPlugin.js +2 -1
  19. package/dist/lib/converter/plugins/GroupPlugin.js +3 -2
  20. package/dist/lib/converter/plugins/ImplementsPlugin.js +8 -5
  21. package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +2 -0
  22. package/dist/lib/converter/plugins/InheritDocPlugin.js +11 -4
  23. package/dist/lib/converter/plugins/LinkResolverPlugin.js +4 -2
  24. package/dist/lib/converter/plugins/PackagePlugin.js +2 -1
  25. package/dist/lib/converter/plugins/SourcePlugin.d.ts +1 -0
  26. package/dist/lib/converter/plugins/SourcePlugin.js +31 -12
  27. package/dist/lib/converter/plugins/TypePlugin.js +12 -10
  28. package/dist/lib/converter/symbols.js +15 -3
  29. package/dist/lib/converter/types.js +6 -1
  30. package/dist/lib/converter/utils/nodes.d.ts +2 -2
  31. package/dist/lib/converter/utils/repository.d.ts +15 -5
  32. package/dist/lib/converter/utils/repository.js +28 -11
  33. package/dist/lib/models/ReflectionGroup.d.ts +4 -2
  34. package/dist/lib/models/ReflectionGroup.js +3 -1
  35. package/dist/lib/models/comments/comment.d.ts +9 -2
  36. package/dist/lib/models/comments/comment.js +2 -0
  37. package/dist/lib/models/reflections/abstract.d.ts +2 -1
  38. package/dist/lib/models/reflections/abstract.js +1 -0
  39. package/dist/lib/models/reflections/container.d.ts +3 -0
  40. package/dist/lib/models/reflections/container.js +4 -1
  41. package/dist/lib/models/reflections/declaration.d.ts +1 -0
  42. package/dist/lib/models/reflections/declaration.js +1 -0
  43. package/dist/lib/models/reflections/kind.d.ts +4 -4
  44. package/dist/lib/models/reflections/kind.js +5 -7
  45. package/dist/lib/models/reflections/parameter.d.ts +3 -0
  46. package/dist/lib/models/reflections/parameter.js +3 -0
  47. package/dist/lib/models/reflections/project.d.ts +1 -0
  48. package/dist/lib/models/reflections/project.js +3 -1
  49. package/dist/lib/models/reflections/reference.d.ts +1 -0
  50. package/dist/lib/models/reflections/reference.js +1 -0
  51. package/dist/lib/models/reflections/signature.d.ts +3 -0
  52. package/dist/lib/models/reflections/signature.js +3 -0
  53. package/dist/lib/models/reflections/type-parameter.d.ts +3 -0
  54. package/dist/lib/models/reflections/type-parameter.js +3 -0
  55. package/dist/lib/models/sources/file.d.ts +2 -0
  56. package/dist/lib/models/sources/file.js +5 -0
  57. package/dist/lib/models/types.d.ts +24 -0
  58. package/dist/lib/models/types.js +21 -0
  59. package/dist/lib/output/components.js +2 -3
  60. package/dist/lib/output/events.d.ts +2 -2
  61. package/dist/lib/output/plugins/AssetsPlugin.js +2 -1
  62. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +2 -1
  63. package/dist/lib/output/renderer.js +3 -2
  64. package/dist/lib/output/theme.d.ts +1 -1
  65. package/dist/lib/output/theme.js +2 -1
  66. package/dist/lib/output/themes/MarkedPlugin.js +2 -1
  67. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +2 -9
  68. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +1 -10
  69. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  70. package/dist/lib/output/themes/default/partials/comment.js +16 -14
  71. package/dist/lib/output/themes/default/partials/footer.js +1 -1
  72. package/dist/lib/output/themes/default/partials/header.js +1 -1
  73. package/dist/lib/output/themes/default/partials/icon.js +0 -3
  74. package/dist/lib/output/themes/default/partials/member.js +1 -1
  75. package/dist/lib/output/themes/default/partials/member.signature.body.js +3 -3
  76. package/dist/lib/output/themes/default/partials/navigation.d.ts +1 -1
  77. package/dist/lib/output/themes/default/partials/navigation.js +27 -14
  78. package/dist/lib/output/themes/default/partials/parameter.js +3 -3
  79. package/dist/lib/output/themes/lib.d.ts +1 -2
  80. package/dist/lib/output/themes/lib.js +1 -11
  81. package/dist/lib/serialization/schema.d.ts +37 -1
  82. package/dist/lib/utils/entry-point.d.ts +0 -6
  83. package/dist/lib/utils/entry-point.js +0 -99
  84. package/dist/lib/utils/jsx.d.ts +1 -1
  85. package/dist/lib/utils/jsx.js +23 -14
  86. package/dist/lib/utils/options/declaration.d.ts +3 -1
  87. package/dist/lib/utils/options/declaration.js +1 -1
  88. package/dist/lib/utils/options/options.d.ts +3 -9
  89. package/dist/lib/utils/options/options.js +5 -13
  90. package/dist/lib/utils/options/readers/typedoc.d.ts +4 -2
  91. package/dist/lib/utils/options/readers/typedoc.js +33 -7
  92. package/dist/lib/utils/options/sources/typedoc.js +14 -4
  93. package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
  94. package/dist/lib/utils/options/tsdoc-defaults.js +4 -0
  95. package/dist/lib/utils/package-manifest.d.ts +0 -25
  96. package/dist/lib/utils/package-manifest.js +7 -148
  97. package/dist/lib/utils/perf.js +26 -11
  98. package/dist/lib/utils/sort.js +0 -1
  99. package/dist/lib/validation/links.js +10 -2
  100. package/package.json +12 -12
  101. package/static/main.js +1 -1
  102. package/static/style.css +19 -7
  103. package/tsdoc.json +16 -0
@@ -22,7 +22,7 @@ const utils_1 = require("../../utils");
22
22
  * A plugin that detects interface implementations of functions and
23
23
  * properties on classes and links them.
24
24
  */
25
- let ImplementsPlugin = exports.ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComponent {
25
+ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComponent {
26
26
  constructor() {
27
27
  super(...arguments);
28
28
  this.resolved = new WeakSet();
@@ -103,9 +103,10 @@ let ImplementsPlugin = exports.ImplementsPlugin = class ImplementsPlugin extends
103
103
  this.resolve(context.project);
104
104
  }
105
105
  resolve(project) {
106
- for (const reflection of Object.values(project.reflections)) {
107
- if (reflection instanceof index_1.DeclarationReflection) {
108
- this.tryResolve(project, reflection);
106
+ for (const id in project.reflections) {
107
+ const refl = project.reflections[id];
108
+ if (refl instanceof index_1.DeclarationReflection) {
109
+ this.tryResolve(project, refl);
109
110
  }
110
111
  }
111
112
  }
@@ -195,7 +196,8 @@ let ImplementsPlugin = exports.ImplementsPlugin = class ImplementsPlugin extends
195
196
  const property = findProperty(reflection, childType);
196
197
  if (!property) {
197
198
  // We're probably broken... but I don't think this should be fatal.
198
- context.logger.warn(`Failed to retrieve${reflection.flags.isStatic ? " static" : ""} member "${reflection.escapedName ?? reflection.name}" of "${reflection.parent?.name}" for inheritance analysis. Please report a bug.`);
199
+ context.logger.warn(`Failed to retrieve${reflection.flags.isStatic ? " static" : ""} member "${reflection.escapedName ?? reflection.name}" of "${reflection.parent
200
+ ?.name}" for inheritance analysis. Please report a bug.`);
199
201
  return;
200
202
  }
201
203
  // Need to check both extends and implements clauses.
@@ -224,6 +226,7 @@ let ImplementsPlugin = exports.ImplementsPlugin = class ImplementsPlugin extends
224
226
  }
225
227
  }
226
228
  };
229
+ exports.ImplementsPlugin = ImplementsPlugin;
227
230
  exports.ImplementsPlugin = ImplementsPlugin = __decorate([
228
231
  (0, components_1.Component)({ name: "implements" })
229
232
  ], ImplementsPlugin);
@@ -1,4 +1,5 @@
1
1
  import { ConverterComponent } from "../components";
2
+ import { ValidationOptions } from "../../utils";
2
3
  /**
3
4
  * A plugin that handles `@inheritDoc` tags by copying documentation from another API item.
4
5
  * It is NOT responsible for handling bare JSDoc style `@inheritDoc` tags which do not specify
@@ -13,6 +14,7 @@ import { ConverterComponent } from "../components";
13
14
  * - `@return` block
14
15
  */
15
16
  export declare class InheritDocPlugin extends ConverterComponent {
17
+ validation: ValidationOptions;
16
18
  private dependencies;
17
19
  /**
18
20
  * Create a new InheritDocPlugin instance.
@@ -28,7 +28,7 @@ const application_events_1 = require("../../application-events");
28
28
  * - `@typeParam` block
29
29
  * - `@return` block
30
30
  */
31
- let InheritDocPlugin = exports.InheritDocPlugin = class InheritDocPlugin extends components_1.ConverterComponent {
31
+ let InheritDocPlugin = class InheritDocPlugin extends components_1.ConverterComponent {
32
32
  constructor() {
33
33
  super(...arguments);
34
34
  // Key is depended on by Values
@@ -39,7 +39,7 @@ let InheritDocPlugin = exports.InheritDocPlugin = class InheritDocPlugin extends
39
39
  */
40
40
  initialize() {
41
41
  this.owner.on(converter_1.Converter.EVENT_RESOLVE_END, (context) => this.processInheritDoc(context.project));
42
- this.owner.on(application_events_1.ApplicationEvents.REVIVE, this.processInheritDoc, this);
42
+ this.application.on(application_events_1.ApplicationEvents.REVIVE, this.processInheritDoc, this);
43
43
  }
44
44
  /**
45
45
  * Traverse through reflection descendant to check for `inheritDoc` tag.
@@ -47,7 +47,8 @@ let InheritDocPlugin = exports.InheritDocPlugin = class InheritDocPlugin extends
47
47
  * that will provide actual comment.
48
48
  */
49
49
  processInheritDoc(project) {
50
- for (const reflection of Object.values(project.reflections)) {
50
+ for (const id in project.reflections) {
51
+ const reflection = project.reflections[id];
51
52
  const source = extractInheritDocTagReference(reflection);
52
53
  if (!source)
53
54
  continue;
@@ -78,7 +79,9 @@ let InheritDocPlugin = exports.InheritDocPlugin = class InheritDocPlugin extends
78
79
  sourceRefl = sourceRefl.getSignature || sourceRefl.setSignature;
79
80
  }
80
81
  if (!sourceRefl) {
81
- this.application.logger.warn(`Failed to find "${source}" to inherit the comment from in the comment for ${reflection.getFullName()}`);
82
+ if (this.validation.invalidLink) {
83
+ this.application.logger.warn(`Failed to find "${source}" to inherit the comment from in the comment for ${reflection.getFullName()}`);
84
+ }
82
85
  continue;
83
86
  }
84
87
  this.copyComment(sourceRefl, reflection);
@@ -159,6 +162,10 @@ let InheritDocPlugin = exports.InheritDocPlugin = class InheritDocPlugin extends
159
162
  }
160
163
  }
161
164
  };
165
+ exports.InheritDocPlugin = InheritDocPlugin;
166
+ __decorate([
167
+ (0, utils_1.BindOption)("validation")
168
+ ], InheritDocPlugin.prototype, "validation", void 0);
162
169
  exports.InheritDocPlugin = InheritDocPlugin = __decorate([
163
170
  (0, components_1.Component)({ name: "inheritDoc" })
164
171
  ], InheritDocPlugin);
@@ -16,7 +16,7 @@ const application_events_1 = require("../../application-events");
16
16
  /**
17
17
  * A plugin that resolves `{@link Foo}` tags.
18
18
  */
19
- let LinkResolverPlugin = exports.LinkResolverPlugin = class LinkResolverPlugin extends components_1.ConverterComponent {
19
+ let LinkResolverPlugin = class LinkResolverPlugin extends components_1.ConverterComponent {
20
20
  initialize() {
21
21
  super.initialize();
22
22
  this.owner.on(converter_events_1.ConverterEvents.RESOLVE_END, this.onResolve, this, -300);
@@ -26,7 +26,8 @@ let LinkResolverPlugin = exports.LinkResolverPlugin = class LinkResolverPlugin e
26
26
  this.resolveLinks(context.project);
27
27
  }
28
28
  resolveLinks(project) {
29
- for (const reflection of Object.values(project.reflections)) {
29
+ for (const id in project.reflections) {
30
+ const reflection = project.reflections[id];
30
31
  if (reflection.comment) {
31
32
  this.owner.resolveLinks(reflection.comment, reflection);
32
33
  }
@@ -53,6 +54,7 @@ let LinkResolverPlugin = exports.LinkResolverPlugin = class LinkResolverPlugin e
53
54
  }
54
55
  }
55
56
  };
57
+ exports.LinkResolverPlugin = LinkResolverPlugin;
56
58
  __decorate([
57
59
  (0, utils_1.BindOption)("validation")
58
60
  ], LinkResolverPlugin.prototype, "validation", void 0);
@@ -43,7 +43,7 @@ const path_1 = require("path");
43
43
  * A handler that tries to find the package.json and readme.md files of the
44
44
  * current project.
45
45
  */
46
- let PackagePlugin = exports.PackagePlugin = class PackagePlugin extends components_1.ConverterComponent {
46
+ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent {
47
47
  initialize() {
48
48
  this.listenTo(this.owner, {
49
49
  [converter_1.Converter.EVENT_BEGIN]: this.onBegin,
@@ -129,6 +129,7 @@ let PackagePlugin = exports.PackagePlugin = class PackagePlugin extends componen
129
129
  }
130
130
  }
131
131
  };
132
+ exports.PackagePlugin = PackagePlugin;
132
133
  __decorate([
133
134
  (0, utils_1.BindOption)("readme")
134
135
  ], PackagePlugin.prototype, "readme", void 0);
@@ -6,6 +6,7 @@ export declare class SourcePlugin extends ConverterComponent {
6
6
  readonly disableSources: boolean;
7
7
  readonly gitRevision: string;
8
8
  readonly gitRemote: string;
9
+ readonly disableGit: boolean;
9
10
  readonly sourceLinkTemplate: string;
10
11
  readonly basePath: string;
11
12
  /**
@@ -23,7 +23,7 @@ const base_path_1 = require("../utils/base-path");
23
23
  /**
24
24
  * A handler that attaches source file information to reflections.
25
25
  */
26
- let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
26
+ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
27
27
  constructor() {
28
28
  super(...arguments);
29
29
  /**
@@ -71,14 +71,11 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
71
71
  const fileName = base_path_1.BasePath.normalize(sourceFile.fileName);
72
72
  this.fileNames.add(fileName);
73
73
  let position;
74
- if ((0, nodes_1.isNamedNode)(node)) {
75
- position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, node.name.getStart());
76
- }
77
- else if (typescript_1.default.isSourceFile(node)) {
74
+ if (typescript_1.default.isSourceFile(node)) {
78
75
  position = { character: 0, line: 0 };
79
76
  }
80
77
  else {
81
- position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, node.getStart());
78
+ position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, getLocationNode(node).getStart());
82
79
  }
83
80
  reflection.sources || (reflection.sources = []);
84
81
  reflection.sources.push(new models_1.SourceReference(fileName, position.line + 1, position.character));
@@ -90,7 +87,7 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
90
87
  const sourceFile = sig.getSourceFile();
91
88
  const fileName = base_path_1.BasePath.normalize(sourceFile.fileName);
92
89
  this.fileNames.add(fileName);
93
- const position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, sig.getStart());
90
+ const position = typescript_1.default.getLineAndCharacterOfPosition(sourceFile, getLocationNode(sig).getStart());
94
91
  reflection.sources || (reflection.sources = []);
95
92
  reflection.sources.push(new models_1.SourceReference(fileName, position.line + 1, position.character));
96
93
  }
@@ -102,15 +99,25 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
102
99
  onBeginResolve(context) {
103
100
  if (this.disableSources)
104
101
  return;
102
+ if (this.disableGit && !this.sourceLinkTemplate) {
103
+ this.application.logger.error(`disableGit is set, but sourceLinkTemplate is not, so source links cannot be produced. Set a sourceLinkTemplate or disableSources to prevent source tracking.`);
104
+ return;
105
+ }
106
+ if (this.disableGit &&
107
+ this.sourceLinkTemplate.includes("{gitRevision}") &&
108
+ !this.gitRevision) {
109
+ this.application.logger.warn(`disableGit is set and sourceLinkTemplate contains {gitRevision}, which will be replaced with an empty string as no revision was provided.`);
110
+ }
105
111
  const basePath = this.basePath || (0, utils_1.getCommonDirectory)([...this.fileNames]);
106
- for (const refl of Object.values(context.project.reflections)) {
112
+ for (const id in context.project.reflections) {
113
+ const refl = context.project.reflections[id];
107
114
  if (!(refl instanceof index_1.DeclarationReflection ||
108
115
  refl instanceof index_1.SignatureReflection)) {
109
116
  continue;
110
117
  }
111
118
  for (const source of refl.sources || []) {
112
- if (repository_1.gitIsInstalled) {
113
- const repo = this.getRepository(source.fullFileName);
119
+ if (this.disableGit || (0, repository_1.gitIsInstalled)()) {
120
+ const repo = this.getRepository(basePath, source.fullFileName);
114
121
  source.url = repo?.getURL(source.fullFileName, source.line);
115
122
  }
116
123
  source.fileName = (0, utils_1.normalizePath)((0, path_1.relative)(basePath, source.fullFileName));
@@ -123,7 +130,10 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
123
130
  * @param fileName The name of the file a repository should be looked for.
124
131
  * @returns The found repository info or undefined.
125
132
  */
126
- getRepository(fileName) {
133
+ getRepository(basePath, fileName) {
134
+ if (this.disableGit) {
135
+ return new repository_1.AssumedRepository(basePath, this.gitRevision, this.sourceLinkTemplate);
136
+ }
127
137
  // Check for known non-repositories
128
138
  const dirName = (0, path_1.dirname)(fileName);
129
139
  const segments = dirName.split("/");
@@ -139,7 +149,7 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
139
149
  }
140
150
  }
141
151
  // Try to create a new repository
142
- const repository = repository_1.Repository.tryCreateRepository(dirName, this.sourceLinkTemplate, this.gitRevision, this.gitRemote, this.application.logger);
152
+ const repository = repository_1.GitRepository.tryCreateRepository(dirName, this.sourceLinkTemplate, this.gitRevision, this.gitRemote, this.application.logger);
143
153
  if (repository) {
144
154
  this.repositories[repository.path.toLowerCase()] = repository;
145
155
  return repository;
@@ -148,6 +158,7 @@ let SourcePlugin = exports.SourcePlugin = class SourcePlugin extends components_
148
158
  this.ignoredPaths.add(dirName);
149
159
  }
150
160
  };
161
+ exports.SourcePlugin = SourcePlugin;
151
162
  __decorate([
152
163
  (0, utils_1.BindOption)("disableSources")
153
164
  ], SourcePlugin.prototype, "disableSources", void 0);
@@ -157,6 +168,9 @@ __decorate([
157
168
  __decorate([
158
169
  (0, utils_1.BindOption)("gitRemote")
159
170
  ], SourcePlugin.prototype, "gitRemote", void 0);
171
+ __decorate([
172
+ (0, utils_1.BindOption)("disableGit")
173
+ ], SourcePlugin.prototype, "disableGit", void 0);
160
174
  __decorate([
161
175
  (0, utils_1.BindOption)("sourceLinkTemplate")
162
176
  ], SourcePlugin.prototype, "sourceLinkTemplate", void 0);
@@ -166,3 +180,8 @@ __decorate([
166
180
  exports.SourcePlugin = SourcePlugin = __decorate([
167
181
  (0, components_1.Component)({ name: "source" })
168
182
  ], SourcePlugin);
183
+ function getLocationNode(node) {
184
+ if ((0, nodes_1.isNamedNode)(node))
185
+ return node.name;
186
+ return node;
187
+ }
@@ -15,7 +15,7 @@ const application_events_1 = require("../../application-events");
15
15
  /**
16
16
  * Responsible for adding `implementedBy` / `implementedFrom`
17
17
  */
18
- let TypePlugin = exports.TypePlugin = class TypePlugin extends components_1.ConverterComponent {
18
+ let TypePlugin = class TypePlugin extends components_1.ConverterComponent {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  this.reflections = new Set();
@@ -34,8 +34,9 @@ let TypePlugin = exports.TypePlugin = class TypePlugin extends components_1.Conv
34
34
  });
35
35
  }
36
36
  onRevive(project) {
37
- for (const refl of Object.values(project.reflections)) {
38
- this.resolve(project, refl);
37
+ for (const id in project.reflections) {
38
+ this.resolve(project, project.reflections[id],
39
+ /* create links */ false);
39
40
  }
40
41
  this.finishResolve(project);
41
42
  this.reflections.clear();
@@ -43,24 +44,24 @@ let TypePlugin = exports.TypePlugin = class TypePlugin extends components_1.Conv
43
44
  onResolve(context, reflection) {
44
45
  this.resolve(context.project, reflection);
45
46
  }
46
- resolve(project, reflection) {
47
+ resolve(project, reflection, createLinks = true) {
47
48
  if (!(reflection instanceof index_1.DeclarationReflection))
48
49
  return;
49
50
  if (reflection.kindOf(index_1.ReflectionKind.ClassOrInterface)) {
50
51
  this.postpone(reflection);
51
52
  walk(reflection.implementedTypes, (target) => {
52
53
  this.postpone(target);
53
- if (!target.implementedBy) {
54
- target.implementedBy = [];
54
+ target.implementedBy || (target.implementedBy = []);
55
+ if (createLinks) {
56
+ target.implementedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, project));
55
57
  }
56
- target.implementedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, project));
57
58
  });
58
59
  walk(reflection.extendedTypes, (target) => {
59
60
  this.postpone(target);
60
- if (!target.extendedBy) {
61
- target.extendedBy = [];
61
+ target.extendedBy || (target.extendedBy = []);
62
+ if (createLinks) {
63
+ target.extendedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, project));
62
64
  }
63
- target.extendedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, project));
64
65
  });
65
66
  }
66
67
  function walk(types, callback) {
@@ -121,6 +122,7 @@ let TypePlugin = exports.TypePlugin = class TypePlugin extends components_1.Conv
121
122
  });
122
123
  }
123
124
  };
125
+ exports.TypePlugin = TypePlugin;
124
126
  exports.TypePlugin = TypePlugin = __decorate([
125
127
  (0, components_1.Component)({ name: "type" })
126
128
  ], TypePlugin);
@@ -176,8 +176,16 @@ function convertNamespace(context, symbol, exportSymbol) {
176
176
  return;
177
177
  }
178
178
  }
179
- const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
180
- context.finalizeDeclarationReflection(reflection);
179
+ // #2364, @namespace on a variable might be merged with a namespace containing types.
180
+ const existingReflection = context.project.getReflectionFromSymbol(exportSymbol || symbol);
181
+ let reflection;
182
+ if (existingReflection?.kind === models_1.ReflectionKind.Namespace) {
183
+ reflection = existingReflection;
184
+ }
185
+ else {
186
+ reflection = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
187
+ context.finalizeDeclarationReflection(reflection);
188
+ }
181
189
  convertSymbols(context.withScope(reflection), context.checker
182
190
  .getExportsOfModule(symbol)
183
191
  .filter((s) => s.flags & exportFlags));
@@ -216,6 +224,9 @@ function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration)
216
224
  context.finalizeDeclarationReflection(reflection);
217
225
  const rc = context.withScope(reflection);
218
226
  const type = context.checker.getTypeAtLocation(declaration);
227
+ if (type.getFlags() & typescript_1.default.TypeFlags.Union) {
228
+ context.logger.warn(`Using @interface on a union type will discard properties not present on all branches of the union. TypeDoc's output may not accurately describe your source code.`, declaration);
229
+ }
219
230
  // Interfaces have properties
220
231
  convertSymbols(rc, type.getProperties());
221
232
  // And type arguments
@@ -511,7 +522,8 @@ function convertVariableAsNamespace(context, symbol, exportSymbol) {
511
522
  const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
512
523
  context.finalizeDeclarationReflection(reflection);
513
524
  const rc = context.withScope(reflection);
514
- const declaration = symbol.declarations[0];
525
+ const declaration = symbol.declarations?.find(typescript_1.default.isVariableDeclaration);
526
+ (0, assert_1.default)(declaration, "Missing variable declaration");
515
527
  const type = context.checker.getTypeAtLocation(declaration);
516
528
  convertSymbols(rc, type.getProperties());
517
529
  return typescript_1.default.SymbolFlags.Property;
@@ -561,7 +561,12 @@ const tupleConverter = {
561
561
  let elements = types?.map((type) => convertType(context, type));
562
562
  if (type.target.labeledElementDeclarations) {
563
563
  const namedDeclarations = type.target.labeledElementDeclarations;
564
- elements = elements?.map((el, i) => new models_1.NamedTupleMember(namedDeclarations[i].name.getText(), !!namedDeclarations[i].questionToken, (0, reflections_1.removeUndefined)(el)));
564
+ elements = elements?.map((el, i) => {
565
+ const namedDecl = namedDeclarations[i];
566
+ return namedDecl
567
+ ? new models_1.NamedTupleMember(namedDecl.name.getText(), !!namedDecl.questionToken, (0, reflections_1.removeUndefined)(el))
568
+ : el;
569
+ });
565
570
  }
566
571
  elements = elements?.map((el, i) => {
567
572
  if (type.target.elementFlags[i] & typescript_1.default.ElementFlags.Variable) {
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
- export declare function isNamedNode(node: ts.Node): node is ts.Node & {
3
- name: ts.Identifier | ts.PrivateIdentifier | ts.ComputedPropertyName;
2
+ export declare function isNamedNode(node: unknown): node is {
3
+ readonly name: ts.Identifier | ts.PrivateIdentifier | ts.ComputedPropertyName;
4
4
  };
5
5
  export declare function getHeritageTypes(declarations: readonly (ts.ClassDeclaration | ts.InterfaceDeclaration)[], kind: ts.SyntaxKind.ImplementsKeyword | ts.SyntaxKind.ExtendsKeyword): ts.ExpressionWithTypeArguments[];
6
6
  export declare function isObjectType(type: ts.Type): type is ts.ObjectType;
@@ -1,9 +1,19 @@
1
1
  import type { Logger } from "../../utils";
2
- export declare const gitIsInstalled: boolean;
2
+ export declare function gitIsInstalled(): boolean;
3
+ export interface Repository {
4
+ getURL(fileName: string, line: number): string | undefined;
5
+ }
6
+ export declare class AssumedRepository implements Repository {
7
+ readonly path: string;
8
+ readonly gitRevision: string;
9
+ readonly sourceLinkTemplate: string;
10
+ constructor(path: string, gitRevision: string, sourceLinkTemplate: string);
11
+ getURL(fileName: string, line: number): string | undefined;
12
+ }
3
13
  /**
4
14
  * Stores data of a repository.
5
15
  */
6
- export declare class Repository {
16
+ export declare class GitRepository implements Repository {
7
17
  /**
8
18
  * The path of this repository on disk.
9
19
  */
@@ -31,11 +41,11 @@ export declare class Repository {
31
41
  * Try to create a new repository instance.
32
42
  *
33
43
  * Checks whether the given path is the root of a valid repository and if so
34
- * creates a new instance of {@link Repository}.
44
+ * creates a new instance of {@link GitRepository}.
35
45
  *
36
46
  * @param path The potential repository root.
37
- * @returns A new instance of {@link Repository} or undefined.
47
+ * @returns A new instance of {@link GitRepository} or undefined.
38
48
  */
39
- static tryCreateRepository(path: string, sourceLinkTemplate: string, gitRevision: string, gitRemote: string, logger: Logger): Repository | undefined;
49
+ static tryCreateRepository(path: string, sourceLinkTemplate: string, gitRevision: string, gitRemote: string, logger: Logger): GitRepository | undefined;
40
50
  }
41
51
  export declare function guessSourceUrlTemplate(remotes: string[]): string | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.guessSourceUrlTemplate = exports.Repository = exports.gitIsInstalled = void 0;
3
+ exports.guessSourceUrlTemplate = exports.GitRepository = exports.AssumedRepository = exports.gitIsInstalled = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const base_path_1 = require("../utils/base-path");
6
6
  const TEN_MEGABYTES = 1024 * 10000;
@@ -11,11 +11,32 @@ function git(...args) {
11
11
  maxBuffer: TEN_MEGABYTES,
12
12
  });
13
13
  }
14
- exports.gitIsInstalled = git("--version").status === 0;
14
+ let haveGit;
15
+ function gitIsInstalled() {
16
+ haveGit ?? (haveGit = git("--version").status === 0);
17
+ return haveGit;
18
+ }
19
+ exports.gitIsInstalled = gitIsInstalled;
20
+ class AssumedRepository {
21
+ constructor(path, gitRevision, sourceLinkTemplate) {
22
+ this.path = path;
23
+ this.gitRevision = gitRevision;
24
+ this.sourceLinkTemplate = sourceLinkTemplate;
25
+ }
26
+ getURL(fileName, line) {
27
+ const replacements = {
28
+ gitRevision: this.gitRevision,
29
+ path: fileName.substring(this.path.length + 1),
30
+ line,
31
+ };
32
+ return this.sourceLinkTemplate.replace(/\{(path|line)\}/g, (_, key) => replacements[key]);
33
+ }
34
+ }
35
+ exports.AssumedRepository = AssumedRepository;
15
36
  /**
16
37
  * Stores data of a repository.
17
38
  */
18
- class Repository {
39
+ class GitRepository {
19
40
  /**
20
41
  * Create a new Repository instance.
21
42
  *
@@ -59,10 +80,10 @@ class Repository {
59
80
  * Try to create a new repository instance.
60
81
  *
61
82
  * Checks whether the given path is the root of a valid repository and if so
62
- * creates a new instance of {@link Repository}.
83
+ * creates a new instance of {@link GitRepository}.
63
84
  *
64
85
  * @param path The potential repository root.
65
- * @returns A new instance of {@link Repository} or undefined.
86
+ * @returns A new instance of {@link GitRepository} or undefined.
66
87
  */
67
88
  static tryCreateRepository(path, sourceLinkTemplate, gitRevision, gitRemote, logger) {
68
89
  const topLevel = git("-C", path, "rev-parse", "--show-toplevel");
@@ -75,10 +96,6 @@ class Repository {
75
96
  if (sourceLinkTemplate) {
76
97
  urlTemplate = sourceLinkTemplate;
77
98
  }
78
- else if (/^https?:\/\//.test(gitRemote)) {
79
- logger.warn("Using a link as the gitRemote is deprecated and will be removed in 0.24.");
80
- urlTemplate = `${gitRemote}/{gitRevision}`;
81
- }
82
99
  else {
83
100
  const remotesOut = git("-C", path, "remote", "get-url", gitRemote);
84
101
  if (remotesOut.status === 0) {
@@ -90,10 +107,10 @@ class Repository {
90
107
  }
91
108
  if (!urlTemplate)
92
109
  return;
93
- return new Repository(base_path_1.BasePath.normalize(topLevel.stdout.replace("\n", "")), gitRevision, urlTemplate);
110
+ return new GitRepository(base_path_1.BasePath.normalize(topLevel.stdout.replace("\n", "")), gitRevision, urlTemplate);
94
111
  }
95
112
  }
96
- exports.Repository = Repository;
113
+ exports.GitRepository = GitRepository;
97
114
  // Should have three capturing groups:
98
115
  // 1. hostname
99
116
  // 2. user
@@ -1,5 +1,5 @@
1
1
  import { ReflectionCategory } from "./ReflectionCategory";
2
- import type { DeclarationReflection } from ".";
2
+ import type { DeclarationReflection, Reflection } from ".";
3
3
  import type { Serializer, JSONOutput, Deserializer } from "../serialization";
4
4
  /**
5
5
  * A group of reflections. All reflections in a group are of the same kind.
@@ -9,6 +9,7 @@ import type { Serializer, JSONOutput, Deserializer } from "../serialization";
9
9
  * render human readable children lists in templates.
10
10
  */
11
11
  export declare class ReflectionGroup {
12
+ readonly owningReflection: Reflection;
12
13
  /**
13
14
  * The title, a string representation of the typescript kind, of this group.
14
15
  */
@@ -25,8 +26,9 @@ export declare class ReflectionGroup {
25
26
  * Create a new ReflectionGroup instance.
26
27
  *
27
28
  * @param title The title of this group.
29
+ * @param owningReflection The reflection containing this group, useful for changing rendering based on a comment on a reflection.
28
30
  */
29
- constructor(title: string);
31
+ constructor(title: string, owningReflection: Reflection);
30
32
  /**
31
33
  * Do all children of this group have a separate document?
32
34
  */
@@ -14,8 +14,10 @@ class ReflectionGroup {
14
14
  * Create a new ReflectionGroup instance.
15
15
  *
16
16
  * @param title The title of this group.
17
+ * @param owningReflection The reflection containing this group, useful for changing rendering based on a comment on a reflection.
17
18
  */
18
- constructor(title) {
19
+ constructor(title, owningReflection) {
20
+ this.owningReflection = owningReflection;
19
21
  /**
20
22
  * All reflections of this group.
21
23
  */
@@ -1,6 +1,10 @@
1
1
  import type { Reflection } from "../reflections";
2
2
  import { ReflectionSymbolId } from "../reflections/ReflectionSymbolId";
3
3
  import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
4
+ /**
5
+ * Represents a parsed piece of a comment.
6
+ * @category Comments
7
+ */
4
8
  export type CommentDisplayPart = {
5
9
  kind: "text";
6
10
  text: string;
@@ -13,6 +17,7 @@ export type CommentDisplayPart = {
13
17
  * property set indicating which reflection/url they link to. They may also
14
18
  * have a `tsLinkText` property which includes the part of the `text` which
15
19
  * TypeScript thinks should be displayed as the link text.
20
+ * @category Comments
16
21
  */
17
22
  export interface InlineTagDisplayPart {
18
23
  kind: "inline-tag";
@@ -25,6 +30,7 @@ export interface InlineTagDisplayPart {
25
30
  * A model that represents a single TypeDoc comment tag.
26
31
  *
27
32
  * Tags are stored in the {@link Comment.blockTags} property.
33
+ * @category Comments
28
34
  */
29
35
  export declare class CommentTag {
30
36
  /**
@@ -53,6 +59,7 @@ export declare class CommentTag {
53
59
  *
54
60
  * Instances of this model are created by the CommentPlugin. You can retrieve comments
55
61
  * through the {@link DeclarationReflection.comment} property.
62
+ * @category Comments
56
63
  */
57
64
  export declare class Comment {
58
65
  /**
@@ -97,7 +104,7 @@ export declare class Comment {
97
104
  /**
98
105
  * All modifier tags present on the comment, e.g. `@alpha`, `@beta`.
99
106
  */
100
- modifierTags: Set<string>;
107
+ modifierTags: Set<`@${string}`>;
101
108
  /**
102
109
  * Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
103
110
  */
@@ -105,7 +112,7 @@ export declare class Comment {
105
112
  /**
106
113
  * Creates a new Comment instance.
107
114
  */
108
- constructor(summary?: CommentDisplayPart[], blockTags?: CommentTag[], modifierTags?: Set<string>);
115
+ constructor(summary?: CommentDisplayPart[], blockTags?: CommentTag[], modifierTags?: Set<`@${string}`>);
109
116
  /**
110
117
  * Create a deep clone of this comment.
111
118
  */
@@ -8,6 +8,7 @@ const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
8
8
  * A model that represents a single TypeDoc comment tag.
9
9
  *
10
10
  * Tags are stored in the {@link Comment.blockTags} property.
11
+ * @category Comments
11
12
  */
12
13
  class CommentTag {
13
14
  /**
@@ -43,6 +44,7 @@ exports.CommentTag = CommentTag;
43
44
  *
44
45
  * Instances of this model are created by the CommentPlugin. You can retrieve comments
45
46
  * through the {@link DeclarationReflection.comment} property.
47
+ * @category Comments
46
48
  */
47
49
  class Comment {
48
50
  /**
@@ -100,6 +100,7 @@ export interface TraverseCallback {
100
100
  * This base class exposes the basic properties one may use to traverse the reflection tree.
101
101
  * You can use the {@link ContainerReflection.children} and {@link parent} properties to walk the tree. The {@link ContainerReflection.groups} property
102
102
  * contains a list of all children grouped and sorted for rendering.
103
+ * @category Reflections
103
104
  */
104
105
  export declare abstract class Reflection {
105
106
  /**
@@ -207,7 +208,7 @@ export declare abstract class Reflection {
207
208
  * Traverse most potential child reflections of this reflection.
208
209
  *
209
210
  * Note: This may not necessarily traverse child reflections contained within the `type` property
210
- * of the reflection, and should not be relied on for this. Support for checking object types will likely be removed in v0.25.
211
+ * of the reflection, and should not be relied on for this. Support for checking object types will likely be removed in v0.26.
211
212
  *
212
213
  * The given callback will be invoked for all children, signatures and type parameters
213
214
  * attached to this reflection.
@@ -205,6 +205,7 @@ var TraverseProperty;
205
205
  * This base class exposes the basic properties one may use to traverse the reflection tree.
206
206
  * You can use the {@link ContainerReflection.children} and {@link parent} properties to walk the tree. The {@link ContainerReflection.groups} property
207
207
  * contains a list of all children grouped and sorted for rendering.
208
+ * @category Reflections
208
209
  */
209
210
  class Reflection {
210
211
  get project() {