typedoc 0.24.4 → 0.24.6

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 (36) hide show
  1. package/dist/lib/application.js +12 -5
  2. package/dist/lib/converter/comments/blockLexer.js +20 -8
  3. package/dist/lib/converter/comments/discovery.d.ts +5 -0
  4. package/dist/lib/converter/comments/discovery.js +14 -1
  5. package/dist/lib/converter/comments/index.d.ts +1 -0
  6. package/dist/lib/converter/comments/index.js +6 -1
  7. package/dist/lib/converter/comments/parser.js +17 -4
  8. package/dist/lib/converter/context.d.ts +1 -0
  9. package/dist/lib/converter/context.js +3 -0
  10. package/dist/lib/converter/converter.js +6 -2
  11. package/dist/lib/converter/plugins/GroupPlugin.d.ts +6 -0
  12. package/dist/lib/converter/plugins/GroupPlugin.js +32 -3
  13. package/dist/lib/output/themes/MarkedPlugin.js +20 -2
  14. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  15. package/dist/lib/output/themes/default/partials/comment.js +5 -1
  16. package/dist/lib/output/themes/default/partials/member.declaration.js +1 -1
  17. package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +3 -3
  18. package/dist/lib/output/themes/default/partials/member.signature.body.js +28 -24
  19. package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -1
  20. package/dist/lib/output/themes/default/partials/navigation.js +38 -13
  21. package/dist/lib/output/themes/default/partials/type.js +1 -1
  22. package/dist/lib/output/themes/default/partials/typeParameters.js +2 -2
  23. package/dist/lib/output/themes/lib.d.ts +2 -1
  24. package/dist/lib/output/themes/lib.js +19 -4
  25. package/dist/lib/utils/entry-point.js +27 -6
  26. package/dist/lib/utils/fs.js +2 -1
  27. package/dist/lib/utils/html.d.ts +1 -0
  28. package/dist/lib/utils/html.js +12 -1
  29. package/dist/lib/utils/jsx.elements.d.ts +52 -0
  30. package/dist/lib/utils/jsx.js +2 -11
  31. package/dist/lib/utils/options/declaration.d.ts +15 -0
  32. package/dist/lib/utils/options/sources/typedoc.js +92 -57
  33. package/dist/lib/utils/package-manifest.js +6 -0
  34. package/package.json +1 -1
  35. package/static/main.js +3 -3
  36. package/static/style.css +56 -29
@@ -373,11 +373,18 @@ let Application = Application_1 = class Application extends component_1.Childabl
373
373
  _merge() {
374
374
  const start = Date.now();
375
375
  const rootDir = (0, fs_1.deriveRootDir)(this.entryPoints);
376
- this.logger.verbose(`Derived root dir is ${rootDir}, will expand ${this.entryPoints
377
- .map(index_2.normalizePath)
378
- .join(", ")}`);
379
- const entryPoints = this.entryPoints.flatMap((entry) => (0, fs_1.glob)(entry, rootDir));
380
- this.logger.verbose(`Merging entry points:\n\t${entryPoints.map(paths_1.nicePath).join("\n\t")}`);
376
+ const entryPoints = this.entryPoints.flatMap((entry) => {
377
+ const result = (0, fs_1.glob)(entry, rootDir);
378
+ if (result.length === 0) {
379
+ this.logger.warn(`The entrypoint glob ${(0, paths_1.nicePath)(entry)} did not match any files.`);
380
+ }
381
+ else {
382
+ this.logger.verbose(`Expanded ${(0, paths_1.nicePath)(entry)} to:\n\t${result
383
+ .map(paths_1.nicePath)
384
+ .join("\n\t")}`);
385
+ }
386
+ return result;
387
+ });
381
388
  if (entryPoints.length < 1) {
382
389
  this.logger.error("No entry points provided to merge.");
383
390
  return;
@@ -36,14 +36,26 @@ function* lexBlockComment(file, pos = 0, end = file.length, jsDoc = undefined, c
36
36
  exports.lexBlockComment = lexBlockComment;
37
37
  function getLinkTags(jsDoc) {
38
38
  const result = [];
39
- if (!jsDoc || typeof jsDoc.comment !== "object")
40
- return result;
41
- for (const part of jsDoc.comment) {
42
- switch (part.kind) {
43
- case typescript_1.default.SyntaxKind.JSDocLink:
44
- case typescript_1.default.SyntaxKind.JSDocLinkCode:
45
- case typescript_1.default.SyntaxKind.JSDocLinkPlain:
46
- result.push(part);
39
+ if (jsDoc?.comment && typeof jsDoc.comment !== "string") {
40
+ for (const part of jsDoc.comment) {
41
+ switch (part.kind) {
42
+ case typescript_1.default.SyntaxKind.JSDocLink:
43
+ case typescript_1.default.SyntaxKind.JSDocLinkCode:
44
+ case typescript_1.default.SyntaxKind.JSDocLinkPlain:
45
+ result.push(part);
46
+ }
47
+ }
48
+ }
49
+ for (const block of jsDoc?.tags || []) {
50
+ if (!block.comment || typeof block.comment === "string")
51
+ continue;
52
+ for (const part of block.comment) {
53
+ switch (part.kind) {
54
+ case typescript_1.default.SyntaxKind.JSDocLink:
55
+ case typescript_1.default.SyntaxKind.JSDocLinkCode:
56
+ case typescript_1.default.SyntaxKind.JSDocLinkPlain:
57
+ result.push(part);
58
+ }
47
59
  }
48
60
  }
49
61
  return result;
@@ -7,5 +7,10 @@ export interface DiscoveredComment {
7
7
  ranges: ts.CommentRange[];
8
8
  jsDoc: ts.JSDoc | undefined;
9
9
  }
10
+ export declare function discoverFileComment(node: ts.SourceFile, commentStyle: CommentStyle): {
11
+ file: ts.SourceFile;
12
+ ranges: ts.CommentRange[];
13
+ jsDoc: ts.JSDoc | undefined;
14
+ } | undefined;
10
15
  export declare function discoverComment(symbol: ts.Symbol, kind: ReflectionKind, logger: Logger, commentStyle: CommentStyle): DiscoveredComment | undefined;
11
16
  export declare function discoverSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, commentStyle: CommentStyle): DiscoveredComment | undefined;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.discoverSignatureComment = exports.discoverComment = void 0;
6
+ exports.discoverSignatureComment = exports.discoverComment = exports.discoverFileComment = void 0;
7
7
  const typescript_1 = __importDefault(require("typescript"));
8
8
  const models_1 = require("../../models");
9
9
  const utils_1 = require("../../utils");
@@ -98,6 +98,19 @@ const wantedKinds = {
98
98
  typescript_1.default.SyntaxKind.ExportSpecifier,
99
99
  ],
100
100
  };
101
+ function discoverFileComment(node, commentStyle) {
102
+ const text = node.text;
103
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
104
+ const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
105
+ if (selectedDocComment) {
106
+ return {
107
+ file: node,
108
+ ranges: selectedDocComment,
109
+ jsDoc: findJsDocForComment(node, selectedDocComment),
110
+ };
111
+ }
112
+ }
113
+ exports.discoverFileComment = discoverFileComment;
101
114
  function discoverComment(symbol, kind, logger, commentStyle) {
102
115
  // For a module comment, we want the first one defined in the file,
103
116
  // not the last one, since that will apply to the import or declaration.
@@ -10,5 +10,6 @@ export interface CommentParserConfig {
10
10
  }
11
11
  export declare function clearCommentCache(): void;
12
12
  export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
13
+ export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
13
14
  export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
14
15
  export declare function getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined): Comment | undefined;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getJsDocComment = exports.getSignatureComment = exports.getComment = exports.clearCommentCache = void 0;
6
+ exports.getJsDocComment = exports.getSignatureComment = exports.getFileComment = exports.getComment = exports.clearCommentCache = void 0;
7
7
  const typescript_1 = __importDefault(require("typescript"));
8
8
  const models_1 = require("../../models");
9
9
  const utils_1 = require("../../utils");
@@ -81,6 +81,11 @@ function getComment(symbol, kind, config, logger, commentStyle, checker) {
81
81
  return comment;
82
82
  }
83
83
  exports.getComment = getComment;
84
+ function getFileComment(file, config, logger, commentStyle, checker) {
85
+ return getCommentImpl((0, discovery_1.discoverFileComment)(file, commentStyle), config, logger,
86
+ /* moduleComment */ true, checker);
87
+ }
88
+ exports.getFileComment = getFileComment;
84
89
  function getConstructorParamPropertyComment(symbol, config, logger, commentStyle, checker) {
85
90
  const decl = symbol.declarations?.find(typescript_1.default.isParameter);
86
91
  if (!decl)
@@ -105,6 +105,11 @@ function postProcessComment(comment, warning) {
105
105
  warning("At most one @remarks tag is expected in a comment, ignoring all but the first");
106
106
  (0, utils_1.removeIf)(comment.blockTags, (tag) => remarks.indexOf(tag) > 0);
107
107
  }
108
+ const returns = comment.blockTags.filter((tag) => tag.tag === "@returns");
109
+ if (remarks.length > 1) {
110
+ warning("At most one @returns tag is expected in a comment, ignoring all but the first");
111
+ (0, utils_1.removeIf)(comment.blockTags, (tag) => returns.indexOf(tag) > 0);
112
+ }
108
113
  const inheritDoc = comment.blockTags.filter((tag) => tag.tag === "@inheritDoc");
109
114
  const inlineInheritDoc = comment.summary.filter((part) => part.kind === "inline-tag" && part.tag === "@inheritDoc");
110
115
  if (inlineInheritDoc.length + inheritDoc.length > 1) {
@@ -223,7 +228,9 @@ function blockContent(comment, lexer, config, warning) {
223
228
  break;
224
229
  case lexer_1.TokenSyntaxKind.Tag:
225
230
  if (next.text === "@inheritdoc") {
226
- warning("The @inheritDoc tag should be properly capitalized", next);
231
+ if (!config.jsDocCompatibility.inheritDocTag) {
232
+ warning("The @inheritDoc tag should be properly capitalized", next);
233
+ }
227
234
  next.text = "@inheritDoc";
228
235
  }
229
236
  if (config.modifierTags.has(next.text)) {
@@ -246,7 +253,9 @@ function blockContent(comment, lexer, config, warning) {
246
253
  break;
247
254
  case lexer_1.TokenSyntaxKind.CloseBrace:
248
255
  // Unmatched closing brace, generate a warning, and treat it as text.
249
- warning(`Unmatched closing brace`, next);
256
+ if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
257
+ warning(`Unmatched closing brace`, next);
258
+ }
250
259
  content.push({ kind: "text", text: next.text });
251
260
  break;
252
261
  case lexer_1.TokenSyntaxKind.OpenBrace:
@@ -294,7 +303,9 @@ function inlineTag(lexer, block, config, warning) {
294
303
  // then produce a warning and treat what we've consumed as plain text.
295
304
  if (lexer.done() ||
296
305
  ![lexer_1.TokenSyntaxKind.Text, lexer_1.TokenSyntaxKind.Tag].includes(lexer.peek().kind)) {
297
- warning("Encountered an unescaped open brace without an inline tag", openBrace);
306
+ if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
307
+ warning("Encountered an unescaped open brace without an inline tag", openBrace);
308
+ }
298
309
  block.push({ kind: "text", text: openBrace.text });
299
310
  return;
300
311
  }
@@ -303,7 +314,9 @@ function inlineTag(lexer, block, config, warning) {
303
314
  (tagName.kind === lexer_1.TokenSyntaxKind.Text &&
304
315
  (!/^\s+$/.test(tagName.text) ||
305
316
  lexer.peek().kind != lexer_1.TokenSyntaxKind.Tag))) {
306
- warning("Encountered an unescaped open brace without an inline tag", openBrace);
317
+ if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
318
+ warning("Encountered an unescaped open brace without an inline tag", openBrace);
319
+ }
307
320
  block.push({ kind: "text", text: openBrace.text + tagName.text });
308
321
  return;
309
322
  }
@@ -79,6 +79,7 @@ export declare class Context {
79
79
  /** @internal */
80
80
  setActiveProgram(program: ts.Program | undefined): void;
81
81
  getComment(symbol: ts.Symbol, kind: ReflectionKind): import("../models/index").Comment | undefined;
82
+ getFileComment(node: ts.SourceFile): import("../models/index").Comment | undefined;
82
83
  getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag): import("../models/index").Comment | undefined;
83
84
  getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature): import("../models/index").Comment | undefined;
84
85
  /**
@@ -176,6 +176,9 @@ class Context {
176
176
  getComment(symbol, kind) {
177
177
  return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
178
178
  }
179
+ getFileComment(node) {
180
+ return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
181
+ }
179
182
  getJsDocComment(declaration) {
180
183
  return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.converter.useTsLinkResolution ? this.checker : undefined);
181
184
  }
@@ -163,13 +163,17 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
163
163
  // Special case for when we're giving a single entry point, we don't need to
164
164
  // create modules for each entry. Register the project as this module.
165
165
  context.project.registerReflection(context.project, symbol);
166
- context.project.comment =
167
- symbol && context.getComment(symbol, context.project.kind);
166
+ context.project.comment = symbol
167
+ ? context.getComment(symbol, context.project.kind)
168
+ : context.getFileComment(node);
168
169
  context.trigger(Converter_1.EVENT_CREATE_DECLARATION, context.project);
169
170
  moduleContext = context;
170
171
  }
171
172
  else {
172
173
  const reflection = context.createDeclarationReflection(index_1.ReflectionKind.Module, symbol, void 0, entryName);
174
+ if (!reflection.comment && !symbol) {
175
+ reflection.comment = context.getFileComment(node);
176
+ }
173
177
  if (entryPoint.readmeFile) {
174
178
  const readme = (0, utils_1.readFile)(entryPoint.readmeFile);
175
179
  const comment = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile));
@@ -9,7 +9,9 @@ import { ConverterComponent } from "../components";
9
9
  export declare class GroupPlugin extends ConverterComponent {
10
10
  sortFunction: (reflections: DeclarationReflection[]) => void;
11
11
  boosts: Record<string, number>;
12
+ groupOrder: string[];
12
13
  usedBoosts: Set<string>;
14
+ static WEIGHTS: string[];
13
15
  /**
14
16
  * Create a new GroupPlugin instance.
15
17
  */
@@ -44,4 +46,8 @@ export declare class GroupPlugin extends ConverterComponent {
44
46
  * @returns An array containing all children of the given reflection grouped by their kind.
45
47
  */
46
48
  getReflectionGroups(reflections: DeclarationReflection[]): ReflectionGroup[];
49
+ /**
50
+ * Callback used to sort groups by name.
51
+ */
52
+ static sortGroupCallback(a: ReflectionGroup, b: ReflectionGroup): number;
47
53
  }
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var GroupPlugin_1;
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.GroupPlugin = void 0;
10
11
  const index_1 = require("../../models/reflections/index");
@@ -19,7 +20,7 @@ const models_1 = require("../../models");
19
20
  *
20
21
  * The handler sets the `groups` property of all container reflections.
21
22
  */
22
- let GroupPlugin = class GroupPlugin extends components_1.ConverterComponent {
23
+ let GroupPlugin = GroupPlugin_1 = class GroupPlugin extends components_1.ConverterComponent {
23
24
  constructor() {
24
25
  super(...arguments);
25
26
  this.usedBoosts = new Set();
@@ -31,6 +32,7 @@ let GroupPlugin = class GroupPlugin extends components_1.ConverterComponent {
31
32
  this.listenTo(this.owner, {
32
33
  [converter_1.Converter.EVENT_RESOLVE_BEGIN]: () => {
33
34
  this.sortFunction = (0, sort_1.getSortFunction)(this.application.options);
35
+ GroupPlugin_1.WEIGHTS = this.groupOrder;
34
36
  },
35
37
  [converter_1.Converter.EVENT_RESOLVE]: this.onResolve,
36
38
  [converter_1.Converter.EVENT_RESOLVE_END]: this.onEndResolve,
@@ -135,13 +137,40 @@ let GroupPlugin = class GroupPlugin extends components_1.ConverterComponent {
135
137
  group.children.push(child);
136
138
  }
137
139
  });
138
- return Array.from(groups.values());
140
+ return Array.from(groups.values()).sort(GroupPlugin_1.sortGroupCallback);
141
+ }
142
+ /**
143
+ * Callback used to sort groups by name.
144
+ */
145
+ static sortGroupCallback(a, b) {
146
+ let aWeight = GroupPlugin_1.WEIGHTS.indexOf(a.title);
147
+ let bWeight = GroupPlugin_1.WEIGHTS.indexOf(b.title);
148
+ if (aWeight === -1 || bWeight === -1) {
149
+ let asteriskIndex = GroupPlugin_1.WEIGHTS.indexOf("*");
150
+ if (asteriskIndex === -1) {
151
+ asteriskIndex = GroupPlugin_1.WEIGHTS.length;
152
+ }
153
+ if (aWeight === -1) {
154
+ aWeight = asteriskIndex;
155
+ }
156
+ if (bWeight === -1) {
157
+ bWeight = asteriskIndex;
158
+ }
159
+ }
160
+ if (aWeight === bWeight) {
161
+ return a.title > b.title ? 1 : -1;
162
+ }
163
+ return aWeight - bWeight;
139
164
  }
140
165
  };
166
+ GroupPlugin.WEIGHTS = [];
141
167
  __decorate([
142
168
  (0, utils_1.BindOption)("searchGroupBoosts")
143
169
  ], GroupPlugin.prototype, "boosts", void 0);
144
- GroupPlugin = __decorate([
170
+ __decorate([
171
+ (0, utils_1.BindOption)("groupOrder")
172
+ ], GroupPlugin.prototype, "groupOrder", void 0);
173
+ GroupPlugin = GroupPlugin_1 = __decorate([
145
174
  (0, components_1.Component)({ name: "group" })
146
175
  ], GroupPlugin);
147
176
  exports.GroupPlugin = GroupPlugin;
@@ -165,14 +165,15 @@ output file :
165
165
  markedOptions.renderer = new Marked.Renderer();
166
166
  markedOptions.renderer.heading = (text, level, _, slugger) => {
167
167
  const slug = slugger.slug(text);
168
- // Prefix the slug with an extra `$` to prevent conflicts with TypeDoc's anchors.
168
+ // Prefix the slug with an extra `md:` to prevent conflicts with TypeDoc's anchors.
169
169
  this.page.pageHeadings.push({
170
170
  link: `#md:${slug}`,
171
171
  text: (0, html_1.getTextContent)(text),
172
172
  level,
173
173
  });
174
- return `<a id="md:${slug}" class="tsd-anchor"></a><h${level}><a href="#$${slug}" style="color:inherit;text-decoration:none">${text}</a></h${level}>`;
174
+ return `<a id="md:${slug}" class="tsd-anchor"></a><h${level}><a href="#md:${slug}">${text}</a></h${level}>`;
175
175
  };
176
+ markedOptions.renderer.code = renderCode;
176
177
  }
177
178
  markedOptions.mangle ?? (markedOptions.mangle = false); // See https://github.com/TypeStrong/typedoc/issues/1395
178
179
  return markedOptions;
@@ -202,3 +203,20 @@ MarkedPlugin = __decorate([
202
203
  (0, components_1.Component)({ name: "marked" })
203
204
  ], MarkedPlugin);
204
205
  exports.MarkedPlugin = MarkedPlugin;
206
+ // Basically a copy/paste of Marked's code, with the addition of the button
207
+ // https://github.com/markedjs/marked/blob/v4.3.0/src/Renderer.js#L15-L39
208
+ function renderCode(code, infostring, escaped) {
209
+ const lang = (infostring || "").match(/\S*/)[0];
210
+ if (this.options.highlight) {
211
+ const out = this.options.highlight(code, lang);
212
+ if (out != null && out !== code) {
213
+ escaped = true;
214
+ code = out;
215
+ }
216
+ }
217
+ code = code.replace(/\n$/, "") + "\n";
218
+ if (!lang) {
219
+ return `<pre><code>${escaped ? code : (0, html_1.escapeHtml)(code)}</code><button>Copy</button></pre>\n`;
220
+ }
221
+ return `<pre><code class="${this.options.langPrefix + (0, html_1.escapeHtml)(lang)}">${escaped ? code : (0, html_1.escapeHtml)(code)}</code><button>Copy</button></pre>\n`;
222
+ }
@@ -1,4 +1,4 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
2
2
  import { JSX } from "../../../../utils";
3
- import type { Reflection } from "../../../../models";
3
+ import { Reflection } from "../../../../models";
4
4
  export declare function comment({ markdown }: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined;
@@ -2,14 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.comment = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
+ const models_1 = require("../../../../models");
5
6
  const lib_1 = require("../../lib");
6
7
  function comment({ markdown }, props) {
7
8
  if (!props.comment?.hasVisibleComponent())
8
9
  return;
9
10
  // Note: Comment modifiers are handled in `renderFlags`
11
+ const tags = props.kindOf(models_1.ReflectionKind.SomeSignature)
12
+ ? props.comment.blockTags.filter((tag) => tag.tag !== "@returns")
13
+ : props.comment.blockTags;
10
14
  return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" },
11
15
  utils_1.JSX.createElement(utils_1.Raw, { html: markdown(props.comment.summary) }),
12
- props.comment.blockTags.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
16
+ tags.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
13
17
  utils_1.JSX.createElement("h3", null, (0, lib_1.camelToTitleCase)(item.tag.substring(1))),
14
18
  utils_1.JSX.createElement(utils_1.Raw, { html: markdown(item.content) }))))));
15
19
  }
@@ -7,7 +7,7 @@ const lib_1 = require("../../lib");
7
7
  const memberDeclaration = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
8
  utils_1.JSX.createElement("div", { class: "tsd-signature" },
9
9
  utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) }, (0, lib_1.wbr)(props.name)),
10
- (0, lib_1.renderTypeParametersSignature)(props.typeParameters),
10
+ (0, lib_1.renderTypeParametersSignature)(context, props.typeParameters),
11
11
  props.type && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
12
12
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" },
13
13
  !!props.flags.isOptional && "?",
@@ -1,6 +1,6 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
2
2
  import { JSX } from "../../../../utils";
3
3
  import { SignatureReflection } from "../../../../models";
4
- export declare const memberSignatureBody: (context: DefaultThemeRenderContext, props: SignatureReflection, { hideSources }?: {
5
- hideSources?: boolean | undefined;
6
- }) => JSX.Element;
4
+ export declare function memberSignatureBody(context: DefaultThemeRenderContext, props: SignatureReflection, { hideSources }?: {
5
+ hideSources?: boolean;
6
+ }): JSX.Element;
@@ -4,28 +4,32 @@ exports.memberSignatureBody = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
5
  const models_1 = require("../../../../models");
6
6
  const lib_1 = require("../../lib");
7
- const memberSignatureBody = (context, props, { hideSources = false } = {}) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
- (0, lib_1.renderFlags)(props.flags, props.comment),
9
- context.comment(props),
10
- (0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters),
11
- props.parameters && props.parameters.length > 0 && (utils_1.JSX.createElement("div", { class: "tsd-parameters" },
12
- utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, "Parameters"),
13
- utils_1.JSX.createElement("ul", { class: "tsd-parameter-list" }, props.parameters.map((item) => (utils_1.JSX.createElement("li", null,
14
- utils_1.JSX.createElement("h5", null,
15
- (0, lib_1.renderFlags)(item.flags, item.comment),
16
- !!item.flags.isRest && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "..."),
17
- utils_1.JSX.createElement("span", { class: "tsd-kind-parameter" }, item.name),
18
- ": ",
19
- context.type(item.type),
20
- item.defaultValue != null && (utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" },
21
- " = ",
22
- item.defaultValue))),
23
- context.comment(item),
24
- item.type instanceof models_1.ReflectionType && context.parameter(item.type.declaration))))))),
25
- props.type && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
26
- utils_1.JSX.createElement("h4", { class: "tsd-returns-title" },
27
- "Returns ",
28
- context.type(props.type)),
29
- props.type instanceof models_1.ReflectionType && context.parameter(props.type.declaration))),
30
- !hideSources && context.memberSources(props)));
7
+ function memberSignatureBody(context, props, { hideSources = false } = {}) {
8
+ const returnsTag = props.comment?.getTag("@returns");
9
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
10
+ (0, lib_1.renderFlags)(props.flags, props.comment),
11
+ context.comment(props),
12
+ (0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters),
13
+ props.parameters && props.parameters.length > 0 && (utils_1.JSX.createElement("div", { class: "tsd-parameters" },
14
+ utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, "Parameters"),
15
+ utils_1.JSX.createElement("ul", { class: "tsd-parameter-list" }, props.parameters.map((item) => (utils_1.JSX.createElement("li", null,
16
+ utils_1.JSX.createElement("h5", null,
17
+ (0, lib_1.renderFlags)(item.flags, item.comment),
18
+ !!item.flags.isRest && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "..."),
19
+ utils_1.JSX.createElement("span", { class: "tsd-kind-parameter" }, item.name),
20
+ ": ",
21
+ context.type(item.type),
22
+ item.defaultValue != null && (utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" },
23
+ " = ",
24
+ item.defaultValue))),
25
+ context.comment(item),
26
+ item.type instanceof models_1.ReflectionType && context.parameter(item.type.declaration))))))),
27
+ props.type && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
28
+ utils_1.JSX.createElement("h4", { class: "tsd-returns-title" },
29
+ "Returns ",
30
+ context.type(props.type)),
31
+ returnsTag && utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(returnsTag.content) }),
32
+ props.type instanceof models_1.ReflectionType && context.parameter(props.type.declaration))),
33
+ !hideSources && context.memberSources(props)));
34
+ }
31
35
  exports.memberSignatureBody = memberSignatureBody;
@@ -27,7 +27,7 @@ function memberSignatureTitle(context, props, { hideName = false, arrowStyle = f
27
27
  !hideName ? (utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) }, (0, lib_1.wbr)(props.name))) : (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.kind === models_1.ReflectionKind.ConstructorSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
28
28
  !!props.flags.isAbstract && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "abstract "),
29
29
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "new "))))),
30
- (0, lib_1.renderTypeParametersSignature)(props.typeParameters),
30
+ (0, lib_1.renderTypeParametersSignature)(context, props.typeParameters),
31
31
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("),
32
32
  (0, lib_1.join)(", ", props.parameters ?? [], renderParam),
33
33
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ")"),
@@ -62,29 +62,54 @@ function settings(context) {
62
62
  utils_1.JSX.createElement("option", { value: "dark" }, "Dark")))))));
63
63
  }
64
64
  exports.settings = settings;
65
+ function getNavigationElements(parent, opts) {
66
+ if (parent instanceof models_1.ReflectionCategory) {
67
+ return parent.children;
68
+ }
69
+ if (parent instanceof models_1.ReflectionGroup) {
70
+ if (opts.includeCategories && parent.categories) {
71
+ return parent.categories;
72
+ }
73
+ return parent.children;
74
+ }
75
+ if (!parent.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
76
+ return [];
77
+ }
78
+ if (parent.categories && opts.includeCategories) {
79
+ return parent.categories;
80
+ }
81
+ if (parent.groups && opts.includeGroups) {
82
+ return parent.groups;
83
+ }
84
+ return parent.children || [];
85
+ }
65
86
  function navigation(context, props) {
87
+ const opts = context.options.getValue("navigation");
66
88
  // Create the navigation for the current page
67
89
  // Recurse to children if the parent is some kind of module
68
90
  return (utils_1.JSX.createElement("nav", { class: "tsd-navigation" },
69
- link(props.project),
70
- utils_1.JSX.createElement("ul", { class: "tsd-small-nested-navigation" }, props.project.children?.map((c) => (utils_1.JSX.createElement("li", null, links(c)))))));
71
- function links(mod) {
72
- const children = (mod.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project) && mod.children) || [];
73
- const nameClasses = (0, lib_1.classNames)({ deprecated: mod.isDeprecated() }, mod.isProject() ? void 0 : context.getReflectionClasses(mod));
91
+ createNavElement(props.project),
92
+ utils_1.JSX.createElement("ul", { class: "tsd-small-nested-navigation" }, getNavigationElements(props.project, opts).map((c) => (utils_1.JSX.createElement("li", null, links(c, [])))))));
93
+ function links(mod, parents) {
94
+ const nameClasses = (0, lib_1.classNames)({ deprecated: mod instanceof models_1.Reflection && mod.isDeprecated() }, !(mod instanceof models_1.Reflection) || mod.isProject() ? void 0 : context.getReflectionClasses(mod));
95
+ const children = getNavigationElements(mod, opts);
74
96
  if (!children.length) {
75
- return link(mod, nameClasses);
97
+ return createNavElement(mod, nameClasses);
76
98
  }
77
- return (utils_1.JSX.createElement("details", { class: (0, lib_1.classNames)({ "tsd-index-accordion": true }, nameClasses), open: inPath(mod), "data-key": mod.getFullName() },
99
+ return (utils_1.JSX.createElement("details", { class: (0, lib_1.classNames)({ "tsd-index-accordion": true }, nameClasses), open: mod instanceof models_1.Reflection && inPath(mod), "data-key": mod instanceof models_1.Reflection ? mod.getFullName() : [...parents, mod.title].join("$") },
78
100
  utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary" },
79
101
  context.icons.chevronDown(),
80
- link(mod)),
102
+ createNavElement(mod)),
81
103
  utils_1.JSX.createElement("div", { class: "tsd-accordion-details" },
82
- utils_1.JSX.createElement("ul", { class: "tsd-nested-navigation" }, children.map((c) => (utils_1.JSX.createElement("li", null, links(c))))))));
104
+ utils_1.JSX.createElement("ul", { class: "tsd-nested-navigation" }, children.map((c) => (utils_1.JSX.createElement("li", null, links(c, mod instanceof models_1.Reflection ? [mod.getFullName()] : [...parents, mod.title]))))))));
83
105
  }
84
- function link(child, nameClasses) {
85
- return (utils_1.JSX.createElement("a", { href: context.urlTo(child), class: (0, lib_1.classNames)({ current: child === props.model }, nameClasses) },
86
- context.icons[child.kind](),
87
- utils_1.JSX.createElement("span", null, (0, lib_1.wbr)((0, lib_1.getDisplayName)(child)))));
106
+ function createNavElement(child, nameClasses) {
107
+ if (child instanceof models_1.Reflection) {
108
+ return (utils_1.JSX.createElement("a", { href: context.urlTo(child), class: (0, lib_1.classNames)({ current: child === props.model }, nameClasses) },
109
+ context.icons[child.kind](),
110
+ utils_1.JSX.createElement("span", null, (0, lib_1.wbr)((0, lib_1.getDisplayName)(child)))));
111
+ }
112
+ return utils_1.JSX.createElement("span", null, child.title);
88
113
  }
89
114
  function inPath(mod) {
90
115
  let iter = props.model;
@@ -171,7 +171,7 @@ const typeRenderers = {
171
171
  predicate(context, type) {
172
172
  return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
173
173
  !!type.asserts && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "asserts "),
174
- utils_1.JSX.createElement("span", { class: "tsd-signature-type" }, type.name),
174
+ utils_1.JSX.createElement("span", { class: "tsd-kind-parameter" }, type.name),
175
175
  !!type.targetType && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
176
176
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " is "),
177
177
  renderType(context, type.targetType, models_1.TypeContext.predicateTarget)))));
@@ -4,9 +4,9 @@ exports.typeParameters = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
5
  function typeParameters(context, typeParameters) {
6
6
  return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
7
- utils_1.JSX.createElement("section", { class: "tsd-panel tsd-type-parameters" },
7
+ utils_1.JSX.createElement("section", { class: "tsd-panel" },
8
8
  utils_1.JSX.createElement("h4", null, "Type Parameters"),
9
- utils_1.JSX.createElement("ul", { class: "tsd-type-parameters" }, typeParameters?.map((item) => (utils_1.JSX.createElement("li", null,
9
+ utils_1.JSX.createElement("ul", { class: "tsd-type-parameter-list" }, typeParameters?.map((item) => (utils_1.JSX.createElement("li", null,
10
10
  utils_1.JSX.createElement("h4", null,
11
11
  item.flags.isConst && "const ",
12
12
  item.varianceModifier ? `${item.varianceModifier} ` : "",
@@ -1,3 +1,4 @@
1
+ import type { DefaultThemeRenderContext } from "..";
1
2
  import { Comment, Reflection, ReflectionFlags, TypeParameterReflection } from "../../models";
2
3
  import { JSX } from "../../utils";
3
4
  export declare function stringify(data: unknown): string;
@@ -19,7 +20,7 @@ export declare function classNames(names: Record<string, boolean | null | undefi
19
20
  export declare function hasTypeParameters(reflection: Reflection): reflection is Reflection & {
20
21
  typeParameters: TypeParameterReflection[];
21
22
  };
22
- export declare function renderTypeParametersSignature(typeParameters: readonly TypeParameterReflection[] | undefined): JSX.Element;
23
+ export declare function renderTypeParametersSignature(context: DefaultThemeRenderContext, typeParameters: readonly TypeParameterReflection[] | undefined): JSX.Element;
23
24
  export declare function camelToTitleCase(text: string): string;
24
25
  /**
25
26
  * Renders the reflection name with an additional `?` if optional.
@@ -88,14 +88,29 @@ function hasTypeParameters(reflection) {
88
88
  reflection.typeParameters.length > 0);
89
89
  }
90
90
  exports.hasTypeParameters = hasTypeParameters;
91
- function renderTypeParametersSignature(typeParameters) {
92
- return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, !!typeParameters && typeParameters.length > 0 && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
91
+ function renderTypeParametersSignature(context, typeParameters) {
92
+ if (!typeParameters || typeParameters.length === 0)
93
+ return utils_1.JSX.createElement(utils_1.JSX.Fragment, null);
94
+ const hideParamTypes = context.options.getValue("hideParameterTypesInTitle");
95
+ if (hideParamTypes) {
96
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
97
+ utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "<"),
98
+ join(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ", "), typeParameters, (item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
99
+ item.flags.isConst && "const ",
100
+ item.varianceModifier ? `${item.varianceModifier} ` : "",
101
+ utils_1.JSX.createElement("span", { class: "tsd-signature-type tsd-kind-type-parameter" }, item.name)))),
102
+ utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ">")));
103
+ }
104
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
93
105
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "<"),
94
106
  join(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ", "), typeParameters, (item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
95
107
  item.flags.isConst && "const ",
96
108
  item.varianceModifier ? `${item.varianceModifier} ` : "",
97
- utils_1.JSX.createElement("span", { class: "tsd-signature-type tsd-kind-type-parameter" }, item.name)))),
98
- utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ">")))));
109
+ utils_1.JSX.createElement("span", { class: "tsd-signature-type tsd-kind-type-parameter" }, item.name),
110
+ !!item.type && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
111
+ utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, " extends "),
112
+ context.type(item.type)))))),
113
+ utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ">")));
99
114
  }
100
115
  exports.renderTypeParametersSignature = renderTypeParametersSignature;
101
116
  function camelToTitleCase(text) {