typedoc 0.26.0-beta.1 → 0.26.0-beta.3

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 (109) hide show
  1. package/dist/lib/application.d.ts +2 -0
  2. package/dist/lib/application.js +12 -3
  3. package/dist/lib/cli.js +1 -0
  4. package/dist/lib/converter/comments/declarationReference.d.ts +1 -0
  5. package/dist/lib/converter/comments/declarationReference.js +14 -0
  6. package/dist/lib/converter/comments/declarationReferenceResolver.js +4 -2
  7. package/dist/lib/converter/comments/discovery.js +9 -2
  8. package/dist/lib/converter/comments/index.d.ts +6 -5
  9. package/dist/lib/converter/comments/index.js +21 -21
  10. package/dist/lib/converter/comments/parser.d.ts +3 -2
  11. package/dist/lib/converter/comments/parser.js +26 -17
  12. package/dist/lib/converter/comments/textParser.d.ts +16 -0
  13. package/dist/lib/converter/comments/textParser.js +190 -0
  14. package/dist/lib/converter/context.d.ts +2 -2
  15. package/dist/lib/converter/context.js +13 -8
  16. package/dist/lib/converter/converter.d.ts +4 -2
  17. package/dist/lib/converter/converter.js +65 -15
  18. package/dist/lib/converter/factories/index-signature.js +1 -1
  19. package/dist/lib/converter/plugins/CategoryPlugin.js +3 -5
  20. package/dist/lib/converter/plugins/CommentPlugin.js +20 -0
  21. package/dist/lib/converter/plugins/PackagePlugin.js +1 -1
  22. package/dist/lib/converter/symbols.js +27 -7
  23. package/dist/lib/converter/types.js +30 -3
  24. package/dist/lib/converter/utils/base-path.js +11 -6
  25. package/dist/lib/converter/utils/repository.js +2 -2
  26. package/dist/lib/internationalization/internationalization.js +1 -2
  27. package/dist/lib/internationalization/locales/ko.cjs +79 -0
  28. package/dist/lib/internationalization/locales/ko.d.cts +78 -0
  29. package/dist/lib/internationalization/translatable.d.ts +12 -1
  30. package/dist/lib/internationalization/translatable.js +12 -1
  31. package/dist/lib/models/FileRegistry.d.ts +26 -0
  32. package/dist/lib/models/FileRegistry.js +136 -0
  33. package/dist/lib/models/comments/comment.d.ts +57 -10
  34. package/dist/lib/models/comments/comment.js +32 -71
  35. package/dist/lib/models/comments/index.d.ts +1 -1
  36. package/dist/lib/models/index.d.ts +1 -0
  37. package/dist/lib/models/index.js +1 -0
  38. package/dist/lib/models/reflections/ReflectionSymbolId.js +1 -1
  39. package/dist/lib/models/reflections/abstract.js +1 -1
  40. package/dist/lib/models/reflections/document.d.ts +6 -1
  41. package/dist/lib/models/reflections/document.js +12 -2
  42. package/dist/lib/models/reflections/kind.d.ts +2 -0
  43. package/dist/lib/models/reflections/kind.js +3 -1
  44. package/dist/lib/models/reflections/project.d.ts +7 -2
  45. package/dist/lib/models/reflections/project.js +52 -40
  46. package/dist/lib/models/reflections/signature.js +9 -2
  47. package/dist/lib/models/types.d.ts +9 -1
  48. package/dist/lib/models/types.js +7 -20
  49. package/dist/lib/output/components.d.ts +2 -0
  50. package/dist/lib/output/components.js +139 -66
  51. package/dist/lib/output/models/UrlMapping.d.ts +4 -0
  52. package/dist/lib/output/plugins/AssetsPlugin.js +5 -0
  53. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +2 -2
  54. package/dist/lib/output/plugins/NavigationPlugin.js +1 -1
  55. package/dist/lib/output/plugins/SitemapPlugin.js +1 -1
  56. package/dist/lib/output/renderer.d.ts +24 -14
  57. package/dist/lib/output/renderer.js +17 -12
  58. package/dist/lib/output/theme.d.ts +0 -7
  59. package/dist/lib/output/theme.js +0 -8
  60. package/dist/lib/output/themes/MarkedPlugin.d.ts +1 -0
  61. package/dist/lib/output/themes/MarkedPlugin.js +91 -3
  62. package/dist/lib/output/themes/default/DefaultTheme.js +6 -3
  63. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -3
  64. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +3 -1
  65. package/dist/lib/output/themes/default/layouts/default.js +10 -10
  66. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  67. package/dist/lib/output/themes/default/partials/comment.js +16 -11
  68. package/dist/lib/output/themes/default/partials/footer.js +3 -3
  69. package/dist/lib/output/themes/default/partials/index.js +1 -1
  70. package/dist/lib/output/themes/default/partials/member.declaration.js +30 -4
  71. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +2 -1
  72. package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -2
  73. package/dist/lib/output/themes/default/partials/members.group.js +17 -10
  74. package/dist/lib/output/themes/default/partials/members.js +7 -3
  75. package/dist/lib/output/themes/default/partials/navigation.js +2 -2
  76. package/dist/lib/output/themes/default/partials/reflectionPreview.js +3 -2
  77. package/dist/lib/output/themes/default/partials/type.js +26 -2
  78. package/dist/lib/output/themes/default/partials/typeAndParent.js +2 -4
  79. package/dist/lib/output/themes/default/partials/typeParameters.js +1 -1
  80. package/dist/lib/serialization/deserializer.d.ts +8 -2
  81. package/dist/lib/serialization/deserializer.js +17 -8
  82. package/dist/lib/serialization/schema.d.ts +49 -13
  83. package/dist/lib/serialization/serializer.d.ts +1 -1
  84. package/dist/lib/utils/array.js +1 -1
  85. package/dist/lib/utils/entry-point.js +1 -1
  86. package/dist/lib/utils/events.d.ts +1 -1
  87. package/dist/lib/utils/events.js +1 -1
  88. package/dist/lib/utils/highlighter.d.ts +4 -2
  89. package/dist/lib/utils/highlighter.js +16 -5
  90. package/dist/lib/utils/html-entities.json +2324 -2231
  91. package/dist/lib/utils/html.d.ts +59 -1
  92. package/dist/lib/utils/html.js +577 -18
  93. package/dist/lib/utils/loggers.d.ts +0 -4
  94. package/dist/lib/utils/loggers.js +1 -7
  95. package/dist/lib/utils/options/declaration.d.ts +2 -0
  96. package/dist/lib/utils/options/help.js +1 -1
  97. package/dist/lib/utils/options/options.js +7 -6
  98. package/dist/lib/utils/options/readers/typedoc.js +0 -1
  99. package/dist/lib/utils/options/sources/typedoc.js +29 -0
  100. package/dist/lib/utils/options/tsdoc-defaults.d.ts +2 -2
  101. package/dist/lib/utils/options/tsdoc-defaults.js +2 -0
  102. package/dist/lib/utils/plugins.js +0 -1
  103. package/dist/lib/utils/set.d.ts +2 -1
  104. package/dist/lib/utils/set.js +8 -0
  105. package/dist/lib/utils/sort.js +4 -13
  106. package/package.json +11 -14
  107. package/static/main.js +4 -4
  108. package/static/style.css +5 -2
  109. package/tsdoc.json +8 -0
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.textContent = textContent;
7
+ const html_1 = require("../../utils/html");
8
+ const lexer_1 = require("./lexer");
9
+ const markdown_it_1 = __importDefault(require("markdown-it"));
10
+ const MdHelpers = new markdown_it_1.default().helpers;
11
+ /**
12
+ * Look for relative links within a piece of text and add them to the {@link FileRegistry}
13
+ * so that they can be correctly resolved during rendering.
14
+ */
15
+ function textContent(sourcePath, token, i18n, warning, outContent, files, atNewLine) {
16
+ let lastPartEnd = 0;
17
+ const data = {
18
+ sourcePath,
19
+ token,
20
+ pos: 0,
21
+ i18n,
22
+ warning,
23
+ files: files,
24
+ atNewLine,
25
+ };
26
+ function addRef(ref) {
27
+ outContent.push({
28
+ kind: "text",
29
+ text: token.text.slice(lastPartEnd, ref.pos),
30
+ });
31
+ outContent.push({
32
+ kind: "relative-link",
33
+ text: token.text.slice(ref.pos, ref.end),
34
+ target: ref.target,
35
+ });
36
+ lastPartEnd = ref.end;
37
+ data.pos = ref.end;
38
+ if (!ref.target) {
39
+ warning(i18n.relative_path_0_does_not_exist(token.text.slice(ref.pos, ref.end)), {
40
+ kind: lexer_1.TokenSyntaxKind.Text,
41
+ pos: ref.pos,
42
+ text: token.text.slice(ref.pos, ref.end),
43
+ });
44
+ }
45
+ }
46
+ while (data.pos < token.text.length) {
47
+ const link = checkMarkdownLink(data);
48
+ if (link) {
49
+ addRef(link);
50
+ continue;
51
+ }
52
+ const reference = checkReference(data);
53
+ if (reference) {
54
+ addRef(reference);
55
+ continue;
56
+ }
57
+ const tagLink = checkTagLink(data);
58
+ if (tagLink) {
59
+ addRef(tagLink);
60
+ continue;
61
+ }
62
+ ++data.pos;
63
+ }
64
+ if (lastPartEnd !== token.text.length) {
65
+ outContent.push({ kind: "text", text: token.text.slice(lastPartEnd) });
66
+ }
67
+ }
68
+ /**
69
+ * Links are inline text with the form `[ text ]( url title )`.
70
+ *
71
+ * Images are just links with a leading `!` and lack of support for `[ref]` referring to a path
72
+ * defined elsewhere, we don't care about that distinction here as we'll only replace the path
73
+ * piece of the image.
74
+ *
75
+ * Reference: https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_inline/link.mjs
76
+ * Reference: https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_inline/image.mjs
77
+ *
78
+ */
79
+ function checkMarkdownLink(data) {
80
+ const { token, sourcePath, files } = data;
81
+ if (token.text[data.pos] === "[") {
82
+ const labelEnd = findLabelEnd(token.text, data.pos + 1);
83
+ if (labelEnd !== -1 &&
84
+ token.text[labelEnd] === "]" &&
85
+ token.text[labelEnd + 1] === "(") {
86
+ const link = MdHelpers.parseLinkDestination(token.text, labelEnd + 2, token.text.length);
87
+ if (link.ok) {
88
+ // Only make a relative-link display part if it's actually a relative link.
89
+ // Discard protocol:// links, unix style absolute paths, and windows style absolute paths.
90
+ if (isRelativeLink(link.str)) {
91
+ return {
92
+ pos: labelEnd + 2,
93
+ end: link.pos,
94
+ target: files.register(sourcePath, link.str),
95
+ };
96
+ }
97
+ // This was a link, skip ahead to ensure we don't happen to parse
98
+ // something else as a link within the link.
99
+ data.pos = link.pos - 1;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ /**
105
+ * Reference definitions are blocks with the form `[label]: link title`
106
+ * Reference: https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_block/reference.mjs
107
+ *
108
+ * Note: This may include false positives where TypeDoc recognizes a reference block that markdown
109
+ * does not if users start lines with something that looks like a reference block without fully
110
+ * separating it from an above paragraph. For a first cut, this is good enough.
111
+ */
112
+ function checkReference(data) {
113
+ const { atNewLine, pos, token, files, sourcePath } = data;
114
+ if (atNewLine) {
115
+ let lookahead = pos;
116
+ while (/[ \t]/.test(token.text[lookahead])) {
117
+ ++lookahead;
118
+ }
119
+ if (token.text[lookahead] === "[") {
120
+ while (lookahead < token.text.length &&
121
+ /[^\n\]]/.test(token.text[lookahead])) {
122
+ ++lookahead;
123
+ }
124
+ if (token.text.startsWith("]:", lookahead)) {
125
+ lookahead += 2;
126
+ while (/[ \t]/.test(token.text[lookahead])) {
127
+ ++lookahead;
128
+ }
129
+ const link = MdHelpers.parseLinkDestination(token.text, lookahead, token.text.length);
130
+ if (link.ok) {
131
+ if (isRelativeLink(link.str)) {
132
+ return {
133
+ pos: lookahead,
134
+ end: link.pos,
135
+ target: files.register(sourcePath, link.str),
136
+ };
137
+ }
138
+ data.pos = link.pos - 1;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ /**
145
+ * Looks for `<a href="./relative">` and `<img src="./relative">`
146
+ */
147
+ function checkTagLink(data) {
148
+ const { pos, token } = data;
149
+ if (token.text.startsWith("<img ", pos)) {
150
+ data.pos += 4;
151
+ return checkAttribute(data, "src");
152
+ }
153
+ if (token.text.startsWith("<a ", pos)) {
154
+ data.pos += 3;
155
+ return checkAttribute(data, "href");
156
+ }
157
+ }
158
+ function checkAttribute(data, attr) {
159
+ const parser = new html_1.HtmlAttributeParser(data.token.text, data.pos);
160
+ while (parser.state !== html_1.ParserState.END) {
161
+ if (parser.state === html_1.ParserState.BeforeAttributeValue &&
162
+ parser.currentAttributeName === attr) {
163
+ parser.step();
164
+ if (isRelativeLink(parser.currentAttributeValue)) {
165
+ data.pos = parser.pos;
166
+ return {
167
+ pos: parser.currentAttributeValueStart,
168
+ end: parser.currentAttributeValueEnd,
169
+ target: data.files.register(data.sourcePath, parser.currentAttributeValue),
170
+ };
171
+ }
172
+ return;
173
+ }
174
+ parser.step();
175
+ }
176
+ }
177
+ function isRelativeLink(link) {
178
+ return !/^[a-z]+:\/\/|^\/|^[a-z]:\\/i.test(link);
179
+ }
180
+ function findLabelEnd(text, pos) {
181
+ while (pos < text.length) {
182
+ switch (text[pos]) {
183
+ case "\n":
184
+ case "]":
185
+ return pos;
186
+ }
187
+ ++pos;
188
+ }
189
+ return -1;
190
+ }
@@ -1,5 +1,5 @@
1
1
  import ts from "typescript";
2
- import { type Reflection, type ProjectReflection, DeclarationReflection, ReflectionKind, type DocumentReflection } from "../models/index";
2
+ import { type Reflection, type ProjectReflection, DeclarationReflection, type DocumentReflection, ReflectionKind } from "../models/index";
3
3
  import type { Converter } from "./converter";
4
4
  import type { TranslationProxy } from "../internationalization/internationalization";
5
5
  /**
@@ -84,7 +84,7 @@ export declare class Context {
84
84
  /** @internal */
85
85
  setActiveProgram(program: ts.Program | undefined): void;
86
86
  getComment(symbol: ts.Symbol, kind: ReflectionKind): import("../models/index").Comment | undefined;
87
- getNodeComment(node: ts.Node, kind: ReflectionKind): import("../models/index").Comment | undefined;
87
+ getNodeComment(node: ts.Node, moduleComment: boolean): import("../models/index").Comment | undefined;
88
88
  getFileComment(node: ts.SourceFile): import("../models/index").Comment | undefined;
89
89
  getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag): import("../models/index").Comment | undefined;
90
90
  getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature): import("../models/index").Comment | undefined;
@@ -72,9 +72,11 @@ class Context {
72
72
  if (!nodeType) {
73
73
  if (node.symbol) {
74
74
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.symbol);
75
+ // The TS types lie due to ts.SourceFile
75
76
  }
76
77
  else if (node.parent?.symbol) {
77
78
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.symbol);
79
+ // The TS types lie due to ts.SourceFile
78
80
  }
79
81
  else if (node.parent?.parent?.symbol) {
80
82
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.parent.symbol);
@@ -138,7 +140,10 @@ class Context {
138
140
  if (exportSymbol) {
139
141
  this.registerReflection(reflection, exportSymbol);
140
142
  }
141
- this.registerReflection(reflection, symbol);
143
+ const path = reflection.kindOf(index_1.ReflectionKind.Namespace | index_1.ReflectionKind.Module)
144
+ ? symbol?.declarations?.find(typescript_1.default.isSourceFile)?.fileName
145
+ : undefined;
146
+ this.project.registerReflection(reflection, symbol, path);
142
147
  }
143
148
  finalizeDeclarationReflection(reflection) {
144
149
  this.converter.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, this, reflection);
@@ -162,7 +167,7 @@ class Context {
162
167
  * @param symbol The symbol the given reflection was resolved from.
163
168
  */
164
169
  registerReflection(reflection, symbol) {
165
- this.project.registerReflection(reflection, symbol);
170
+ this.project.registerReflection(reflection, symbol, void 0);
166
171
  }
167
172
  /**
168
173
  * Trigger a node reflection event.
@@ -181,19 +186,19 @@ class Context {
181
186
  this._program = program;
182
187
  }
183
188
  getComment(symbol, kind) {
184
- return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
189
+ return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
185
190
  }
186
- getNodeComment(node, kind) {
187
- return (0, comments_1.getNodeComment)(node, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
191
+ getNodeComment(node, moduleComment) {
192
+ return (0, comments_1.getNodeComment)(node, moduleComment, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
188
193
  }
189
194
  getFileComment(node) {
190
- return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
195
+ return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
191
196
  }
192
197
  getJsDocComment(declaration) {
193
- return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.converter.useTsLinkResolution ? this.checker : undefined);
198
+ return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
194
199
  }
195
200
  getSignatureComment(declaration) {
196
- return (0, comments_1.getSignatureComment)(declaration, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
201
+ return (0, comments_1.getSignatureComment)(declaration, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
197
202
  }
198
203
  withScope(scope) {
199
204
  const context = new Context(this.converter, this.programs, this.project, scope);
@@ -9,7 +9,8 @@ import type { DocumentationEntryPoint } from "../utils/entry-point";
9
9
  import type { CommentParserConfig } from "./comments";
10
10
  import type { CommentStyle, ValidationOptions } from "../utils/options/declaration";
11
11
  import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver";
12
- import type { DeclarationReference } from "./comments/declarationReference";
12
+ import { type DeclarationReference } from "./comments/declarationReference";
13
+ import type { FileRegistry } from "../models/FileRegistry";
13
14
  /**
14
15
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
15
16
  */
@@ -128,7 +129,7 @@ export declare class Converter extends ChildableComponent<Application, Converter
128
129
  /**
129
130
  * Parse the given file into a comment. Intended to be used with markdown files.
130
131
  */
131
- parseRawComment(file: MinimalSourceFile): {
132
+ parseRawComment(file: MinimalSourceFile, files: FileRegistry): {
132
133
  content: CommentDisplayPart[];
133
134
  frontmatter: Record<string, unknown>;
134
135
  };
@@ -176,5 +177,6 @@ export declare class Converter extends ChildableComponent<Application, Converter
176
177
  /** @internal */
177
178
  isExternal(symbol: ts.Symbol): boolean;
178
179
  processDocumentTags(reflection: Reflection, parent: ContainerReflection): void;
180
+ private addDocument;
179
181
  private _buildCommentParserConfig;
180
182
  }
@@ -67,6 +67,7 @@ const enum_1 = require("../utils/enum");
67
67
  const parser_1 = require("./comments/parser");
68
68
  const rawLexer_1 = require("./comments/rawLexer");
69
69
  const linkResolver_1 = require("./comments/linkResolver");
70
+ const declarationReference_1 = require("./comments/declarationReference");
70
71
  const path_1 = require("path");
71
72
  /**
72
73
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
@@ -190,7 +191,7 @@ let Converter = (() => {
190
191
  name += ref.symbolReference.path.map((p) => p.path).join(".");
191
192
  }
192
193
  if (ref.symbolReference.meaning) {
193
- name += ":" + ref.symbolReference.meaning;
194
+ name += (0, declarationReference_1.meaningToString)(ref.symbolReference.meaning);
194
195
  }
195
196
  if (typeof modLinks[name] === "string") {
196
197
  return modLinks[name];
@@ -206,7 +207,7 @@ let Converter = (() => {
206
207
  convert(entryPoints) {
207
208
  const programs = (0, utils_1.unique)(entryPoints.map((e) => e.program));
208
209
  this.externalPatternCache = void 0;
209
- const project = new index_1.ProjectReflection(this.application.options.getValue("name"));
210
+ const project = new index_1.ProjectReflection(this.application.options.getValue("name"), this.application.files);
210
211
  const context = new context_1.Context(this, programs, project);
211
212
  this.trigger(Converter.EVENT_BEGIN, context);
212
213
  this.addProjectDocuments(project);
@@ -220,11 +221,15 @@ let Converter = (() => {
220
221
  addProjectDocuments(project) {
221
222
  const projectDocuments = (0, utils_1.getDocumentEntryPoints)(this.application.logger, this.application.options);
222
223
  for (const { displayName, path } of projectDocuments) {
223
- const file = new utils_1.MinimalSourceFile((0, utils_1.readFile)(path), path);
224
- const { content, frontmatter } = this.parseRawComment(file);
225
- const docRefl = new index_1.DocumentReflection(displayName, project, content, frontmatter);
226
- project.addChild(docRefl);
227
- project.registerReflection(docRefl);
224
+ let file;
225
+ try {
226
+ file = new utils_1.MinimalSourceFile((0, utils_1.readFile)(path), path);
227
+ }
228
+ catch (error) {
229
+ this.application.logger.error(this.application.logger.i18n.failed_to_read_0_when_processing_project_document(path));
230
+ continue;
231
+ }
232
+ this.addDocument(project, file, displayName);
228
233
  }
229
234
  }
230
235
  /** @internal */
@@ -244,8 +249,8 @@ let Converter = (() => {
244
249
  /**
245
250
  * Parse the given file into a comment. Intended to be used with markdown files.
246
251
  */
247
- parseRawComment(file) {
248
- return (0, parser_1.parseCommentString)((0, rawLexer_1.lexCommentString)(file.text), this.config, file, this.application.logger);
252
+ parseRawComment(file, files) {
253
+ return (0, parser_1.parseCommentString)((0, rawLexer_1.lexCommentString)(file.text), this.config, file, this.application.logger, files);
249
254
  }
250
255
  /**
251
256
  * Adds a new resolver that the theme can use to try to figure out how to link to a symbol declared
@@ -319,7 +324,7 @@ let Converter = (() => {
319
324
  if (createModuleReflections === false) {
320
325
  // Special case for when we're giving a single entry point, we don't need to
321
326
  // create modules for each entry. Register the project as this module.
322
- context.project.registerReflection(context.project, symbol);
327
+ context.project.registerReflection(context.project, symbol, entryPoint.sourceFile.fileName);
323
328
  context.project.comment = symbol
324
329
  ? context.getComment(symbol, context.project.kind)
325
330
  : context.getFileComment(node);
@@ -334,7 +339,7 @@ let Converter = (() => {
334
339
  }
335
340
  if (entryPoint.readmeFile) {
336
341
  const readme = (0, utils_1.readFile)(entryPoint.readmeFile);
337
- const { content } = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile));
342
+ const { content } = this.parseRawComment(new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile), context.project.files);
338
343
  reflection.readme = content;
339
344
  }
340
345
  reflection.packageVersion = entryPoint.version;
@@ -406,11 +411,56 @@ let Converter = (() => {
406
411
  this.application.logger.warn(this.application.logger.i18n.failed_to_read_0_when_processing_document_tag_in_1((0, paths_1.nicePath)(path), (0, paths_1.nicePath)(reflection.comment.sourcePath)));
407
412
  continue;
408
413
  }
409
- const { content, frontmatter } = this.parseRawComment(file);
410
- const docRefl = new index_1.DocumentReflection((0, path_1.basename)(file.fileName).replace(/\.[^.]+$/, ""), parent, content, frontmatter);
411
- parent.addChild(docRefl);
412
- parent.project.registerReflection(docRefl);
414
+ this.addDocument(parent, file, (0, path_1.basename)(file.fileName).replace(/\.[^.]+$/, ""));
415
+ }
416
+ }
417
+ }
418
+ addDocument(parent, file, displayName) {
419
+ const { content, frontmatter } = this.parseRawComment(file, parent.project.files);
420
+ const children = frontmatter["children"];
421
+ delete frontmatter["children"];
422
+ const docRefl = new index_1.DocumentReflection(displayName, parent, content, frontmatter);
423
+ parent.addChild(docRefl);
424
+ parent.project.registerReflection(docRefl, undefined, file.fileName);
425
+ const childrenToAdd = [];
426
+ if (children && typeof children === "object") {
427
+ if (Array.isArray(children)) {
428
+ for (const child of children) {
429
+ if (typeof child === "string") {
430
+ childrenToAdd.push([
431
+ (0, path_1.basename)(child).replace(/\.[^.]+$/, ""),
432
+ child,
433
+ ]);
434
+ }
435
+ else {
436
+ this.application.logger.error(this.application.i18n.frontmatter_children_0_should_be_an_array_of_strings_or_object_with_string_values((0, paths_1.nicePath)(file.fileName)));
437
+ return;
438
+ }
439
+ }
440
+ }
441
+ else {
442
+ for (const [name, path] of Object.entries(children)) {
443
+ if (typeof path === "string") {
444
+ childrenToAdd.push([name, path]);
445
+ }
446
+ else {
447
+ this.application.logger.error(this.application.i18n.frontmatter_children_0_should_be_an_array_of_strings_or_object_with_string_values((0, paths_1.nicePath)(file.fileName)));
448
+ return;
449
+ }
450
+ }
451
+ }
452
+ }
453
+ for (const [displayName, path] of childrenToAdd) {
454
+ const absPath = (0, path_1.resolve)((0, path_1.dirname)(file.fileName), path);
455
+ let childFile;
456
+ try {
457
+ childFile = new utils_1.MinimalSourceFile((0, utils_1.readFile)(absPath), absPath);
458
+ }
459
+ catch (error) {
460
+ this.application.logger.error(this.application.logger.i18n.failed_to_read_0_when_processing_document_child_in_1(path, (0, paths_1.nicePath)(file.fileName)));
461
+ continue;
413
462
  }
463
+ this.addDocument(docRefl, childFile, displayName);
414
464
  }
415
465
  }
416
466
  _buildCommentParserConfig() {
@@ -18,7 +18,7 @@ function convertIndexSignatures(context, symbol) {
18
18
  const param = indexDeclaration.parameters[0];
19
19
  (0, assert_1.default)(param && typescript_1.default.isParameter(param));
20
20
  const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope);
21
- index.comment = context.getNodeComment(indexDeclaration, index.kind);
21
+ index.comment = context.getNodeComment(indexDeclaration, false);
22
22
  index.parameters = [
23
23
  new models_1.ParameterReflection(param.name.getText(), models_1.ReflectionKind.Parameter, index),
24
24
  ];
@@ -114,9 +114,7 @@ let CategoryPlugin = (() => {
114
114
  if (this.defaultCategory) {
115
115
  CategoryPlugin.defaultCategory = this.defaultCategory;
116
116
  }
117
- if (this.categoryOrder) {
118
- CategoryPlugin.WEIGHTS = this.categoryOrder;
119
- }
117
+ CategoryPlugin.WEIGHTS = this.categoryOrder;
120
118
  }
121
119
  /**
122
120
  * Triggered when the converter has finished resolving a project.
@@ -157,7 +155,7 @@ let CategoryPlugin = (() => {
157
155
  if (group.categories)
158
156
  return;
159
157
  group.categories = this.getReflectionCategories(obj, group.children);
160
- if (group.categories && group.categories.length > 1) {
158
+ if (group.categories.length > 1) {
161
159
  group.categories.sort(CategoryPlugin.sortCatCallback);
162
160
  }
163
161
  else if (group.categories.length === 1 &&
@@ -172,7 +170,7 @@ let CategoryPlugin = (() => {
172
170
  return;
173
171
  }
174
172
  obj.categories = this.getReflectionCategories(obj, obj.childrenIncludingDocuments);
175
- if (obj.categories && obj.categories.length > 1) {
173
+ if (obj.categories.length > 1) {
176
174
  obj.categories.sort(CategoryPlugin.sortCatCallback);
177
175
  }
178
176
  else if (obj.categories.length === 1 &&
@@ -76,6 +76,7 @@ const NEVER_RENDERED = [
76
76
  "@this",
77
77
  "@type",
78
78
  "@typedef",
79
+ "@jsx",
79
80
  ];
80
81
  // We might make this user configurable at some point, but for now,
81
82
  // this set is configured here.
@@ -397,6 +398,12 @@ let CommentPlugin = (() => {
397
398
  }
398
399
  mergeSeeTags(reflection.comment);
399
400
  movePropertyTags(reflection.comment, reflection);
401
+ // Unlike other modifiers, this one has to wait until resolution to be removed
402
+ // as it needs to remain present so that it can be checked when `@hidden` tags are
403
+ // being processed.
404
+ if (reflection.kindOf(models_1.ReflectionKind.Class)) {
405
+ reflection.comment.removeModifier("@hideconstructor");
406
+ }
400
407
  }
401
408
  if (reflection instanceof models_1.DeclarationReflection && reflection.comment) {
402
409
  let sigs;
@@ -506,6 +513,19 @@ let CommentPlugin = (() => {
506
513
  if (this.excludedByCategory(reflection)) {
507
514
  return true;
508
515
  }
516
+ if (reflection.kindOf(models_1.ReflectionKind.ConstructorSignature |
517
+ models_1.ReflectionKind.Constructor)) {
518
+ if (comment?.hasModifier("@hideconstructor"))
519
+ return true;
520
+ const cls = reflection.parent?.kindOf(models_1.ReflectionKind.Class)
521
+ ? reflection.parent
522
+ : reflection.parent?.parent?.kindOf(models_1.ReflectionKind.Class)
523
+ ? reflection.parent.parent
524
+ : undefined;
525
+ if (cls?.comment?.hasModifier("@hideconstructor")) {
526
+ return true;
527
+ }
528
+ }
509
529
  if (!comment) {
510
530
  // We haven't moved comments from the parent for signatures without a direct
511
531
  // comment, so don't exclude those due to not being documented.
@@ -185,7 +185,7 @@ let PackagePlugin = (() => {
185
185
  }
186
186
  addEntries(project) {
187
187
  if (this.readmeFile && this.readmeContents) {
188
- const { content } = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(this.readmeContents, this.readmeFile));
188
+ const { content } = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(this.readmeContents, this.readmeFile), project.files);
189
189
  project.readme = content;
190
190
  }
191
191
  if (this.packageJson) {
@@ -184,7 +184,7 @@ function convertNamespace(context, symbol, exportSymbol) {
184
184
  }
185
185
  function convertTypeAlias(context, symbol, exportSymbol) {
186
186
  const declaration = symbol
187
- ?.getDeclarations()
187
+ .getDeclarations()
188
188
  ?.find((d) => typescript_1.default.isTypeAliasDeclaration(d) ||
189
189
  typescript_1.default.isJSDocTypedefTag(d) ||
190
190
  typescript_1.default.isJSDocCallbackTag(d) ||
@@ -198,6 +198,9 @@ function convertTypeAlias(context, symbol, exportSymbol) {
198
198
  }
199
199
  const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
200
200
  reflection.type = context.converter.convertType(context.withScope(reflection), declaration.type);
201
+ if (reflection.type.type === "union") {
202
+ attachUnionComments(context, declaration, reflection.type);
203
+ }
201
204
  context.finalizeDeclarationReflection(reflection);
202
205
  // Do this after finalization so that the CommentPlugin can get @typeParam tags
203
206
  // from the parent comment. Ugly, but works for now. Should be cleaned up eventually.
@@ -211,6 +214,25 @@ function convertTypeAlias(context, symbol, exportSymbol) {
211
214
  (0, jsdoc_1.convertJsDocCallback)(context, symbol, declaration, exportSymbol);
212
215
  }
213
216
  }
217
+ function attachUnionComments(context, declaration, union) {
218
+ const list = declaration.type.getChildAt(0);
219
+ if (list.kind !== typescript_1.default.SyntaxKind.SyntaxList)
220
+ return;
221
+ let unionIndex = 0;
222
+ for (const child of list.getChildren()) {
223
+ const comment = context.getNodeComment(child, false);
224
+ if (comment?.modifierTags.size || comment?.blockTags.length) {
225
+ context.logger.warn(context.logger.i18n.comment_for_0_should_not_contain_block_or_modifier_tags(`${context.scope.getFriendlyFullName()}.${unionIndex}`), child);
226
+ }
227
+ if (comment) {
228
+ union.elementSummaries ||= Array.from({ length: union.types.length }, () => []);
229
+ union.elementSummaries[unionIndex] = comment.summary;
230
+ }
231
+ if (child.kind !== typescript_1.default.SyntaxKind.BarToken) {
232
+ ++unionIndex;
233
+ }
234
+ }
235
+ }
214
236
  function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration) {
215
237
  const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Interface, symbol, exportSymbol);
216
238
  context.finalizeDeclarationReflection(reflection);
@@ -322,7 +344,7 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
322
344
  }
323
345
  reflectionContext.shouldBeStatic = false;
324
346
  const ctors = staticType.getConstructSignatures();
325
- const constructMember = reflectionContext.createDeclarationReflection(models_1.ReflectionKind.Constructor, ctors?.[0]?.declaration?.symbol, void 0, "constructor");
347
+ const constructMember = reflectionContext.createDeclarationReflection(models_1.ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
326
348
  // Modifiers are the same for all constructors
327
349
  if (ctors.length && ctors[0].declaration) {
328
350
  setModifiers(symbol, ctors[0].declaration, constructMember);
@@ -338,7 +360,7 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
338
360
  // And type arguments
339
361
  if (instanceType.typeParameters) {
340
362
  reflection.typeParameters = instanceType.typeParameters.map((param) => {
341
- const declaration = param.symbol?.declarations?.[0];
363
+ const declaration = param.symbol.declarations?.[0];
342
364
  (0, assert_1.default)(declaration && typescript_1.default.isTypeParameterDeclaration(declaration));
343
365
  return (0, signature_1.createTypeParamReflection)(declaration, reflectionContext);
344
366
  });
@@ -537,9 +559,7 @@ function convertVariableAsNamespace(context, symbol, exportSymbol) {
537
559
  const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
538
560
  context.finalizeDeclarationReflection(reflection);
539
561
  const rc = context.withScope(reflection);
540
- const declaration = symbol.declarations?.find(typescript_1.default.isVariableDeclaration);
541
- (0, assert_1.default)(declaration, "Missing variable declaration");
542
- const type = context.checker.getTypeAtLocation(declaration);
562
+ const type = context.checker.getTypeOfSymbol(symbol);
543
563
  convertSymbols(rc, type.getProperties());
544
564
  return typescript_1.default.SymbolFlags.Property;
545
565
  }
@@ -600,7 +620,7 @@ function convertSymbolAsClass(context, symbol, exportSymbol) {
600
620
  rc.shouldBeStatic = false;
601
621
  const ctors = type.getConstructSignatures();
602
622
  if (ctors.length) {
603
- const constructMember = rc.createDeclarationReflection(models_1.ReflectionKind.Constructor, ctors?.[0]?.declaration?.symbol, void 0, "constructor");
623
+ const constructMember = rc.createDeclarationReflection(models_1.ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
604
624
  // Modifiers are the same for all constructors
605
625
  if (ctors.length && ctors[0].declaration) {
606
626
  setModifiers(symbol, ctors[0].declaration, constructMember);