typedoc 0.27.5 → 0.27.7

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 (67) hide show
  1. package/bin/typedoc +21 -2
  2. package/dist/index.d.ts +1 -1
  3. package/dist/lib/application.d.ts +30 -1
  4. package/dist/lib/application.js +96 -24
  5. package/dist/lib/cli.js +4 -4
  6. package/dist/lib/converter/comments/declarationReference.d.ts +2 -1
  7. package/dist/lib/converter/comments/declarationReference.js +9 -0
  8. package/dist/lib/converter/comments/linkResolver.js +20 -5
  9. package/dist/lib/converter/converter.d.ts +5 -3
  10. package/dist/lib/converter/converter.js +18 -21
  11. package/dist/lib/converter/factories/signature.js +16 -4
  12. package/dist/lib/converter/plugins/IncludePlugin.d.ts +4 -1
  13. package/dist/lib/converter/plugins/IncludePlugin.js +177 -4
  14. package/dist/lib/converter/plugins/PackagePlugin.js +5 -0
  15. package/dist/lib/converter/symbols.js +22 -8
  16. package/dist/lib/converter/types.d.ts +2 -2
  17. package/dist/lib/converter/types.js +26 -10
  18. package/dist/lib/converter/utils/nodes.d.ts +1 -0
  19. package/dist/lib/converter/utils/nodes.js +4 -0
  20. package/dist/lib/internationalization/internationalization.js +3 -1
  21. package/dist/lib/internationalization/locales/en.cjs +15 -0
  22. package/dist/lib/internationalization/locales/en.d.cts +14 -0
  23. package/dist/lib/internationalization/locales/ja.cjs +321 -0
  24. package/dist/lib/internationalization/locales/ja.d.cts +308 -0
  25. package/dist/lib/internationalization/locales/jp.cjs +2 -320
  26. package/dist/lib/internationalization/locales/jp.d.cts +2 -308
  27. package/dist/lib/internationalization/locales/zh.cjs +6 -3
  28. package/dist/lib/internationalization/locales/zh.d.cts +5 -2
  29. package/dist/lib/internationalization/translatable.d.ts +2 -1
  30. package/dist/lib/output/index.d.ts +1 -0
  31. package/dist/lib/output/plugins/AssetsPlugin.d.ts +1 -7
  32. package/dist/lib/output/plugins/AssetsPlugin.js +18 -7
  33. package/dist/lib/output/renderer.d.ts +1 -0
  34. package/dist/lib/output/renderer.js +10 -2
  35. package/dist/lib/output/themes/default/DefaultTheme.d.ts +3 -39
  36. package/dist/lib/output/themes/default/DefaultTheme.js +19 -10
  37. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +12 -12
  38. package/dist/lib/output/themes/default/partials/icon.d.ts +17 -2
  39. package/dist/lib/output/themes/default/partials/icon.js +77 -79
  40. package/dist/lib/output/themes/default/partials/member.getterSetter.js +6 -6
  41. package/dist/lib/output/themes/default/partials/member.signatures.js +3 -3
  42. package/dist/lib/output/themes/default/templates/reflection.js +2 -2
  43. package/dist/lib/utils/array.d.ts +1 -0
  44. package/dist/lib/utils/array.js +15 -0
  45. package/dist/lib/utils/fs.d.ts +2 -2
  46. package/dist/lib/utils/fs.js +4 -3
  47. package/dist/lib/utils/general.d.ts +1 -0
  48. package/dist/lib/utils/general.js +11 -0
  49. package/dist/lib/utils/highlighter.d.ts +1 -1
  50. package/dist/lib/utils/highlighter.js +6 -4
  51. package/dist/lib/utils/options/declaration.d.ts +1 -0
  52. package/dist/lib/utils/options/defaults.d.ts +1 -0
  53. package/dist/lib/utils/options/defaults.js +1 -0
  54. package/dist/lib/utils/options/options.d.ts +3 -10
  55. package/dist/lib/utils/options/options.js +2 -20
  56. package/dist/lib/utils/options/readers/package-json.d.ts +1 -1
  57. package/dist/lib/utils/options/readers/package-json.js +2 -2
  58. package/dist/lib/utils/options/readers/tsconfig.d.ts +1 -1
  59. package/dist/lib/utils/options/readers/tsconfig.js +2 -2
  60. package/dist/lib/utils/options/readers/typedoc.d.ts +1 -4
  61. package/dist/lib/utils/options/readers/typedoc.js +6 -7
  62. package/dist/lib/utils/options/sources/typedoc.js +6 -0
  63. package/dist/lib/utils/tsconfig.d.ts +1 -1
  64. package/dist/lib/utils/tsconfig.js +2 -2
  65. package/package.json +1 -1
  66. package/static/main.js +3 -3
  67. package/static/style.css +5 -4
package/bin/typedoc CHANGED
@@ -1,5 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
  //@ts-check
3
3
 
4
- /* eslint-disable @typescript-eslint/no-var-requires */
5
- import("../dist/lib/cli.js");
4
+ const { fork } = require("child_process");
5
+
6
+ function main() {
7
+ fork(__dirname + "/../dist/lib/cli.js", process.argv.slice(2), {
8
+ stdio: "inherit",
9
+ }).on("exit", (code) => {
10
+ // Watch restart required? Fork a new child
11
+ if (code === 7) {
12
+ // Set an environment variable to ensure we continue watching
13
+ // Otherwise, the watch might stop unexpectedly if the watch
14
+ // option was set in a config file originally, and change to false
15
+ // later, causing a restart
16
+ process.env["TYPEDOC_FORCE_WATCH"] = "1";
17
+ main();
18
+ } else {
19
+ process.exit(code || 0);
20
+ }
21
+ });
22
+ }
23
+
24
+ main();
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ export * as Configuration from "./lib/utils/options/index.js";
32
32
  export * from "./lib/models/index.js";
33
33
  export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, type ConverterEvents, } from "./lib/converter/index.js";
34
34
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, Slugger, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output/index.js";
35
- export type { RenderTemplate, RendererHooks, NavigationElement, RendererEvents, PageHeading, } from "./lib/output/index.js";
35
+ export type { RenderTemplate, RendererHooks, NavigationElement, RendererEvents, PageHeading, Icons, } from "./lib/output/index.js";
36
36
  export { Outputs } from "./lib/output/output.js";
37
37
  export { ArgumentsReader, Option, CommentStyle, JSX, LogLevel, Logger, Options, OptionDefaults, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils/index.js";
38
38
  export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, JsDocCompatibility, OutputSpecification, } from "./lib/utils/index.js";
@@ -137,7 +137,36 @@ export declare class Application extends AbstractComponent<Application, Applicat
137
137
  * @returns An instance of ProjectReflection on success, undefined otherwise.
138
138
  */
139
139
  convert(): Promise<ProjectReflection | undefined>;
140
- convertAndWatch(success: (project: ProjectReflection) => Promise<void>): void;
140
+ private watchers;
141
+ private _watchFile?;
142
+ private criticalFiles;
143
+ private clearWatches;
144
+ private watchConfigFile;
145
+ /**
146
+ * Register that the current build depends on a file, so that in watch mode
147
+ * the build will be repeated. Has no effect if a watch build is not
148
+ * running, or if the file has already been registered.
149
+ *
150
+ * @param path The file to watch. It does not need to exist, and you should
151
+ * in fact register files you look for, but which do not exist, so that if
152
+ * they are created the build will re-run. (e.g. if you look through a list
153
+ * of 5 possibilities and find the third, you should register the first 3.)
154
+ *
155
+ * @param shouldRestart Should the build be completely restarted? (This is
156
+ * normally only used for configuration files -- i.e. files whose contents
157
+ * determine how conversion, rendering, or compiling will be done, as
158
+ * opposed to files that are only read *during* the conversion or
159
+ * rendering.)
160
+ */
161
+ watchFile(path: string, shouldRestart?: boolean): void;
162
+ /**
163
+ * Run a convert / watch process.
164
+ *
165
+ * @param success Callback to run after each convert, receiving the project
166
+ * @returns True if the watch process should be restarted due to a
167
+ * configuration change, false for an options error
168
+ */
169
+ convertAndWatch(success: (project: ProjectReflection) => Promise<void>): Promise<boolean>;
141
170
  validate(project: ProjectReflection): void;
142
171
  /**
143
172
  * Render outputs selected with options for the specified project
@@ -197,7 +197,6 @@ let Application = (() => {
197
197
  throw new Error("An application handle must be retrieved with Application.bootstrap or Application.bootstrapWithPlugins");
198
198
  }
199
199
  super(null); // We own ourselves
200
- __runInitializers(this, _entryPoints_extraInitializers);
201
200
  this.converter = new Converter(this);
202
201
  this.renderer = new Renderer(this);
203
202
  this.logger.i18n = this.i18n;
@@ -218,7 +217,7 @@ let Application = (() => {
218
217
  readers.forEach((r) => app.options.addReader(r));
219
218
  app.options.reset();
220
219
  app.setOptions(options, /* reportErrors */ false);
221
- await app.options.read(new Logger());
220
+ await app.options.read(new Logger(), undefined, (path) => app.watchConfigFile(path));
222
221
  app.logger.level = app.options.getValue("logLevel");
223
222
  await loadPlugins(app, app.options.getValue("plugin"));
224
223
  await app._bootstrap(options);
@@ -245,7 +244,7 @@ let Application = (() => {
245
244
  async _bootstrap(options) {
246
245
  this.options.reset();
247
246
  this.setOptions(options, /* reportErrors */ false);
248
- await this.options.read(this.logger);
247
+ await this.options.read(this.logger, undefined, (path) => this.watchConfigFile(path));
249
248
  this.setOptions(options);
250
249
  this.logger.level = this.options.getValue("logLevel");
251
250
  for (const [lang, locales] of Object.entries(this.options.getValue("locales"))) {
@@ -257,13 +256,18 @@ let Application = (() => {
257
256
  this.trigger(ApplicationEvents.BOOTSTRAP_END, this);
258
257
  if (!this.internationalization.hasTranslations(this.lang)) {
259
258
  // Not internationalized as by definition we don't know what to include here.
260
- this.logger.warn(`Options specified "${this.lang}" as the language to use, but TypeDoc does not support it.`);
261
- this.logger.info(("The supported languages are:\n\t" +
259
+ this.logger.warn(`Options specified "${this.lang}" as the language to use, but TypeDoc cannot provide translations for it.`);
260
+ this.logger.info(("The languages that translations are available for are:\n\t" +
262
261
  this.internationalization
263
262
  .getSupportedLanguages()
264
263
  .join("\n\t")));
265
264
  this.logger.info("You can define/override local locales with the `locales` option, or contribute them to TypeDoc!");
266
265
  }
266
+ else if (this.lang === "jp") {
267
+ this.logger.warn(
268
+ // Only Japanese see this. Meaning: "jp" is going to be removed in the future. Please designate "ja" instead.
269
+ "「jp」は将来削除されます。代わりに「ja」を指定してください。");
270
+ }
267
271
  if (this.options.getValue("useHostedBaseUrlForAbsoluteLinks") &&
268
272
  !this.options.getValue("hostedBaseUrl")) {
269
273
  this.logger.warn(this.i18n.useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl());
@@ -317,9 +321,6 @@ let Application = (() => {
317
321
  */
318
322
  async convert() {
319
323
  const start = Date.now();
320
- // We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
321
- // with a few different settings.
322
- this.options.freeze();
323
324
  this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
324
325
  if (this.entryPointStrategy === EntryPointStrategy.Merge) {
325
326
  return this._merge();
@@ -355,8 +356,43 @@ let Application = (() => {
355
356
  this.logger.verbose(`Finished conversion in ${Date.now() - startConversion}ms`);
356
357
  return project;
357
358
  }
358
- convertAndWatch(success) {
359
- this.options.freeze();
359
+ watchers = (__runInitializers(this, _entryPoints_extraInitializers), new Map());
360
+ _watchFile;
361
+ criticalFiles = new Set();
362
+ clearWatches() {
363
+ this.watchers.forEach((w) => w.close());
364
+ this.watchers.clear();
365
+ }
366
+ watchConfigFile(path) {
367
+ this.criticalFiles.add(path);
368
+ }
369
+ /**
370
+ * Register that the current build depends on a file, so that in watch mode
371
+ * the build will be repeated. Has no effect if a watch build is not
372
+ * running, or if the file has already been registered.
373
+ *
374
+ * @param path The file to watch. It does not need to exist, and you should
375
+ * in fact register files you look for, but which do not exist, so that if
376
+ * they are created the build will re-run. (e.g. if you look through a list
377
+ * of 5 possibilities and find the third, you should register the first 3.)
378
+ *
379
+ * @param shouldRestart Should the build be completely restarted? (This is
380
+ * normally only used for configuration files -- i.e. files whose contents
381
+ * determine how conversion, rendering, or compiling will be done, as
382
+ * opposed to files that are only read *during* the conversion or
383
+ * rendering.)
384
+ */
385
+ watchFile(path, shouldRestart = false) {
386
+ this._watchFile?.(path, shouldRestart);
387
+ }
388
+ /**
389
+ * Run a convert / watch process.
390
+ *
391
+ * @param success Callback to run after each convert, receiving the project
392
+ * @returns True if the watch process should be restarted due to a
393
+ * configuration change, false for an options error
394
+ */
395
+ async convertAndWatch(success) {
360
396
  if (!this.options.getValue("preserveWatchOutput") &&
361
397
  this.logger instanceof ConsoleLogger) {
362
398
  ts.sys.clearScreen?.();
@@ -372,20 +408,20 @@ let Application = (() => {
372
408
  // have reported in the first time... just error out for now. I'm not convinced anyone will actually notice.
373
409
  if (this.options.getFileNames().length === 0) {
374
410
  this.logger.error(this.i18n.solution_not_supported_in_watch_mode());
375
- return;
411
+ return false;
376
412
  }
377
413
  // Support for packages mode is currently unimplemented
378
414
  if (this.entryPointStrategy !== EntryPointStrategy.Resolve &&
379
415
  this.entryPointStrategy !== EntryPointStrategy.Expand) {
380
416
  this.logger.error(this.i18n.strategy_not_supported_in_watch_mode());
381
- return;
417
+ return false;
382
418
  }
383
419
  const tsconfigFile = findTsConfigFile(this.options.getValue("tsconfig")) ??
384
420
  "tsconfig.json";
385
421
  // We don't want to do it the first time to preserve initial debug status messages. They'll be lost
386
422
  // after the user saves a file, but better than nothing...
387
423
  let firstStatusReport = true;
388
- const host = ts.createWatchCompilerHost(tsconfigFile, {}, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
424
+ const host = ts.createWatchCompilerHost(tsconfigFile, this.options.fixCompilerOptions({}), ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
389
425
  if (!firstStatusReport &&
390
426
  errorCount === void 0 &&
391
427
  !this.options.getValue("preserveWatchOutput") &&
@@ -397,20 +433,59 @@ let Application = (() => {
397
433
  });
398
434
  let successFinished = true;
399
435
  let currentProgram;
436
+ let lastProgram = currentProgram;
437
+ let restarting = false;
438
+ this._watchFile = (path, shouldRestart = false) => {
439
+ this.logger.verbose(`Watching ${nicePath(path)}, shouldRestart=${shouldRestart}`);
440
+ if (this.watchers.has(path))
441
+ return;
442
+ this.watchers.set(path, host.watchFile(path, (file) => {
443
+ if (shouldRestart) {
444
+ restartMain(file);
445
+ }
446
+ else if (!currentProgram) {
447
+ currentProgram = lastProgram;
448
+ this.logger.info(this.i18n.file_0_changed_rebuilding(nicePath(file)));
449
+ }
450
+ if (successFinished)
451
+ runSuccess();
452
+ }, 2000));
453
+ };
454
+ /** resolver for the returned promise */
455
+ let exitWatch;
456
+ const restartMain = (file) => {
457
+ if (restarting)
458
+ return;
459
+ this.logger.info(this.i18n.file_0_changed_restarting(nicePath(file)));
460
+ restarting = true;
461
+ currentProgram = undefined;
462
+ this.clearWatches();
463
+ tsWatcher.close();
464
+ };
400
465
  const runSuccess = () => {
466
+ if (restarting && successFinished) {
467
+ successFinished = false;
468
+ exitWatch(true);
469
+ return;
470
+ }
401
471
  if (!currentProgram) {
402
472
  return;
403
473
  }
404
474
  if (successFinished) {
405
- if (this.options.getValue("emit") === "both") {
475
+ if (this.options.getValue("emit") === "both" &&
476
+ currentProgram !== lastProgram) {
406
477
  currentProgram.emit();
407
478
  }
479
+ // Save for possible re-run due to non-.ts file change
480
+ lastProgram = currentProgram;
408
481
  this.logger.resetErrors();
409
482
  this.logger.resetWarnings();
410
483
  const entryPoints = getWatchEntryPoints(this.logger, this.options, currentProgram);
411
484
  if (!entryPoints) {
412
485
  return;
413
486
  }
487
+ this.clearWatches();
488
+ this.criticalFiles.forEach((path) => this.watchFile(path, true));
414
489
  const project = this.converter.convert(entryPoints);
415
490
  currentProgram = undefined;
416
491
  successFinished = false;
@@ -420,23 +495,20 @@ let Application = (() => {
420
495
  });
421
496
  }
422
497
  };
423
- const origCreateProgram = host.createProgram;
424
- host.createProgram = (rootNames, options, host, oldProgram, configDiagnostics, references) => {
425
- // If we always do this, we'll get a crash the second time a program is created.
426
- if (rootNames !== undefined) {
427
- options = this.options.fixCompilerOptions(options || {});
428
- }
429
- return origCreateProgram(rootNames, options, host, oldProgram, configDiagnostics, references);
430
- };
431
498
  const origAfterProgramCreate = host.afterProgramCreate;
432
499
  host.afterProgramCreate = (program) => {
433
- if (ts.getPreEmitDiagnostics(program.getProgram()).length === 0) {
500
+ if (!restarting &&
501
+ ts.getPreEmitDiagnostics(program.getProgram()).length === 0) {
434
502
  currentProgram = program.getProgram();
435
503
  runSuccess();
436
504
  }
437
505
  origAfterProgramCreate?.(program);
438
506
  };
439
- ts.createWatchProgram(host);
507
+ const tsWatcher = ts.createWatchProgram(host);
508
+ // Don't return to caller until the watch needs to restart
509
+ return await new Promise((res) => {
510
+ exitWatch = res;
511
+ });
440
512
  }
441
513
  validate(project) {
442
514
  const checks = this.options.getValue("validation");
package/dist/lib/cli.js CHANGED
@@ -25,8 +25,8 @@ async function main() {
25
25
  if (exitCode !== ExitCodes.Watching) {
26
26
  app.logger.verbose(`Full run took ${Date.now() - start}ms`);
27
27
  logRunSummary(app.logger);
28
- process.exit(exitCode);
29
28
  }
29
+ process.exit(exitCode);
30
30
  }
31
31
  catch (error) {
32
32
  console.error("TypeDoc exiting with unexpected error:");
@@ -57,12 +57,12 @@ async function run(app) {
57
57
  app.logger.hasWarnings()) {
58
58
  return ExitCodes.OptionError;
59
59
  }
60
- if (app.options.getValue("watch")) {
61
- app.convertAndWatch(async (project) => {
60
+ if (app.options.getValue("watch") || process.env["TYPEDOC_FORCE_WATCH"]) {
61
+ const continueWatching = await app.convertAndWatch(async (project) => {
62
62
  app.validate(project);
63
63
  await app.generateOutputs(project);
64
64
  });
65
- return ExitCodes.Watching;
65
+ return continueWatching ? ExitCodes.Watching : ExitCodes.OptionError;
66
66
  }
67
67
  const project = await app.convert();
68
68
  if (!project) {
@@ -27,7 +27,8 @@ export interface ComponentPath {
27
27
  * How to resolve the `path`
28
28
  * - `.` - Navigate via `exports` of symbol
29
29
  * - `#` - Navigate via `members` of symbol
30
- * - `~` - Navigate via `locals` of symbol
30
+ * - `~` - Navigate via `locals` of symbol (note: TypeDoc does not support
31
+ * locals, see the declaration reference docs)
31
32
  */
32
33
  navigation: "." | "#" | "~";
33
34
  path: string;
@@ -300,6 +300,7 @@ export function parseDeclarationReference(source, pos, end) {
300
300
  let moduleSource;
301
301
  let symbolReference;
302
302
  let resolutionStart = "local";
303
+ let topLevelLocalReference = false;
303
304
  const moduleSourceOrSymbolRef = parseModuleSource(source, pos, end);
304
305
  if (moduleSourceOrSymbolRef) {
305
306
  if (moduleSourceOrSymbolRef[1] < end &&
@@ -308,6 +309,11 @@ export function parseDeclarationReference(source, pos, end) {
308
309
  pos = moduleSourceOrSymbolRef[1] + 1;
309
310
  resolutionStart = "global";
310
311
  moduleSource = moduleSourceOrSymbolRef[0];
312
+ // We might be referencing a local of a module
313
+ if (source[pos] === "~") {
314
+ topLevelLocalReference = true;
315
+ pos++;
316
+ }
311
317
  }
312
318
  }
313
319
  else if (source[pos] === "!") {
@@ -317,6 +323,9 @@ export function parseDeclarationReference(source, pos, end) {
317
323
  const ref = parseSymbolReference(source, pos, end);
318
324
  if (ref) {
319
325
  symbolReference = ref[0];
326
+ if (topLevelLocalReference && symbolReference.path?.length) {
327
+ symbolReference.path[0].navigation = "~";
328
+ }
320
329
  pos = ref[1];
321
330
  }
322
331
  if (!moduleSource && !symbolReference)
@@ -2,6 +2,7 @@ import ts from "typescript";
2
2
  import { DeclarationReflection, Reflection, ReflectionKind, ReflectionSymbolId, } from "../../models/index.js";
3
3
  import { parseDeclarationReference, } from "./declarationReference.js";
4
4
  import { resolveDeclarationReference } from "./declarationReferenceResolver.js";
5
+ import { maxElementByScore } from "../../utils/array.js";
5
6
  const urlPrefix = /^(http|ftp)s?:\/\//;
6
7
  export function resolveLinks(comment, reflection, externalResolver, options) {
7
8
  comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver, options);
@@ -48,11 +49,25 @@ function resolveLinkTag(reflection, part, externalResolver, options) {
48
49
  const tsTargets = reflection.project.getReflectionsFromSymbolId(part.target);
49
50
  if (tsTargets.length) {
50
51
  // Find the target most likely to have a real url in the generated documentation
51
- target =
52
- tsTargets.find((r) => r.kindOf(ReflectionKind.SomeExport)) ||
53
- tsTargets.find((r) => r.kindOf(ReflectionKind.SomeMember) &&
54
- r.parent?.kindOf(ReflectionKind.SomeExport)) ||
55
- tsTargets[0];
52
+ // 1. A direct export (class, interface, variable)
53
+ // 2. A property of a direct export (class/interface property)
54
+ // 3. A property of a type of an export (property on type alias)
55
+ // 4. Whatever the first symbol found was
56
+ target = maxElementByScore(tsTargets, (r) => {
57
+ if (r.kindOf(ReflectionKind.SomeExport)) {
58
+ return 4;
59
+ }
60
+ if (r.kindOf(ReflectionKind.SomeMember) &&
61
+ r.parent?.kindOf(ReflectionKind.SomeExport)) {
62
+ return 3;
63
+ }
64
+ if (r.kindOf(ReflectionKind.SomeMember) &&
65
+ r.parent?.kindOf(ReflectionKind.TypeLiteral) &&
66
+ r.parent.parent?.kindOf(ReflectionKind.TypeAlias | ReflectionKind.Variable)) {
67
+ return 2;
68
+ }
69
+ return 1;
70
+ });
56
71
  pos = end;
57
72
  defaultDisplayText =
58
73
  part.tsLinkText ||
@@ -10,6 +10,7 @@ import type { CommentStyle, ValidationOptions } from "../utils/options/declarati
10
10
  import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver.js";
11
11
  import { type DeclarationReference } from "./comments/declarationReference.js";
12
12
  import type { FileRegistry } from "../models/FileRegistry.js";
13
+ import { IncludePlugin } from "./plugins/IncludePlugin.js";
13
14
  export interface ConverterEvents {
14
15
  begin: [Context];
15
16
  end: [Context];
@@ -46,8 +47,6 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
46
47
  /** @internal */
47
48
  accessor excludeExternals: boolean;
48
49
  /** @internal */
49
- accessor excludeNotDocumented: boolean;
50
- /** @internal */
51
50
  accessor excludePrivate: boolean;
52
51
  /** @internal */
53
52
  accessor excludeProtected: boolean;
@@ -144,6 +143,8 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
144
143
  * @event
145
144
  */
146
145
  static readonly EVENT_RESOLVE_END: "resolveEnd";
146
+ /** @internal @hidden */
147
+ includePlugin: IncludePlugin;
147
148
  constructor(owner: Application);
148
149
  /**
149
150
  * Compile the given source files and create a project reflection for them.
@@ -160,7 +161,8 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
160
161
  * @returns The TypeDoc type reflection representing the given node and type.
161
162
  * @internal
162
163
  */
163
- convertType(context: Context, node: ts.TypeNode | ts.Type | undefined): SomeType;
164
+ convertType(context: Context, node: ts.TypeNode | undefined): SomeType;
165
+ convertType(context: Context, type: ts.Type, node?: ts.TypeNode): SomeType;
164
166
  /**
165
167
  * Parse the given file into a comment. Intended to be used with markdown files.
166
168
  */
@@ -72,9 +72,6 @@ let Converter = (() => {
72
72
  let _excludeExternals_decorators;
73
73
  let _excludeExternals_initializers = [];
74
74
  let _excludeExternals_extraInitializers = [];
75
- let _excludeNotDocumented_decorators;
76
- let _excludeNotDocumented_initializers = [];
77
- let _excludeNotDocumented_extraInitializers = [];
78
75
  let _excludePrivate_decorators;
79
76
  let _excludePrivate_initializers = [];
80
77
  let _excludePrivate_extraInitializers = [];
@@ -104,7 +101,6 @@ let Converter = (() => {
104
101
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
105
102
  _externalPattern_decorators = [Option("externalPattern")];
106
103
  _excludeExternals_decorators = [Option("excludeExternals")];
107
- _excludeNotDocumented_decorators = [Option("excludeNotDocumented")];
108
104
  _excludePrivate_decorators = [Option("excludePrivate")];
109
105
  _excludeProtected_decorators = [Option("excludeProtected")];
110
106
  _excludeReferences_decorators = [Option("excludeReferences")];
@@ -115,7 +111,6 @@ let Converter = (() => {
115
111
  _maxTypeConversionDepth_decorators = [Option("maxTypeConversionDepth")];
116
112
  __esDecorate(this, null, _externalPattern_decorators, { kind: "accessor", name: "externalPattern", static: false, private: false, access: { has: obj => "externalPattern" in obj, get: obj => obj.externalPattern, set: (obj, value) => { obj.externalPattern = value; } }, metadata: _metadata }, _externalPattern_initializers, _externalPattern_extraInitializers);
117
113
  __esDecorate(this, null, _excludeExternals_decorators, { kind: "accessor", name: "excludeExternals", static: false, private: false, access: { has: obj => "excludeExternals" in obj, get: obj => obj.excludeExternals, set: (obj, value) => { obj.excludeExternals = value; } }, metadata: _metadata }, _excludeExternals_initializers, _excludeExternals_extraInitializers);
118
- __esDecorate(this, null, _excludeNotDocumented_decorators, { kind: "accessor", name: "excludeNotDocumented", static: false, private: false, access: { has: obj => "excludeNotDocumented" in obj, get: obj => obj.excludeNotDocumented, set: (obj, value) => { obj.excludeNotDocumented = value; } }, metadata: _metadata }, _excludeNotDocumented_initializers, _excludeNotDocumented_extraInitializers);
119
114
  __esDecorate(this, null, _excludePrivate_decorators, { kind: "accessor", name: "excludePrivate", static: false, private: false, access: { has: obj => "excludePrivate" in obj, get: obj => obj.excludePrivate, set: (obj, value) => { obj.excludePrivate = value; } }, metadata: _metadata }, _excludePrivate_initializers, _excludePrivate_extraInitializers);
120
115
  __esDecorate(this, null, _excludeProtected_decorators, { kind: "accessor", name: "excludeProtected", static: false, private: false, access: { has: obj => "excludeProtected" in obj, get: obj => obj.excludeProtected, set: (obj, value) => { obj.excludeProtected = value; } }, metadata: _metadata }, _excludeProtected_initializers, _excludeProtected_extraInitializers);
121
116
  __esDecorate(this, null, _excludeReferences_decorators, { kind: "accessor", name: "excludeReferences", static: false, private: false, access: { has: obj => "excludeReferences" in obj, get: obj => obj.excludeReferences, set: (obj, value) => { obj.excludeReferences = value; } }, metadata: _metadata }, _excludeReferences_initializers, _excludeReferences_extraInitializers);
@@ -136,11 +131,7 @@ let Converter = (() => {
136
131
  /** @internal */
137
132
  get excludeExternals() { return this.#excludeExternals_accessor_storage; }
138
133
  set excludeExternals(value) { this.#excludeExternals_accessor_storage = value; }
139
- #excludeNotDocumented_accessor_storage = (__runInitializers(this, _excludeExternals_extraInitializers), __runInitializers(this, _excludeNotDocumented_initializers, void 0));
140
- /** @internal */
141
- get excludeNotDocumented() { return this.#excludeNotDocumented_accessor_storage; }
142
- set excludeNotDocumented(value) { this.#excludeNotDocumented_accessor_storage = value; }
143
- #excludePrivate_accessor_storage = (__runInitializers(this, _excludeNotDocumented_extraInitializers), __runInitializers(this, _excludePrivate_initializers, void 0));
134
+ #excludePrivate_accessor_storage = (__runInitializers(this, _excludeExternals_extraInitializers), __runInitializers(this, _excludePrivate_initializers, void 0));
144
135
  /** @internal */
145
136
  get excludePrivate() { return this.#excludePrivate_accessor_storage; }
146
137
  set excludePrivate(value) { this.#excludePrivate_accessor_storage = value; }
@@ -255,6 +246,8 @@ let Converter = (() => {
255
246
  * @event
256
247
  */
257
248
  static EVENT_RESOLVE_END = ConverterEvents.RESOLVE_END;
249
+ /** @internal @hidden */
250
+ includePlugin;
258
251
  constructor(owner) {
259
252
  super(owner);
260
253
  const userConfiguredSymbolResolver = (ref, refl, _part, symbolId) => {
@@ -294,7 +287,7 @@ let Converter = (() => {
294
287
  new PackagePlugin(this);
295
288
  new SourcePlugin(this);
296
289
  new TypePlugin(this);
297
- new IncludePlugin(this);
290
+ this.includePlugin = new IncludePlugin(this);
298
291
  new MergeModuleWithPlugin(this);
299
292
  }
300
293
  /**
@@ -332,15 +325,8 @@ let Converter = (() => {
332
325
  convertSymbol(context, symbol, exportSymbol) {
333
326
  convertSymbol(context, symbol, exportSymbol);
334
327
  }
335
- /**
336
- * Convert the given TypeScript type into its TypeDoc type reflection.
337
- *
338
- * @param context The context object describing the current state the converter is in.
339
- * @returns The TypeDoc type reflection representing the given node and type.
340
- * @internal
341
- */
342
- convertType(context, node) {
343
- return convertType(context, node);
328
+ convertType(context, typeOrNode, maybeNode) {
329
+ return convertType(context, typeOrNode, maybeNode);
344
330
  }
345
331
  /**
346
332
  * Parse the given file into a comment. Intended to be used with markdown files.
@@ -485,7 +471,17 @@ let Converter = (() => {
485
471
  isExternal(symbol) {
486
472
  this.externalPatternCache ??= createMinimatch(this.externalPattern);
487
473
  const cache = this.externalPatternCache;
488
- return (symbol.getDeclarations() ?? []).some((node) => matchesAny(cache, node.getSourceFile().fileName));
474
+ const declarations = symbol.getDeclarations();
475
+ // `undefined` has no declarations, if someone does `export default undefined`
476
+ // the symbol ends up as having no declarations (the export symbol does, but
477
+ // not the source symbol)
478
+ if (!declarations?.length) {
479
+ return false;
480
+ }
481
+ // If there are any non-external declarations, treat it as non-external
482
+ // This is possible with declaration merging against external namespaces
483
+ // (e.g. merging with HTMLElementTagNameMap)
484
+ return declarations.every((node) => matchesAny(cache, node.getSourceFile().fileName));
489
485
  }
490
486
  processDocumentTags(reflection, parent) {
491
487
  let relativeTo = reflection.comment?.sourcePath;
@@ -513,6 +509,7 @@ let Converter = (() => {
513
509
  const children = frontmatter["children"];
514
510
  delete frontmatter["children"];
515
511
  const docRefl = new DocumentReflection(displayName, parent, content, frontmatter);
512
+ this.application.watchFile(file.fileName);
516
513
  parent.addChild(docRefl);
517
514
  parent.project.registerReflection(docRefl, undefined, file.fileName);
518
515
  this.trigger(ConverterEvents.CREATE_DOCUMENT, undefined, docRefl);
@@ -50,9 +50,11 @@ export function createSignature(context, kind, signature, symbol, declaration) {
50
50
  sigRef.type = new IntrinsicType("this");
51
51
  }
52
52
  else {
53
- sigRef.type = context.converter.convertType(sigRefCtx, (declaration?.kind === ts.SyntaxKind.FunctionDeclaration &&
54
- declaration.type) ||
55
- signature.getReturnType());
53
+ let typeNode = declaration?.type;
54
+ if (typeNode && ts.isJSDocReturnTag(typeNode)) {
55
+ typeNode = typeNode.typeExpression?.type;
56
+ }
57
+ sigRef.type = context.converter.convertType(sigRefCtx, signature.getReturnType(), typeNode);
56
58
  }
57
59
  context.registerReflection(sigRef, undefined);
58
60
  switch (kind) {
@@ -106,8 +108,15 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
106
108
  context.registerReflection(paramRefl, param);
107
109
  context.converter.trigger(ConverterEvents.CREATE_PARAMETER, context, paramRefl);
108
110
  let type;
111
+ let typeNode;
109
112
  if (declaration) {
110
113
  type = context.checker.getTypeOfSymbolAtLocation(param, declaration);
114
+ if (ts.isParameter(declaration)) {
115
+ typeNode = declaration.type;
116
+ }
117
+ else {
118
+ typeNode = declaration.typeExpression?.type;
119
+ }
111
120
  }
112
121
  else {
113
122
  type = param.type;
@@ -117,8 +126,11 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
117
126
  declaration.type?.kind === ts.SyntaxKind.ThisType) {
118
127
  paramRefl.type = new IntrinsicType("this");
119
128
  }
129
+ else if (!type) {
130
+ paramRefl.type = new IntrinsicType("any");
131
+ }
120
132
  else {
121
- paramRefl.type = context.converter.convertType(context.withScope(paramRefl), type);
133
+ paramRefl.type = context.converter.convertType(context.withScope(paramRefl), type, typeNode);
122
134
  }
123
135
  let isOptional = false;
124
136
  if (declaration) {
@@ -1,4 +1,5 @@
1
1
  import { ConverterComponent } from "../components.js";
2
+ import type { CommentDisplayPart, Reflection } from "../../models/index.js";
2
3
  import type { Converter } from "../converter.js";
3
4
  /**
4
5
  * Handles `@include` and `@includeCode` within comments/documents.
@@ -7,5 +8,7 @@ export declare class IncludePlugin extends ConverterComponent {
7
8
  get logger(): import("../../utils/loggers.js").Logger;
8
9
  constructor(owner: Converter);
9
10
  private onCreate;
10
- private checkIncludeTagsParts;
11
+ checkIncludeTagsParts(refl: Reflection, relative: string, parts: CommentDisplayPart[], included?: string[]): void;
12
+ getRegions(refl: Reflection, file: string, ext: string, textPart: string, text: string, regionTargets: string, tag: string, ignoreIndent: boolean): string;
13
+ getLines(refl: Reflection, file: string, textPart: string, text: string, requestedLines: string, tag: string): string;
11
14
  }