typedoc 0.28.12 → 0.28.13

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.
@@ -67,6 +67,10 @@ export declare class Application extends AbstractComponent<Application, Applicat
67
67
  */
68
68
  internationalization: Internationalization;
69
69
  options: Options;
70
+ /**
71
+ * Due for deprecation in 0.29, use the reference to this on {@link ProjectReflection},
72
+ * this was the wrong place for this member to live.
73
+ */
70
74
  files: FileRegistry;
71
75
  /** @internal */
72
76
  accessor lang: string;
@@ -158,6 +158,10 @@ let Application = (() => {
158
158
  */
159
159
  internationalization = new Internationalization();
160
160
  options = new Options();
161
+ /**
162
+ * Due for deprecation in 0.29, use the reference to this on {@link ProjectReflection},
163
+ * this was the wrong place for this member to live.
164
+ */
161
165
  files = new ValidatingFileRegistry();
162
166
  #lang_accessor_storage = __runInitializers(this, _lang_initializers, void 0);
163
167
  /** @internal */
@@ -260,6 +264,9 @@ let Application = (() => {
260
264
  else {
261
265
  this.logger.level = this.options.getValue("logLevel");
262
266
  }
267
+ if (this.files instanceof ValidatingFileRegistry) {
268
+ this.files.basePath = this.options.getValue("basePath");
269
+ }
263
270
  for (const [lang, locales] of Object.entries(this.options.getValue("locales"))) {
264
271
  this.internationalization.addTranslations(lang, locales);
265
272
  }
@@ -630,7 +637,7 @@ let Application = (() => {
630
637
  for (const { dir, options } of projectsToConvert) {
631
638
  this.logger.info(i18n.converting_project_at_0(nicePath(dir)));
632
639
  this.options = options;
633
- this.files = new ValidatingFileRegistry();
640
+ this.files = new ValidatingFileRegistry(options.getValue("basePath"));
634
641
  let project = await this.convert();
635
642
  if (project) {
636
643
  this.validate(project);
@@ -206,6 +206,9 @@ function postProcessComment(comment, i18n, getPosition, warning) {
206
206
  if ((inlineInheritDoc.length || inheritDoc.length) && remarks.length) {
207
207
  warning(i18n.content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0(getPosition()));
208
208
  }
209
+ if ((inlineInheritDoc.length || inheritDoc.length) && returns.length) {
210
+ warning(i18n.content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0(getPosition()));
211
+ }
209
212
  }
210
213
  const aliasedTags = new Map([["@return", "@returns"]]);
211
214
  function blockTag(comment, lexer, config, i18n, warning, files) {
@@ -4,7 +4,7 @@ import { DeclarationReflection, ReflectionFlag, ReflectionKind, SignatureReflect
4
4
  import { ReferenceType, ReflectionType } from "../../models/types.js";
5
5
  import { filterMap, zip } from "#utils";
6
6
  import { ConverterComponent } from "../components.js";
7
- import { getHumanName } from "../../utils/index.js";
7
+ import { findPackageForPath, getHumanName } from "../../utils/index.js";
8
8
  import { ConverterEvents } from "../converter-events.js";
9
9
  /**
10
10
  * A plugin that detects interface implementations of functions and
@@ -95,22 +95,23 @@ export class ImplementsPlugin extends ConverterComponent {
95
95
  // serialization/deserialization, might point to an unexpected location. (See the mixin
96
96
  // converter tests, I suspect this might actually be an indication of something else slightly
97
97
  // broken there, but don't want to spend more time with this right now.)
98
- // #2982, even more unfortunately, we only want to keep the link if it is pointing to a reflection
99
- // which will receive a link during rendering.
100
- const isValidRef = (ref) => ref.reflection && !ref.reflection.parent?.kindOf(ReflectionKind.TypeLiteral);
98
+ // #2982/#3007, even more unfortunately, we only want to keep the link if it is pointing
99
+ // to a reflection which will receive a link during rendering, we pick this based on it being
100
+ // the type of member we expect to point to.
101
+ const isValidRef = (ref) => !!ref.reflection?.parent?.kindOf(ReflectionKind.ClassOrInterface | ReflectionKind.Method | ReflectionKind.Constructor);
101
102
  for (const child of reflection.children || []) {
102
103
  if (child.inheritedFrom && !isValidRef(child.inheritedFrom)) {
103
- child.inheritedFrom = ReferenceType.createBrokenReference(child.inheritedFrom.name, project);
104
+ child.inheritedFrom = ReferenceType.createBrokenReference(child.inheritedFrom.name, project, child.inheritedFrom.package);
104
105
  }
105
106
  if (child.overwrites && !isValidRef(child.overwrites)) {
106
- child.overwrites = ReferenceType.createBrokenReference(child.overwrites.name, project);
107
+ child.overwrites = ReferenceType.createBrokenReference(child.overwrites.name, project, child.overwrites.package);
107
108
  }
108
109
  for (const childSig of child.getAllSignatures()) {
109
110
  if (childSig.inheritedFrom && !isValidRef(childSig.inheritedFrom)) {
110
- childSig.inheritedFrom = ReferenceType.createBrokenReference(childSig.inheritedFrom.name, project);
111
+ childSig.inheritedFrom = ReferenceType.createBrokenReference(childSig.inheritedFrom.name, project, childSig.inheritedFrom.package);
111
112
  }
112
113
  if (childSig.overwrites && !isValidRef(childSig.overwrites)) {
113
- childSig.overwrites = ReferenceType.createBrokenReference(childSig.overwrites.name, project);
114
+ childSig.overwrites = ReferenceType.createBrokenReference(childSig.overwrites.name, project, childSig.overwrites.package);
114
115
  }
115
116
  }
116
117
  }
@@ -325,15 +326,27 @@ export class ImplementsPlugin extends ConverterComponent {
325
326
  }
326
327
  }
327
328
  }
329
+ function getConstructorPackagePath(context, clause) {
330
+ const symbol = context.getSymbolAtLocation(clause.expression);
331
+ if (!symbol)
332
+ return undefined;
333
+ const resolvedSymbol = context.resolveAliasedSymbol(symbol);
334
+ const symbolPath = resolvedSymbol?.declarations?.[0]?.getSourceFile().fileName;
335
+ if (!symbolPath)
336
+ return undefined;
337
+ return findPackageForPath(symbolPath)?.[0];
338
+ }
328
339
  function constructorInheritance(context, reflection, childDecl, constructorDecl) {
329
340
  const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token === ts.SyntaxKind.ExtendsKeyword);
330
341
  if (!extendsClause)
331
342
  return;
332
- const name = `${extendsClause.types[0].getText()}.constructor`;
343
+ const extendsType = extendsClause.types[0];
344
+ const refPackage = getConstructorPackagePath(context, extendsType);
345
+ const name = `${extendsType.getText()}.constructor`;
333
346
  const key = constructorDecl ? "overwrites" : "inheritedFrom";
334
- reflection[key] ??= ReferenceType.createBrokenReference(name, context.project);
347
+ reflection[key] ??= ReferenceType.createBrokenReference(name, context.project, refPackage);
335
348
  for (const sig of reflection.signatures ?? []) {
336
- sig[key] ??= ReferenceType.createBrokenReference(name, context.project);
349
+ sig[key] ??= ReferenceType.createBrokenReference(name, context.project, refPackage);
337
350
  }
338
351
  }
339
352
  function findProperty(reflection, parent) {
@@ -356,7 +369,7 @@ function createLink(context, reflection, clause, expr, symbol, isInherit) {
356
369
  const rootSymbols = context.checker.getRootSymbols(symbol);
357
370
  const ref = rootSymbols.length && rootSymbols[0] != symbol
358
371
  ? context.createSymbolReference(rootSymbols[0], context, name)
359
- : ReferenceType.createBrokenReference(name, context.project);
372
+ : ReferenceType.createBrokenReference(name, context.project, undefined);
360
373
  link(reflection);
361
374
  link(reflection.getSignature);
362
375
  link(reflection.setSignature);
@@ -149,6 +149,8 @@ let InheritDocPlugin = (() => {
149
149
  return;
150
150
  }
151
151
  target.comment.removeTags("@inheritDoc");
152
+ target.comment.removeTags("@remarks");
153
+ target.comment.removeTags("@returns");
152
154
  target.comment.summary = Comment.cloneDisplayParts(source.comment.summary);
153
155
  const remarks = source.comment.getTag("@remarks");
154
156
  if (remarks) {
@@ -1,6 +1,5 @@
1
1
  import { ConverterComponent } from "../components.js";
2
2
  import type { Converter } from "../converter.js";
3
- import { type NormalizedPath } from "#utils";
4
3
  /**
5
4
  * A handler that attaches source file information to reflections.
6
5
  */
@@ -10,7 +9,7 @@ export declare class SourcePlugin extends ConverterComponent {
10
9
  accessor gitRemote: string;
11
10
  accessor disableGit: boolean;
12
11
  accessor sourceLinkTemplate: string;
13
- accessor basePath: NormalizedPath;
12
+ get displayBasePath(): import("#utils").NormalizedPath;
14
13
  /**
15
14
  * All file names to find the base path from.
16
15
  */
@@ -62,9 +62,6 @@ let SourcePlugin = (() => {
62
62
  let _sourceLinkTemplate_decorators;
63
63
  let _sourceLinkTemplate_initializers = [];
64
64
  let _sourceLinkTemplate_extraInitializers = [];
65
- let _basePath_decorators;
66
- let _basePath_initializers = [];
67
- let _basePath_extraInitializers = [];
68
65
  return class SourcePlugin extends _classSuper {
69
66
  static {
70
67
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
@@ -73,13 +70,11 @@ let SourcePlugin = (() => {
73
70
  _gitRemote_decorators = [Option("gitRemote")];
74
71
  _disableGit_decorators = [Option("disableGit")];
75
72
  _sourceLinkTemplate_decorators = [Option("sourceLinkTemplate")];
76
- _basePath_decorators = [Option("basePath")];
77
73
  __esDecorate(this, null, _disableSources_decorators, { kind: "accessor", name: "disableSources", static: false, private: false, access: { has: obj => "disableSources" in obj, get: obj => obj.disableSources, set: (obj, value) => { obj.disableSources = value; } }, metadata: _metadata }, _disableSources_initializers, _disableSources_extraInitializers);
78
74
  __esDecorate(this, null, _gitRevision_decorators, { kind: "accessor", name: "gitRevision", static: false, private: false, access: { has: obj => "gitRevision" in obj, get: obj => obj.gitRevision, set: (obj, value) => { obj.gitRevision = value; } }, metadata: _metadata }, _gitRevision_initializers, _gitRevision_extraInitializers);
79
75
  __esDecorate(this, null, _gitRemote_decorators, { kind: "accessor", name: "gitRemote", static: false, private: false, access: { has: obj => "gitRemote" in obj, get: obj => obj.gitRemote, set: (obj, value) => { obj.gitRemote = value; } }, metadata: _metadata }, _gitRemote_initializers, _gitRemote_extraInitializers);
80
76
  __esDecorate(this, null, _disableGit_decorators, { kind: "accessor", name: "disableGit", static: false, private: false, access: { has: obj => "disableGit" in obj, get: obj => obj.disableGit, set: (obj, value) => { obj.disableGit = value; } }, metadata: _metadata }, _disableGit_initializers, _disableGit_extraInitializers);
81
77
  __esDecorate(this, null, _sourceLinkTemplate_decorators, { kind: "accessor", name: "sourceLinkTemplate", static: false, private: false, access: { has: obj => "sourceLinkTemplate" in obj, get: obj => obj.sourceLinkTemplate, set: (obj, value) => { obj.sourceLinkTemplate = value; } }, metadata: _metadata }, _sourceLinkTemplate_initializers, _sourceLinkTemplate_extraInitializers);
82
- __esDecorate(this, null, _basePath_decorators, { kind: "accessor", name: "basePath", static: false, private: false, access: { has: obj => "basePath" in obj, get: obj => obj.basePath, set: (obj, value) => { obj.basePath = value; } }, metadata: _metadata }, _basePath_initializers, _basePath_extraInitializers);
83
78
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
84
79
  }
85
80
  #disableSources_accessor_storage = __runInitializers(this, _disableSources_initializers, void 0);
@@ -97,13 +92,13 @@ let SourcePlugin = (() => {
97
92
  #sourceLinkTemplate_accessor_storage = (__runInitializers(this, _disableGit_extraInitializers), __runInitializers(this, _sourceLinkTemplate_initializers, void 0));
98
93
  get sourceLinkTemplate() { return this.#sourceLinkTemplate_accessor_storage; }
99
94
  set sourceLinkTemplate(value) { this.#sourceLinkTemplate_accessor_storage = value; }
100
- #basePath_accessor_storage = (__runInitializers(this, _sourceLinkTemplate_extraInitializers), __runInitializers(this, _basePath_initializers, void 0));
101
- get basePath() { return this.#basePath_accessor_storage; }
102
- set basePath(value) { this.#basePath_accessor_storage = value; }
95
+ get displayBasePath() {
96
+ return this.application.options.getValue("displayBasePath") || this.application.options.getValue("basePath");
97
+ }
103
98
  /**
104
99
  * All file names to find the base path from.
105
100
  */
106
- fileNames = (__runInitializers(this, _basePath_extraInitializers), new Set());
101
+ fileNames = (__runInitializers(this, _sourceLinkTemplate_extraInitializers), new Set());
107
102
  repositories;
108
103
  constructor(owner) {
109
104
  super(owner);
@@ -170,7 +165,7 @@ let SourcePlugin = (() => {
170
165
  !this.gitRevision) {
171
166
  this.application.logger.warn(i18n.disable_git_set_and_git_revision_used());
172
167
  }
173
- const basePath = this.basePath || getCommonDirectory([...this.fileNames]);
168
+ const basePath = this.displayBasePath || getCommonDirectory([...this.fileNames]);
174
169
  this.repositories ||= new RepositoryManager(basePath, this.gitRevision, this.gitRemote, this.sourceLinkTemplate, this.disableGit, this.application.logger);
175
170
  for (const id in context.project.reflections) {
176
171
  const refl = context.project.reflections[id];
@@ -410,7 +410,7 @@ const queryConverter = {
410
410
  if (!querySymbol) {
411
411
  // This can happen if someone uses `typeof` on some property
412
412
  // on a variable typed as `any` with a name that doesn't exist.
413
- return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project));
413
+ return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project, undefined));
414
414
  }
415
415
  const ref = context.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText());
416
416
  ref.preferValues = true;
@@ -454,7 +454,7 @@ const referenceConverter = {
454
454
  if (!symbol) {
455
455
  // This happens when we get a reference to a type parameter
456
456
  // created within a mapped type, `K` in: `{ [K in T]: string }`
457
- const ref = ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
457
+ const ref = ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project, undefined);
458
458
  ref.refersToTypeParameter = true;
459
459
  return ref;
460
460
  }
@@ -45,6 +45,7 @@ module.exports = {
45
45
  at_most_one_inheritdoc_tag_expected_in_comment_at_0: "At most one @inheritDoc tag is expected in a comment, ignoring all but the first in comment at {0}",
46
46
  content_in_summary_overwritten_by_inheritdoc_in_comment_at_0: "Content in the summary section will be overwritten by the @inheritDoc tag in comment at {0}",
47
47
  content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @remarks block will be overwritten by the @inheritDoc tag in comment at {0}",
48
+ content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @returns block will be overwritten by the @inheritDoc tag in comment at {0}",
48
49
  example_tag_literal_name: "The first line of an example tag will be taken literally as the example name, and should only contain text",
49
50
  inheritdoc_tag_properly_capitalized: "The @inheritDoc tag should be properly capitalized",
50
51
  treating_unrecognized_tag_0_as_modifier: `Treating unrecognized tag {0} as a modifier tag`,
@@ -195,11 +196,12 @@ module.exports = {
195
196
  help_gitRevision: "Use specified revision instead of the last revision for linking to GitHub/Bitbucket source files. Has no effect if disableSources is set",
196
197
  help_gitRemote: "Use the specified remote for linking to GitHub/Bitbucket source files. Has no effect if disableGit or disableSources is set",
197
198
  help_disableGit: "Assume that all can be linked to with the sourceLinkTemplate, sourceLinkTemplate must be set if this is enabled. {path} will be rooted at basePath",
198
- help_basePath: "Specifies the base path to be used when displaying file paths",
199
+ help_displayBasePath: "Specifies the base path to be used when displaying file paths. If not specified, basePath is used.",
199
200
  help_excludeTags: "Remove the listed block/modifier tags from doc comments",
200
201
  help_notRenderedTags: "Tags which will be preserved in doc comments, but not rendered when creating output",
201
202
  help_cascadedModifierTags: "Modifier tags which should be copied to all children of the parent reflection",
202
203
  help_readme: "Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page",
204
+ help_basePath: "Specifies a path which links may be resolved relative to.",
203
205
  help_cname: "Set the CNAME file text, it's useful for custom domains on GitHub Pages",
204
206
  help_favicon: "Path to favicon to include as the site icon",
205
207
  help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab",
@@ -41,6 +41,7 @@ declare const _default: {
41
41
  readonly at_most_one_inheritdoc_tag_expected_in_comment_at_0: "At most one @inheritDoc tag is expected in a comment, ignoring all but the first in comment at {0}";
42
42
  readonly content_in_summary_overwritten_by_inheritdoc_in_comment_at_0: "Content in the summary section will be overwritten by the @inheritDoc tag in comment at {0}";
43
43
  readonly content_in_remarks_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @remarks block will be overwritten by the @inheritDoc tag in comment at {0}";
44
+ readonly content_in_returns_block_overwritten_by_inheritdoc_in_comment_at_0: "Content in the @returns block will be overwritten by the @inheritDoc tag in comment at {0}";
44
45
  readonly example_tag_literal_name: "The first line of an example tag will be taken literally as the example name, and should only contain text";
45
46
  readonly inheritdoc_tag_properly_capitalized: "The @inheritDoc tag should be properly capitalized";
46
47
  readonly treating_unrecognized_tag_0_as_modifier: "Treating unrecognized tag {0} as a modifier tag";
@@ -182,11 +183,12 @@ declare const _default: {
182
183
  readonly help_gitRevision: "Use specified revision instead of the last revision for linking to GitHub/Bitbucket source files. Has no effect if disableSources is set";
183
184
  readonly help_gitRemote: "Use the specified remote for linking to GitHub/Bitbucket source files. Has no effect if disableGit or disableSources is set";
184
185
  readonly help_disableGit: "Assume that all can be linked to with the sourceLinkTemplate, sourceLinkTemplate must be set if this is enabled. {path} will be rooted at basePath";
185
- readonly help_basePath: "Specifies the base path to be used when displaying file paths";
186
+ readonly help_displayBasePath: "Specifies the base path to be used when displaying file paths. If not specified, basePath is used.";
186
187
  readonly help_excludeTags: "Remove the listed block/modifier tags from doc comments";
187
188
  readonly help_notRenderedTags: "Tags which will be preserved in doc comments, but not rendered when creating output";
188
189
  readonly help_cascadedModifierTags: "Modifier tags which should be copied to all children of the parent reflection";
189
190
  readonly help_readme: "Path to the readme file that should be displayed on the index page. Pass `none` to disable the index page and start the documentation on the globals page";
191
+ readonly help_basePath: "Specifies a path which links may be resolved relative to.";
190
192
  readonly help_cname: "Set the CNAME file text, it's useful for custom domains on GitHub Pages";
191
193
  readonly help_favicon: "Path to favicon to include as the site icon";
192
194
  readonly help_sourceLinkExternal: "Specifies that source links should be treated as external links to be opened in a new tab";
@@ -393,7 +393,7 @@ export declare class ReferenceType extends Type {
393
393
  * later during conversion.
394
394
  * @internal
395
395
  */
396
- static createBrokenReference(name: string, project: ProjectReflection): ReferenceType;
396
+ static createBrokenReference(name: string, project: ProjectReflection, packageName: string | undefined): ReferenceType;
397
397
  protected getTypeString(): string;
398
398
  needsParenthesis(): boolean;
399
399
  toObject(serializer: Serializer): JSONOutput.ReferenceType;
@@ -833,8 +833,10 @@ let ReferenceType = (() => {
833
833
  * later during conversion.
834
834
  * @internal
835
835
  */
836
- static createBrokenReference(name, project) {
837
- return new ReferenceType(name, -1, project, name);
836
+ static createBrokenReference(name, project, packageName) {
837
+ const ref = new ReferenceType(name, -1, project, name);
838
+ ref.package = packageName;
839
+ return ref;
838
840
  }
839
841
  getTypeString() {
840
842
  const name = this.reflection ? this.reflection.name : this.name;
@@ -1,4 +1,4 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext.js";
2
- import { type Type } from "../../../../models/index.js";
2
+ import { type Type } from "#models";
3
3
  import { JSX } from "#utils";
4
4
  export declare const typeAndParent: (context: DefaultThemeRenderContext, props: Type) => JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ArrayType, ReferenceType, SignatureReflection } from "../../../../models/index.js";
1
+ import { ArrayType, ReferenceType, SignatureReflection } from "#models";
2
2
  import { JSX } from "#utils";
3
3
  export const typeAndParent = (context, props) => {
4
4
  if (props instanceof ArrayType) {
@@ -6,13 +6,23 @@ export const typeAndParent = (context, props) => {
6
6
  context.typeAndParent(props.elementType),
7
7
  "[]"));
8
8
  }
9
- if (props instanceof ReferenceType && props.reflection) {
10
- const refl = props.reflection instanceof SignatureReflection ? props.reflection.parent : props.reflection;
11
- const parent = refl.parent;
12
- return (JSX.createElement(JSX.Fragment, null,
13
- JSX.createElement("a", { href: context.urlTo(parent) }, parent.name),
14
- ".",
15
- JSX.createElement("a", { href: context.urlTo(refl) }, refl.name)));
9
+ if (props instanceof ReferenceType) {
10
+ if (props.reflection) {
11
+ const refl = props.reflection instanceof SignatureReflection ? props.reflection.parent : props.reflection;
12
+ const parent = refl.parent;
13
+ return (JSX.createElement(JSX.Fragment, null,
14
+ JSX.createElement("a", { href: context.urlTo(parent) }, parent.name),
15
+ ".",
16
+ JSX.createElement("a", { href: context.urlTo(refl) }, refl.name)));
17
+ }
18
+ else if (props.externalUrl) {
19
+ if (props.externalUrl === "#") {
20
+ return JSX.createElement(JSX.Fragment, null, props.toString());
21
+ }
22
+ else {
23
+ return JSX.createElement("a", { href: props.externalUrl, class: "external", target: "_blank" }, props.name);
24
+ }
25
+ }
16
26
  }
17
27
  return JSX.createElement(JSX.Fragment, null, props.toString());
18
28
  };
@@ -2,6 +2,8 @@ import { type FileId, FileRegistry } from "../models/FileRegistry.js";
2
2
  import type { Deserializer, JSONOutput } from "#serialization";
3
3
  import { type NormalizedPath } from "#utils";
4
4
  export declare class ValidatingFileRegistry extends FileRegistry {
5
+ basePath: NormalizedPath;
6
+ constructor(basePath?: NormalizedPath);
5
7
  register(sourcePath: NormalizedPath, relativePath: NormalizedPath): {
6
8
  target: FileId;
7
9
  anchor: string | undefined;
@@ -2,14 +2,29 @@ import { FileRegistry } from "../models/FileRegistry.js";
2
2
  import { i18n, NormalizedPathUtils } from "#utils";
3
3
  import { existsSync } from "fs";
4
4
  export class ValidatingFileRegistry extends FileRegistry {
5
+ basePath;
6
+ constructor(basePath = "") {
7
+ super();
8
+ this.basePath = basePath;
9
+ }
5
10
  register(sourcePath, relativePath) {
6
- const absolute = NormalizedPathUtils.resolve(NormalizedPathUtils.dirname(sourcePath), relativePath);
7
- const absoluteWithoutAnchor = absolute.replace(/#.*/, "");
11
+ let absolute = NormalizedPathUtils.resolve(NormalizedPathUtils.dirname(sourcePath), relativePath);
12
+ let absoluteWithoutAnchor = absolute.replace(/#.*/, "");
8
13
  // Note: We allow paths to directories to be registered here, but the AssetsPlugin will not
9
14
  // copy them to the output path. This is so that we can link to directories and associate them
10
15
  // with reflections in packages mode.
11
16
  if (!existsSync(absoluteWithoutAnchor)) {
12
- return;
17
+ // If the relative path didn't exist normally, also check the path relative to the assetBasePath option
18
+ if (this.basePath != "") {
19
+ absolute = NormalizedPathUtils.resolve(this.basePath, relativePath);
20
+ absoluteWithoutAnchor = absolute.replace(/#.*/, "");
21
+ if (!existsSync(absoluteWithoutAnchor)) {
22
+ return;
23
+ }
24
+ }
25
+ else {
26
+ return;
27
+ }
13
28
  }
14
29
  return this.registerAbsolute(absolute);
15
30
  }
@@ -124,7 +124,7 @@ export function getDocumentEntryPoints(logger, options) {
124
124
  // that have at some point or another been used for markdown: https://superuser.com/a/285878
125
125
  const supportedFileRegex = /\.(md|markdown)$/;
126
126
  const expanded = expandInputFiles(logger, docPaths, options, supportedFileRegex);
127
- const baseDir = options.getValue("basePath") || getCommonDirectory(expanded);
127
+ const baseDir = options.getValue("displayBasePath") || options.getValue("basePath") || getCommonDirectory(expanded);
128
128
  return expanded.map((path) => {
129
129
  return {
130
130
  displayName: relative(baseDir, path).replace(/\.[^.]+$/, ""),
@@ -184,7 +184,8 @@ function getModuleName(fileName, baseDir) {
184
184
  * This is in contrast with the package-oriented `getEntryPointsForPackages`
185
185
  */
186
186
  function getEntryPointsForPaths(logger, inputFiles, options, programs = getEntryPrograms(inputFiles, logger, options)) {
187
- const baseDir = options.getValue("basePath") || getCommonDirectory(inputFiles);
187
+ const baseDir = options.getValue("displayBasePath") || options.getValue("basePath") ||
188
+ getCommonDirectory(inputFiles);
188
189
  const entryPoints = [];
189
190
  let expandSuggestion = true;
190
191
  entryLoop: for (const fileOrDir of inputFiles.map(normalizePath)) {
@@ -108,6 +108,7 @@ export interface TypeDocOptionMap {
108
108
  gitRevision: string;
109
109
  gitRemote: string;
110
110
  readme: string;
111
+ basePath: NormalizedPath;
111
112
  outputs: ManuallyValidatedOption<Array<OutputSpecification>>;
112
113
  out: NormalizedPath;
113
114
  html: NormalizedPath;
@@ -145,7 +146,7 @@ export interface TypeDocOptionMap {
145
146
  * strictly typed here.
146
147
  */
147
148
  markdownItLoader: ManuallyValidatedOption<(parser: any) => void>;
148
- basePath: NormalizedPath;
149
+ displayBasePath: NormalizedPath;
149
150
  cname: string;
150
151
  favicon: NormalizedPath;
151
152
  githubPages: boolean;
@@ -16,9 +16,7 @@ function makeTagArrayValidator(name) {
16
16
  }
17
17
  // For convenience, added in the same order as they are documented on the website.
18
18
  export function addTypeDocOptions(options) {
19
- ///////////////////////////
20
- // Configuration Options //
21
- ///////////////////////////
19
+ // MARK: Configuration Options
22
20
  options.addDeclaration({
23
21
  type: ParameterType.Path,
24
22
  name: "options",
@@ -84,9 +82,7 @@ export function addTypeDocOptions(options) {
84
82
  }
85
83
  },
86
84
  });
87
- ///////////////////////////
88
- ////// Input Options //////
89
- ///////////////////////////
85
+ // MARK: Input Options
90
86
  options.addDeclaration({
91
87
  name: "entryPoints",
92
88
  help: () => i18n.help_entryPoints(),
@@ -202,9 +198,17 @@ export function addTypeDocOptions(options) {
202
198
  }
203
199
  },
204
200
  });
205
- ///////////////////////////
206
- ///// Output Options //////
207
- ///////////////////////////
201
+ options.addDeclaration({
202
+ name: "readme",
203
+ help: () => i18n.help_readme(),
204
+ type: ParameterType.Path,
205
+ });
206
+ options.addDeclaration({
207
+ name: "basePath",
208
+ help: () => i18n.help_basePath(),
209
+ type: ParameterType.Path,
210
+ });
211
+ // MARK: Output Options
208
212
  options.addDeclaration({
209
213
  name: "outputs",
210
214
  help: () => i18n.help_out(),
@@ -396,13 +400,8 @@ export function addTypeDocOptions(options) {
396
400
  type: ParameterType.Boolean,
397
401
  });
398
402
  options.addDeclaration({
399
- name: "basePath",
400
- help: () => i18n.help_basePath(),
401
- type: ParameterType.Path,
402
- });
403
- options.addDeclaration({
404
- name: "readme",
405
- help: () => i18n.help_readme(),
403
+ name: "displayBasePath",
404
+ help: () => i18n.help_displayBasePath(),
406
405
  type: ParameterType.Path,
407
406
  });
408
407
  options.addDeclaration({
@@ -622,9 +621,7 @@ export function addTypeDocOptions(options) {
622
621
  help: () => i18n.help_useFirstParagraphOfCommentAsSummary(),
623
622
  type: ParameterType.Boolean,
624
623
  });
625
- ///////////////////////////
626
- ///// Comment Options /////
627
- ///////////////////////////
624
+ // MARK: Comment Options
628
625
  options.addDeclaration({
629
626
  name: "jsDocCompatibility",
630
627
  help: () => i18n.help_jsDocCompatibility(),
@@ -703,9 +700,7 @@ export function addTypeDocOptions(options) {
703
700
  defaultValue: OptionDefaults.cascadedModifierTags,
704
701
  validate: makeTagArrayValidator("cascadedModifierTags"),
705
702
  });
706
- ///////////////////////////
707
- // Organization Options ///
708
- ///////////////////////////
703
+ // MARK: Organization Options
709
704
  options.addDeclaration({
710
705
  name: "categorizeByGroup",
711
706
  help: () => i18n.help_categorizeByGroup(),
@@ -764,9 +759,7 @@ export function addTypeDocOptions(options) {
764
759
  }
765
760
  },
766
761
  });
767
- ///////////////////////////
768
- ///// General Options /////
769
- ///////////////////////////
762
+ // MARK: General Options
770
763
  options.addDeclaration({
771
764
  name: "watch",
772
765
  help: () => i18n.help_watch(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.28.12",
4
+ "version": "0.28.13",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {