typedoc 0.26.0-beta.2 → 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 (66) hide show
  1. package/README.md +0 -2
  2. package/dist/lib/application.js +5 -0
  3. package/dist/lib/cli.js +1 -0
  4. package/dist/lib/converter/comments/discovery.js +0 -1
  5. package/dist/lib/converter/comments/index.d.ts +1 -1
  6. package/dist/lib/converter/comments/index.js +2 -2
  7. package/dist/lib/converter/comments/textParser.d.ts +0 -3
  8. package/dist/lib/converter/comments/textParser.js +39 -3
  9. package/dist/lib/converter/context.d.ts +2 -2
  10. package/dist/lib/converter/context.js +2 -4
  11. package/dist/lib/converter/converter.d.ts +1 -0
  12. package/dist/lib/converter/converter.js +58 -9
  13. package/dist/lib/converter/factories/index-signature.js +1 -1
  14. package/dist/lib/converter/symbols.js +22 -0
  15. package/dist/lib/converter/types.js +20 -1
  16. package/dist/lib/converter/utils/base-path.js +11 -6
  17. package/dist/lib/converter/utils/repository.js +2 -2
  18. package/dist/lib/internationalization/internationalization.js +0 -1
  19. package/dist/lib/internationalization/translatable.d.ts +6 -0
  20. package/dist/lib/internationalization/translatable.js +6 -0
  21. package/dist/lib/models/comments/comment.d.ts +28 -3
  22. package/dist/lib/models/comments/comment.js +6 -0
  23. package/dist/lib/models/reflections/document.d.ts +6 -1
  24. package/dist/lib/models/reflections/document.js +12 -2
  25. package/dist/lib/models/reflections/kind.d.ts +2 -0
  26. package/dist/lib/models/reflections/kind.js +3 -1
  27. package/dist/lib/models/reflections/project.js +1 -0
  28. package/dist/lib/models/reflections/signature.js +7 -2
  29. package/dist/lib/models/types.d.ts +9 -1
  30. package/dist/lib/models/types.js +5 -18
  31. package/dist/lib/output/components.d.ts +2 -0
  32. package/dist/lib/output/components.js +139 -66
  33. package/dist/lib/output/models/UrlMapping.d.ts +4 -0
  34. package/dist/lib/output/renderer.d.ts +16 -0
  35. package/dist/lib/output/themes/MarkedPlugin.js +8 -2
  36. package/dist/lib/output/themes/default/DefaultTheme.js +4 -1
  37. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -3
  38. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +3 -2
  39. package/dist/lib/output/themes/default/layouts/default.js +10 -10
  40. package/dist/lib/output/themes/default/partials/comment.d.ts +1 -1
  41. package/dist/lib/output/themes/default/partials/comment.js +16 -11
  42. package/dist/lib/output/themes/default/partials/footer.js +2 -2
  43. package/dist/lib/output/themes/default/partials/index.js +1 -1
  44. package/dist/lib/output/themes/default/partials/member.declaration.js +30 -4
  45. package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +2 -1
  46. package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -2
  47. package/dist/lib/output/themes/default/partials/members.group.js +17 -10
  48. package/dist/lib/output/themes/default/partials/members.js +7 -3
  49. package/dist/lib/output/themes/default/partials/navigation.js +2 -2
  50. package/dist/lib/output/themes/default/partials/reflectionPreview.js +3 -2
  51. package/dist/lib/output/themes/default/partials/type.js +26 -2
  52. package/dist/lib/serialization/schema.d.ts +23 -11
  53. package/dist/lib/serialization/serializer.d.ts +1 -1
  54. package/dist/lib/utils/component.js +0 -3
  55. package/dist/lib/utils/events.js +0 -1
  56. package/dist/lib/utils/html-entities.json +2324 -2231
  57. package/dist/lib/utils/html.d.ts +59 -1
  58. package/dist/lib/utils/html.js +577 -19
  59. package/dist/lib/utils/options/declaration.d.ts +1 -0
  60. package/dist/lib/utils/options/help.js +0 -1
  61. package/dist/lib/utils/options/options.js +0 -1
  62. package/dist/lib/utils/options/sources/typedoc.js +5 -0
  63. package/dist/lib/utils/sort.js +4 -13
  64. package/package.json +4 -6
  65. package/static/main.js +4 -4
  66. package/static/style.css +5 -2
package/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Documentation generator for TypeScript projects.
4
4
 
5
- Plugins: [plugins](./internal-docs/plugins.md)
6
-
7
5
  [![CI](https://github.com/TypeStrong/typedoc/workflows/CI/badge.svg)](https://github.com/TypeStrong/typedoc/actions)
8
6
  [![NPM Version](https://img.shields.io/npm/v/typedoc?color=33cd56&logo=npm)](https://www.npmjs.com/package/typedoc)
9
7
 
@@ -259,6 +259,11 @@ let Application = (() => {
259
259
  .join("\n\t")));
260
260
  this.logger.info("You can define/override local locales with the `locales` option, or contribute them to TypeDoc!");
261
261
  }
262
+ if (this.options.getValue("useHostedBaseUrlForAbsoluteLinks") &&
263
+ !this.options.getValue("hostedBaseUrl")) {
264
+ this.logger.warn(this.i18n.useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl());
265
+ this.options.setValue("useHostedBaseUrlForAbsoluteLinks", false);
266
+ }
262
267
  }
263
268
  setOptions(options, reportErrors = true) {
264
269
  for (const [key, val] of Object.entries(options)) {
package/dist/lib/cli.js CHANGED
@@ -83,6 +83,7 @@ async function run(app) {
83
83
  }
84
84
  if (app.options.getValue("watch")) {
85
85
  app.convertAndWatch(async (project) => {
86
+ app.validate(project);
86
87
  const json = app.options.getValue("json");
87
88
  if (!json || app.options.isSet("out")) {
88
89
  await app.generateDocs(project, app.options.getValue("out"));
@@ -284,7 +284,6 @@ function getRootModuleDeclaration(node) {
284
284
  }
285
285
  function declarationToCommentNode(node) {
286
286
  // ts.SourceFile is a counterexample
287
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
288
287
  if (!node.parent)
289
288
  return node;
290
289
  // const abc = 123
@@ -11,7 +11,7 @@ export interface CommentParserConfig {
11
11
  }
12
12
  export declare function clearCommentCache(): void;
13
13
  export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
14
- export declare function getNodeComment(node: ts.Node, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
14
+ export declare function getNodeComment(node: ts.Node, moduleComment: boolean, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
15
15
  export declare function getFileComment(file: ts.SourceFile, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
16
16
  export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
17
17
  export declare function getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined, files: FileRegistry): Comment | undefined;
@@ -97,8 +97,8 @@ function getComment(symbol, kind, config, logger, commentStyle, checker, files)
97
97
  }
98
98
  return comment;
99
99
  }
100
- function getNodeComment(node, kind, config, logger, commentStyle, checker, files) {
101
- return getCommentImpl((0, discovery_1.discoverNodeComment)(node, commentStyle), config, logger, kind === models_1.ReflectionKind.Module, checker, files);
100
+ function getNodeComment(node, moduleComment, config, logger, commentStyle, checker, files) {
101
+ return getCommentImpl((0, discovery_1.discoverNodeComment)(node, commentStyle), config, logger, moduleComment, checker, files);
102
102
  }
103
103
  function getFileComment(file, config, logger, commentStyle, checker, files) {
104
104
  for (const commentSource of (0, discovery_1.discoverFileComments)(file, commentStyle)) {
@@ -12,8 +12,5 @@ import { type Token } from "./lexer";
12
12
  /**
13
13
  * Look for relative links within a piece of text and add them to the {@link FileRegistry}
14
14
  * so that they can be correctly resolved during rendering.
15
- *
16
- * TODO: We also handle `<a>` and `<img>` tags with relative targets here.
17
- *
18
15
  */
19
16
  export declare function textContent(sourcePath: string, token: Token, i18n: TranslationProxy, warning: (msg: TranslatedString, token: Token) => void, outContent: CommentDisplayPart[], files: FileRegistry, atNewLine: boolean): void;
@@ -4,15 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.textContent = textContent;
7
+ const html_1 = require("../../utils/html");
7
8
  const lexer_1 = require("./lexer");
8
9
  const markdown_it_1 = __importDefault(require("markdown-it"));
9
10
  const MdHelpers = new markdown_it_1.default().helpers;
10
11
  /**
11
12
  * Look for relative links within a piece of text and add them to the {@link FileRegistry}
12
13
  * so that they can be correctly resolved during rendering.
13
- *
14
- * TODO: We also handle `<a>` and `<img>` tags with relative targets here.
15
- *
16
14
  */
17
15
  function textContent(sourcePath, token, i18n, warning, outContent, files, atNewLine) {
18
16
  let lastPartEnd = 0;
@@ -56,6 +54,11 @@ function textContent(sourcePath, token, i18n, warning, outContent, files, atNewL
56
54
  addRef(reference);
57
55
  continue;
58
56
  }
57
+ const tagLink = checkTagLink(data);
58
+ if (tagLink) {
59
+ addRef(tagLink);
60
+ continue;
61
+ }
59
62
  ++data.pos;
60
63
  }
61
64
  if (lastPartEnd !== token.text.length) {
@@ -138,6 +141,39 @@ function checkReference(data) {
138
141
  }
139
142
  }
140
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
+ }
141
177
  function isRelativeLink(link) {
142
178
  return !/^[a-z]+:\/\/|^\/|^[a-z]:\\/i.test(link);
143
179
  }
@@ -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;
@@ -73,12 +73,10 @@ class Context {
73
73
  if (node.symbol) {
74
74
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.symbol);
75
75
  // The TS types lie due to ts.SourceFile
76
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
77
76
  }
78
77
  else if (node.parent?.symbol) {
79
78
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.symbol);
80
79
  // The TS types lie due to ts.SourceFile
81
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
82
80
  }
83
81
  else if (node.parent?.parent?.symbol) {
84
82
  nodeType = this.checker.getDeclaredTypeOfSymbol(node.parent.parent.symbol);
@@ -190,8 +188,8 @@ class Context {
190
188
  getComment(symbol, kind) {
191
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);
192
190
  }
193
- getNodeComment(node, kind) {
194
- return (0, comments_1.getNodeComment)(node, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
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);
195
193
  }
196
194
  getFileComment(node) {
197
195
  return (0, comments_1.getFileComment)(node, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined, this.project.files);
@@ -177,5 +177,6 @@ export declare class Converter extends ChildableComponent<Application, Converter
177
177
  /** @internal */
178
178
  isExternal(symbol: ts.Symbol): boolean;
179
179
  processDocumentTags(reflection: Reflection, parent: ContainerReflection): void;
180
+ private addDocument;
180
181
  private _buildCommentParserConfig;
181
182
  }
@@ -221,11 +221,15 @@ let Converter = (() => {
221
221
  addProjectDocuments(project) {
222
222
  const projectDocuments = (0, utils_1.getDocumentEntryPoints)(this.application.logger, this.application.options);
223
223
  for (const { displayName, path } of projectDocuments) {
224
- const file = new utils_1.MinimalSourceFile((0, utils_1.readFile)(path), path);
225
- const { content, frontmatter } = this.parseRawComment(file, project.files);
226
- const docRefl = new index_1.DocumentReflection(displayName, project, content, frontmatter);
227
- project.addChild(docRefl);
228
- project.registerReflection(docRefl, undefined, path);
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);
229
233
  }
230
234
  }
231
235
  /** @internal */
@@ -407,11 +411,56 @@ let Converter = (() => {
407
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)));
408
412
  continue;
409
413
  }
410
- const { content, frontmatter } = this.parseRawComment(file, reflection.project.files);
411
- const docRefl = new index_1.DocumentReflection((0, path_1.basename)(file.fileName).replace(/\.[^.]+$/, ""), parent, content, frontmatter);
412
- parent.addChild(docRefl);
413
- parent.project.registerReflection(docRefl, undefined, file.fileName);
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;
414
462
  }
463
+ this.addDocument(docRefl, childFile, displayName);
415
464
  }
416
465
  }
417
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
  ];
@@ -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);
@@ -53,7 +53,6 @@ function loadConverters() {
53
53
  jsDocNonNullableTypeConverter,
54
54
  ]) {
55
55
  for (const key of actor.kind) {
56
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
57
56
  if (key === undefined) {
58
57
  // Might happen if running on an older TS version.
59
58
  continue;
@@ -672,6 +671,7 @@ const unionConverter = {
672
671
  },
673
672
  convertType(context, type) {
674
673
  const types = type.types.map((type) => convertType(context, type));
674
+ normalizeUnion(types);
675
675
  sortLiteralUnion(types);
676
676
  return new models_1.UnionType(types);
677
677
  },
@@ -735,3 +735,22 @@ function sortLiteralUnion(types) {
735
735
  return aLit.value - bLit.value;
736
736
  });
737
737
  }
738
+ function normalizeUnion(types) {
739
+ let trueIndex = -1;
740
+ let falseIndex = -1;
741
+ for (let i = 0; i < types.length && (trueIndex === -1 || falseIndex === -1); i++) {
742
+ const t = types[i];
743
+ if (t instanceof models_1.LiteralType) {
744
+ if (t.value === true) {
745
+ trueIndex = i;
746
+ }
747
+ if (t.value === false) {
748
+ falseIndex = i;
749
+ }
750
+ }
751
+ }
752
+ if (trueIndex !== -1 && falseIndex !== -1) {
753
+ types.splice(Math.max(trueIndex, falseIndex), 1);
754
+ types.splice(Math.min(trueIndex, falseIndex), 1, new models_1.IntrinsicType("boolean"));
755
+ }
756
+ }
@@ -101,12 +101,17 @@ class BasePath {
101
101
  * @returns Normalized version of the given path.
102
102
  */
103
103
  static normalize(path) {
104
- // Ensure forward slashes
105
- path = path.replace(/\\/g, "/");
106
- // Remove all surrounding quotes
107
- path = path.replace(/^["']+|["']+$/g, "");
108
- // Make Windows drive letters upper case
109
- return path.replace(/^([^:]+):\//, (_m, m1) => m1.toUpperCase() + ":/");
104
+ if (process.platform === "win32") {
105
+ // Ensure forward slashes
106
+ path = path.replace(/\\/g, "/");
107
+ // Msys2 git on windows will give paths which use unix-style
108
+ // absolute paths, like /c/users/you. Since the rest of TypeDoc
109
+ // expects drive letters, convert it to that here.
110
+ path = path.replace(/^\/([a-zA-Z])\//, (_m, m1) => `${m1}:/`);
111
+ // Make Windows drive letters upper case
112
+ path = path.replace(/^([^:]+):\//, (_m, m1) => m1.toUpperCase() + ":/");
113
+ }
114
+ return path;
110
115
  }
111
116
  }
112
117
  exports.BasePath = BasePath;
@@ -52,9 +52,9 @@ class GitRepository {
52
52
  this.path = path;
53
53
  this.gitRevision = gitRevision;
54
54
  this.urlTemplate = urlTemplate;
55
- const out = git("-C", path, "ls-files");
55
+ const out = git("-C", path, "ls-files", "-z");
56
56
  if (out.status === 0) {
57
- out.stdout.split("\n").forEach((file) => {
57
+ out.stdout.split("\0").forEach((file) => {
58
58
  if (file !== "") {
59
59
  this.files.add(base_path_1.BasePath.normalize(path + "/" + file));
60
60
  }
@@ -9,7 +9,6 @@ const path_1 = require("path");
9
9
  const kind_1 = require("../models/reflections/kind");
10
10
  // If we're running in ts-node, then we need the TS source rather than
11
11
  // the compiled file.
12
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
13
12
  const ext = process[Symbol.for("ts-node.register.instance")]
14
13
  ? "cts"
15
14
  : "cjs";
@@ -21,9 +21,13 @@ export declare const translatable: {
21
21
  readonly entrypoint_did_not_match_files_0: "The entrypoint glob {0} did not match any files.";
22
22
  readonly failed_to_parse_json_0: "Failed to parse file at {0} as json.";
23
23
  readonly failed_to_read_0_when_processing_document_tag_in_1: "Failed to read file {0} when processing @document tag for comment in {1}";
24
+ readonly failed_to_read_0_when_processing_project_document: "Failed to read file {0} when adding project document";
25
+ readonly failed_to_read_0_when_processing_document_child_in_1: "Failed to read file {0} when processing document children in {1}";
26
+ readonly frontmatter_children_0_should_be_an_array_of_strings_or_object_with_string_values: "Frontmatter children in {0} should be an array of strings or an object with string values.";
24
27
  readonly converting_union_as_interface: "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.";
25
28
  readonly converting_0_as_class_requires_value_declaration: "Converting {0} as a class requires a declaration which represents a non-type value.";
26
29
  readonly converting_0_as_class_without_construct_signatures: "{0} is being converted as a class, but does not have any construct signatures";
30
+ readonly comment_for_0_should_not_contain_block_or_modifier_tags: "The comment for {0} should not contain any block or modifier tags.";
27
31
  readonly symbol_0_has_multiple_declarations_with_comment: "{0} has multiple declarations with a comment. An arbitrary comment will be used.";
28
32
  readonly comments_for_0_are_declared_at_1: "The comments for {0} are declared at:\n\t{1}";
29
33
  readonly multiple_type_parameters_on_template_tag_unsupported: "TypeDoc does not support multiple type parameters defined in a single @template tag with a comment.";
@@ -150,6 +154,7 @@ export declare const translatable: {
150
154
  readonly help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab.";
151
155
  readonly help_githubPages: "Generate a .nojekyll file to prevent 404 errors in GitHub Pages. Defaults to `true`.";
152
156
  readonly help_hostedBaseUrl: "Specify a base URL to be used in generating a sitemap.xml in our output folder and canonical links. If not specified, no sitemap will be generated.";
157
+ readonly help_useHostedBaseUrlForAbsoluteLinks: "If set, TypeDoc will produce absolute links to pages on your site using the hostedBaseUrl option.";
153
158
  readonly help_gaID: "Set the Google Analytics tracking ID and activate tracking code.";
154
159
  readonly help_hideGenerator: "Do not print the TypeDoc link at the end of the page.";
155
160
  readonly help_customFooterHtml: "Custom footer after the TypeDoc link.";
@@ -208,6 +213,7 @@ export declare const translatable: {
208
213
  readonly highlight_theme_0_must_be_one_of_1: "{0} must be one of the following: {1}";
209
214
  readonly highlightLanguages_contains_invalid_languages_0: "highlightLanguages contains invalid languages: {0}, run typedoc --help for a list of supported languages.";
210
215
  readonly hostedBaseUrl_must_start_with_http: "hostedBaseUrl must start with http:// or https://";
216
+ readonly useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl: "The useHostedBaseUrlForAbsoluteLinks option requires that hostedBaseUrl be set";
211
217
  readonly option_0_must_be_an_object: "The '{0}' option must be a non-array object.";
212
218
  readonly option_0_must_be_a_function: "The '{0}' option must be a function.";
213
219
  readonly option_0_must_be_object_with_urls: "{0} must be an object with string labels as keys and URL values.";
@@ -30,9 +30,13 @@ exports.translatable = {
30
30
  entrypoint_did_not_match_files_0: "The entrypoint glob {0} did not match any files.",
31
31
  failed_to_parse_json_0: `Failed to parse file at {0} as json.`,
32
32
  failed_to_read_0_when_processing_document_tag_in_1: `Failed to read file {0} when processing @document tag for comment in {1}`,
33
+ failed_to_read_0_when_processing_project_document: `Failed to read file {0} when adding project document`,
34
+ failed_to_read_0_when_processing_document_child_in_1: `Failed to read file {0} when processing document children in {1}`,
35
+ frontmatter_children_0_should_be_an_array_of_strings_or_object_with_string_values: "Frontmatter children in {0} should be an array of strings or an object with string values.",
33
36
  converting_union_as_interface: `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.`,
34
37
  converting_0_as_class_requires_value_declaration: `Converting {0} as a class requires a declaration which represents a non-type value.`,
35
38
  converting_0_as_class_without_construct_signatures: `{0} is being converted as a class, but does not have any construct signatures`,
39
+ comment_for_0_should_not_contain_block_or_modifier_tags: `The comment for {0} should not contain any block or modifier tags.`,
36
40
  symbol_0_has_multiple_declarations_with_comment: `{0} has multiple declarations with a comment. An arbitrary comment will be used.`,
37
41
  comments_for_0_are_declared_at_1: `The comments for {0} are declared at:\n\t{1}`,
38
42
  // comments/parser.ts
@@ -169,6 +173,7 @@ exports.translatable = {
169
173
  help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab.",
170
174
  help_githubPages: "Generate a .nojekyll file to prevent 404 errors in GitHub Pages. Defaults to `true`.",
171
175
  help_hostedBaseUrl: "Specify a base URL to be used in generating a sitemap.xml in our output folder and canonical links. If not specified, no sitemap will be generated.",
176
+ help_useHostedBaseUrlForAbsoluteLinks: "If set, TypeDoc will produce absolute links to pages on your site using the hostedBaseUrl option.",
172
177
  help_gaID: "Set the Google Analytics tracking ID and activate tracking code.",
173
178
  help_hideGenerator: "Do not print the TypeDoc link at the end of the page.",
174
179
  help_customFooterHtml: "Custom footer after the TypeDoc link.",
@@ -230,6 +235,7 @@ exports.translatable = {
230
235
  highlight_theme_0_must_be_one_of_1: "{0} must be one of the following: {1}",
231
236
  highlightLanguages_contains_invalid_languages_0: "highlightLanguages contains invalid languages: {0}, run typedoc --help for a list of supported languages.",
232
237
  hostedBaseUrl_must_start_with_http: "hostedBaseUrl must start with http:// or https://",
238
+ useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl: "The useHostedBaseUrlForAbsoluteLinks option requires that hostedBaseUrl be set",
233
239
  option_0_must_be_an_object: "The '{0}' option must be a non-array object.",
234
240
  option_0_must_be_a_function: "The '{0}' option must be a function.",
235
241
  option_0_must_be_object_with_urls: `{0} must be an object with string labels as keys and URL values.`,
@@ -4,14 +4,33 @@ import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
4
4
  /**
5
5
  * Represents a parsed piece of a comment.
6
6
  * @category Comments
7
+ * @see {@link JSONOutput.CommentDisplayPart}
7
8
  */
8
- export type CommentDisplayPart = {
9
+ export type CommentDisplayPart =
10
+ /**
11
+ * Represents a plain text portion of the comment, may contain markdown
12
+ */
13
+ {
9
14
  kind: "text";
10
15
  text: string;
11
- } | {
16
+ }
17
+ /**
18
+ * Represents a code block separated out form the plain text entry so
19
+ * that TypeDoc knows to skip it when parsing relative links and inline tags.
20
+ **/
21
+ | {
12
22
  kind: "code";
13
23
  text: string;
14
- } | InlineTagDisplayPart | RelativeLinkDisplayPart;
24
+ }
25
+ /**
26
+ * Represents an inline tag like `{@link Foo}`
27
+ */
28
+ | InlineTagDisplayPart
29
+ /**
30
+ * Represents a reference to a path relative to where the comment resides.
31
+ * This is used to detect and copy relative image links.
32
+ */
33
+ | RelativeLinkDisplayPart;
15
34
  /**
16
35
  * The `@link`, `@linkcode`, and `@linkplain` tags may have a `target`
17
36
  * property set indicating which reflection/url they link to. They may also
@@ -63,6 +82,12 @@ export declare class CommentTag {
63
82
  * The actual body text of this tag.
64
83
  */
65
84
  content: CommentDisplayPart[];
85
+ /**
86
+ * A flag which may be set by plugins to prevent TypeDoc from rendering this tag, if the plugin provides
87
+ * custom rendering. Note: This flag is **not** serialized, it is expected to be set just before the comment
88
+ * is rendered.
89
+ */
90
+ skipRendering: boolean;
66
91
  /**
67
92
  * Create a new CommentTag instance.
68
93
  */
@@ -49,6 +49,12 @@ class CommentTag {
49
49
  * Create a new CommentTag instance.
50
50
  */
51
51
  constructor(tag, text) {
52
+ /**
53
+ * A flag which may be set by plugins to prevent TypeDoc from rendering this tag, if the plugin provides
54
+ * custom rendering. Note: This flag is **not** serialized, it is expected to be set just before the comment
55
+ * is rendered.
56
+ */
57
+ this.skipRendering = false;
52
58
  this.tag = tag;
53
59
  this.content = text;
54
60
  }
@@ -19,9 +19,14 @@ export declare class DocumentReflection extends Reflection {
19
19
  * boosting search relevance scores at runtime. May be modified by plugins.
20
20
  */
21
21
  relevanceBoost?: number;
22
+ /**
23
+ * Child documents, if any are present.
24
+ */
25
+ children?: DocumentReflection[];
22
26
  constructor(name: string, parent: Reflection, content: CommentDisplayPart[], frontmatter: Record<string, unknown>);
27
+ addChild(child: DocumentReflection): void;
23
28
  isDocument(): this is DocumentReflection;
24
- traverse(_callback: TraverseCallback): void;
29
+ traverse(callback: TraverseCallback): void;
25
30
  toObject(serializer: Serializer): JSONOutput.DocumentReflection;
26
31
  fromObject(de: Deserializer, obj: JSONOutput.DocumentReflection): void;
27
32
  }
@@ -18,11 +18,19 @@ class DocumentReflection extends abstract_1.Reflection {
18
18
  delete frontmatter["title"];
19
19
  }
20
20
  }
21
+ addChild(child) {
22
+ this.children ||= [];
23
+ this.children.push(child);
24
+ }
21
25
  isDocument() {
22
26
  return true;
23
27
  }
24
- traverse(_callback) {
25
- // Nothing to do here, we have no children.
28
+ traverse(callback) {
29
+ for (const child of this.children || []) {
30
+ if (callback(child, abstract_1.TraverseProperty.Documents) === false) {
31
+ return;
32
+ }
33
+ }
26
34
  }
27
35
  toObject(serializer) {
28
36
  return {
@@ -31,6 +39,7 @@ class DocumentReflection extends abstract_1.Reflection {
31
39
  content: comments_1.Comment.serializeDisplayParts(serializer, this.content),
32
40
  frontmatter: this.frontmatter,
33
41
  relevanceBoost: this.relevanceBoost,
42
+ children: serializer.toObjectsOptional(this.children),
34
43
  };
35
44
  }
36
45
  fromObject(de, obj) {
@@ -38,6 +47,7 @@ class DocumentReflection extends abstract_1.Reflection {
38
47
  this.content = comments_1.Comment.deserializeDisplayParts(de, obj.content);
39
48
  this.frontmatter = obj.frontmatter;
40
49
  this.relevanceBoost = obj.relevanceBoost;
50
+ this.children = de.reviveMany(obj.children, (obj) => de.reflectionBuilders.document(this, obj));
41
51
  }
42
52
  }
43
53
  exports.DocumentReflection = DocumentReflection;
@@ -35,6 +35,7 @@ export declare enum ReflectionKind {
35
35
  /** @category Reflections */
36
36
  export declare namespace ReflectionKind {
37
37
  type KindString = EnumKeys<typeof ReflectionKind>;
38
+ /** @internal */
38
39
  const All: number;
39
40
  /** @internal */
40
41
  const ClassOrInterface: number;
@@ -56,6 +57,7 @@ export declare namespace ReflectionKind {
56
57
  const SomeMember: number;
57
58
  /** @internal */
58
59
  const SomeExport: number;
60
+ /** @internal */
59
61
  const MayContainDocuments: number;
60
62
  /** @internal */
61
63
  const ExportContainer: number;
@@ -37,6 +37,7 @@ var ReflectionKind;
37
37
  })(ReflectionKind || (exports.ReflectionKind = ReflectionKind = {}));
38
38
  /** @category Reflections */
39
39
  (function (ReflectionKind) {
40
+ /** @internal */
40
41
  ReflectionKind.All = ReflectionKind.Reference * 2 - 1;
41
42
  /** @internal */
42
43
  ReflectionKind.ClassOrInterface = ReflectionKind.Class | ReflectionKind.Interface;
@@ -79,7 +80,8 @@ var ReflectionKind;
79
80
  ReflectionKind.Interface |
80
81
  ReflectionKind.TypeAlias |
81
82
  ReflectionKind.Reference;
82
- ReflectionKind.MayContainDocuments = ReflectionKind.SomeExport | ReflectionKind.Project;
83
+ /** @internal */
84
+ ReflectionKind.MayContainDocuments = ReflectionKind.SomeExport | ReflectionKind.Project | ReflectionKind.Document;
83
85
  /** @internal */
84
86
  ReflectionKind.ExportContainer = ReflectionKind.SomeModule | ReflectionKind.Project;
85
87
  /** @internal */
@@ -298,6 +298,7 @@ class ProjectReflection extends container_1.ContainerReflection {
298
298
  }
299
299
  this.files.fromObject(de, obj.files);
300
300
  de.defer(() => {
301
+ // Unnecessary conditional in release
301
302
  for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
302
303
  const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
303
304
  if (refl) {