typedoc 0.23.7 → 0.23.8

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.
@@ -4,6 +4,7 @@ import { ProjectReflection, SomeType } from "../models/index";
4
4
  import { Context } from "./context";
5
5
  import { ConverterComponent } from "./components";
6
6
  import { ChildableComponent } from "../utils/component";
7
+ import { MinimalSourceFile } from "../utils";
7
8
  import type { DocumentationEntryPoint } from "../utils/entry-point";
8
9
  import { CommentParserConfig } from "./comments";
9
10
  import type { CommentStyle } from "../utils/options/declaration";
@@ -51,7 +52,8 @@ export declare class Converter extends ChildableComponent<Application, Converter
51
52
  static readonly EVENT_CREATE_DECLARATION: "createDeclaration";
52
53
  /**
53
54
  * Triggered when the converter has created a signature reflection.
54
- * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and a `ts.Node?`
55
+ * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and
56
+ * `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`
55
57
  * @event
56
58
  */
57
59
  static readonly EVENT_CREATE_SIGNATURE: "createSignature";
@@ -103,6 +105,10 @@ export declare class Converter extends ChildableComponent<Application, Converter
103
105
  * @internal
104
106
  */
105
107
  convertType(context: Context, node: ts.TypeNode | ts.Type | undefined): SomeType;
108
+ /**
109
+ * Parse the given file into a comment. Intended to be used with markdown files.
110
+ */
111
+ parseRawComment(file: MinimalSourceFile): import("../models/index").Comment;
106
112
  /**
107
113
  * Compile the files within the given context and convert the compiler symbols to reflections.
108
114
  *
@@ -60,6 +60,12 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
60
60
  convertType(context, node) {
61
61
  return (0, types_1.convertType)(context, node);
62
62
  }
63
+ /**
64
+ * Parse the given file into a comment. Intended to be used with markdown files.
65
+ */
66
+ parseRawComment(file) {
67
+ return (0, parser_1.parseComment)((0, rawLexer_1.lexCommentString)(file.text), this.config, file, this.application.logger);
68
+ }
63
69
  /**
64
70
  * Compile the files within the given context and convert the compiler symbols to reflections.
65
71
  *
@@ -110,7 +116,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
110
116
  const reflection = context.createDeclarationReflection(index_1.ReflectionKind.Module, symbol, void 0, entryName);
111
117
  if (entryPoint.readmeFile) {
112
118
  const readme = (0, utils_1.readFile)(entryPoint.readmeFile);
113
- const comment = (0, parser_1.parseComment)((0, rawLexer_1.lexCommentString)(readme), context.converter.config, new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile), context.logger);
119
+ const comment = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile));
114
120
  if (comment.blockTags.length || comment.modifierTags.size) {
115
121
  const ignored = [
116
122
  ...comment.blockTags.map((tag) => tag.tag),
@@ -206,7 +212,8 @@ Converter.EVENT_END = converter_events_1.ConverterEvents.END;
206
212
  Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_DECLARATION;
207
213
  /**
208
214
  * Triggered when the converter has created a signature reflection.
209
- * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and a `ts.Node?`
215
+ * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} and
216
+ * `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`
210
217
  * @event
211
218
  */
212
219
  Converter.EVENT_CREATE_SIGNATURE = converter_events_1.ConverterEvents.CREATE_SIGNATURE;
@@ -49,7 +49,7 @@ function createSignature(context, kind, signature, declaration) {
49
49
  context.scope.signatures.push(sigRef);
50
50
  break;
51
51
  }
52
- context.trigger(converter_events_1.ConverterEvents.CREATE_SIGNATURE, sigRef);
52
+ context.trigger(converter_events_1.ConverterEvents.CREATE_SIGNATURE, sigRef, declaration);
53
53
  }
54
54
  exports.createSignature = createSignature;
55
55
  function convertParameters(context, sigRef, parameters, parameterNodes) {
@@ -174,14 +174,16 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
174
174
  }
175
175
  hidden.forEach((reflection) => project.removeReflection(reflection));
176
176
  // remove functions with empty signatures after their signatures have been removed
177
- const [allRemoved, someRemoved] = (0, utils_1.partition)((0, utils_1.filterMap)(hidden, (reflection) => reflection.parent?.kindOf(models_1.ReflectionKind.FunctionOrMethod | models_1.ReflectionKind.Constructor)
177
+ const [allRemoved, someRemoved] = (0, utils_1.partition)((0, utils_1.unique)((0, utils_1.filterMap)(hidden, (reflection) => reflection.parent?.kindOf(models_1.ReflectionKind.SignatureContainer)
178
178
  ? reflection.parent
179
- : void 0), (method) => method.signatures?.length === 0);
179
+ : void 0)), (method) => method.getNonIndexSignatures().length === 0);
180
180
  allRemoved.forEach((reflection) => {
181
181
  project.removeReflection(reflection);
182
182
  });
183
183
  someRemoved.forEach((reflection) => {
184
- reflection.sources = (0, utils_1.unique)(reflection.signatures.flatMap((s) => s.sources ?? []));
184
+ reflection.sources = reflection
185
+ .getNonIndexSignatures()
186
+ .flatMap((s) => s.sources ?? []);
185
187
  });
186
188
  }
187
189
  /**
@@ -282,8 +284,9 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
282
284
  }
283
285
  if (!comment) {
284
286
  if (this.excludeNotDocumented) {
285
- // Only allow excludeNotDocumented to exclude root level reflections
286
- if (!(reflection instanceof models_1.DeclarationReflection)) {
287
+ // Don't let excludeNotDocumented remove parameters.
288
+ if (!(reflection instanceof models_1.DeclarationReflection) &&
289
+ !(reflection instanceof models_1.SignatureReflection)) {
287
290
  return false;
288
291
  }
289
292
  // excludeNotDocumented should hide a module only if it has no visible children
@@ -297,6 +300,12 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
297
300
  if (reflection.kind === models_1.ReflectionKind.EnumMember) {
298
301
  return false;
299
302
  }
303
+ // signature containers should only be hidden if all their signatures are hidden
304
+ if (reflection.kindOf(models_1.ReflectionKind.SignatureContainer)) {
305
+ return reflection
306
+ .getAllSignatures()
307
+ .every((child) => this.isHidden(child));
308
+ }
300
309
  // excludeNotDocumented should never hide parts of "type" reflections
301
310
  return inTypeLiteral(reflection) === false;
302
311
  }
@@ -177,6 +177,10 @@ exports.LinkResolverPlugin = LinkResolverPlugin;
177
177
  function resolveLinkTag(reflection, part, warn) {
178
178
  let pos = 0;
179
179
  const end = part.text.length;
180
+ while (pos < end && ts.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
181
+ pos++;
182
+ }
183
+ const origText = part.text;
180
184
  // Try to parse one
181
185
  const declRef = (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
182
186
  let target;
@@ -185,12 +189,20 @@ function resolveLinkTag(reflection, part, warn) {
185
189
  target = (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
186
190
  pos = declRef[1];
187
191
  }
192
+ if (!target) {
193
+ if (urlPrefix.test(part.text)) {
194
+ const wsIndex = part.text.search(/\s/);
195
+ target =
196
+ wsIndex === -1 ? part.text : part.text.substring(0, wsIndex);
197
+ pos = target.length;
198
+ }
199
+ }
188
200
  // If resolution via a declaration reference failed, revert to the legacy "split and check"
189
201
  // method... this should go away in 0.24, once people have had a chance to migrate any failing links.
190
202
  if (!target) {
191
203
  const resolved = legacyResolveLinkTag(reflection, part);
192
204
  if (resolved) {
193
- warn(`Failed to resolve {@link ${part.text}} in ${reflection.getFriendlyFullName()} with declaration references. This link will break in v0.24.`);
205
+ warn(`Failed to resolve {@link ${origText}} in ${reflection.getFriendlyFullName()} with declaration references. This link will break in v0.24.`);
194
206
  }
195
207
  return resolved;
196
208
  }
@@ -203,7 +215,9 @@ function resolveLinkTag(reflection, part, warn) {
203
215
  pos++;
204
216
  }
205
217
  part.target = target;
206
- part.text = part.text.substring(pos).trim() || target.name;
218
+ part.text =
219
+ part.text.substring(pos).trim() ||
220
+ (typeof target === "string" ? target : target.name);
207
221
  return part;
208
222
  }
209
223
  function legacyResolveLinkTag(reflection, part) {
@@ -14,8 +14,6 @@ const converter_1 = require("../converter");
14
14
  const utils_1 = require("../../utils");
15
15
  const fs_1 = require("../../utils/fs");
16
16
  const paths_1 = require("../../utils/paths");
17
- const rawLexer_1 = require("../comments/rawLexer");
18
- const parser_1 = require("../comments/parser");
19
17
  const minimalSourceFile_1 = require("../../utils/minimalSourceFile");
20
18
  /**
21
19
  * A handler that tries to find the package.json and readme.md files of the
@@ -76,7 +74,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
76
74
  const project = context.project;
77
75
  if (this.readmeFile) {
78
76
  const readme = (0, utils_1.readFile)(this.readmeFile);
79
- const comment = (0, parser_1.parseComment)((0, rawLexer_1.lexCommentString)(readme), context.converter.config, new minimalSourceFile_1.MinimalSourceFile(readme, this.readmeFile), context.logger);
77
+ const comment = context.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(readme, this.readmeFile));
80
78
  if (comment.blockTags.length || comment.modifierTags.size) {
81
79
  const ignored = [
82
80
  ...comment.blockTags.map((tag) => tag.tag),
@@ -33,6 +33,7 @@ export declare class SourcePlugin extends ConverterComponent {
33
33
  * @param reflection The reflection that is currently processed.
34
34
  */
35
35
  private onDeclaration;
36
+ private onSignature;
36
37
  /**
37
38
  * Triggered when the converter begins resolving a project.
38
39
  *
@@ -42,7 +42,7 @@ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
42
42
  this.listenTo(this.owner, {
43
43
  [converter_1.Converter.EVENT_END]: this.onEnd,
44
44
  [converter_1.Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,
45
- [converter_1.Converter.EVENT_CREATE_SIGNATURE]: this.onDeclaration,
45
+ [converter_1.Converter.EVENT_CREATE_SIGNATURE]: this.onSignature,
46
46
  [converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
47
47
  });
48
48
  }
@@ -77,6 +77,16 @@ let SourcePlugin = class SourcePlugin extends components_1.ConverterComponent {
77
77
  reflection.sources.push(new models_1.SourceReference(fileName, position.line + 1, position.character));
78
78
  }
79
79
  }
80
+ onSignature(_context, reflection, sig) {
81
+ if (this.disableSources || !sig)
82
+ return;
83
+ const sourceFile = sig.getSourceFile();
84
+ const fileName = sourceFile.fileName;
85
+ this.fileNames.add(fileName);
86
+ const position = ts.getLineAndCharacterOfPosition(sourceFile, sig.getStart());
87
+ reflection.sources || (reflection.sources = []);
88
+ reflection.sources.push(new models_1.SourceReference(fileName, position.line + 1, position.character));
89
+ }
80
90
  /**
81
91
  * Triggered when the converter begins resolving a project.
82
92
  *
@@ -44,11 +44,19 @@ class Repository {
44
44
  this.path = path;
45
45
  this.branch = gitRevision || "master";
46
46
  for (let i = 0, c = repoLinks.length; i < c; i++) {
47
- let match = /(github(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
47
+ let match = /(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
48
48
  // Github Enterprise
49
49
  if (!match) {
50
50
  match = /(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
51
51
  }
52
+ // Github Enterprise
53
+ if (!match) {
54
+ match = /(\w+\.ghe.com)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
55
+ }
56
+ // Github Enterprise
57
+ if (!match) {
58
+ match = /(\w+\.github.us)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
59
+ }
52
60
  if (!match) {
53
61
  match = /(bitbucket.org)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
54
62
  }
@@ -45,4 +45,9 @@ export declare namespace ReflectionKind {
45
45
  const Inheritable: number;
46
46
  /** @internal */
47
47
  const ContainsCallSignatures: number;
48
+ /**
49
+ * Note: This does not include Class/Interface, even though they technically could contain index signatures
50
+ * @internal
51
+ */
52
+ const SignatureContainer: number;
48
53
  }
@@ -78,4 +78,9 @@ var ReflectionKind;
78
78
  ReflectionKind.ContainsCallSignatures = ReflectionKind.Constructor |
79
79
  ReflectionKind.Function |
80
80
  ReflectionKind.Method;
81
+ /**
82
+ * Note: This does not include Class/Interface, even though they technically could contain index signatures
83
+ * @internal
84
+ */
85
+ ReflectionKind.SignatureContainer = ReflectionKind.ContainsCallSignatures | ReflectionKind.Accessor;
81
86
  })(ReflectionKind = exports.ReflectionKind || (exports.ReflectionKind = {}));
@@ -36,7 +36,8 @@ function reflectionTemplate(context, props) {
36
36
  context.type(props.model.indexSignature.type)),
37
37
  context.comment(props.model.indexSignature),
38
38
  props.model.indexSignature?.type instanceof models_1.ReflectionType &&
39
- context.parameter(props.model.indexSignature.type.declaration))))),
39
+ context.parameter(props.model.indexSignature.type.declaration))),
40
+ !props.model.signatures && context.memberSources(props.model))),
40
41
  !!props.model.children?.length && context.index(props.model),
41
42
  context.members(props.model)));
42
43
  }
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.23.7",
4
+ "version": "0.23.8",
5
5
  "homepage": "https://typedoc.org",
6
6
  "main": "./dist/index.js",
7
7
  "exports": {
package/static/style.css CHANGED
@@ -942,7 +942,7 @@ a.tsd-index-link {
942
942
  margin: 2rem 0;
943
943
  }
944
944
  .tsd-panel-group.tsd-index-group details {
945
- margin: 4rem 0;
945
+ margin: 2rem 0;
946
946
  }
947
947
 
948
948
  #tsd-search {