typedoc 0.24.0-beta.1 → 0.24.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 (80) hide show
  1. package/README.md +5 -32
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +6 -14
  4. package/dist/lib/application-events.d.ts +1 -0
  5. package/dist/lib/application-events.js +1 -0
  6. package/dist/lib/application.d.ts +6 -2
  7. package/dist/lib/application.js +21 -13
  8. package/dist/lib/cli.js +7 -14
  9. package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
  10. package/dist/lib/converter/comments/discovery.d.ts +1 -1
  11. package/dist/lib/converter/comments/discovery.js +76 -96
  12. package/dist/lib/converter/comments/index.d.ts +1 -1
  13. package/dist/lib/converter/comments/index.js +21 -41
  14. package/dist/lib/converter/comments/linkResolver.d.ts +7 -2
  15. package/dist/lib/converter/comments/linkResolver.js +27 -39
  16. package/dist/lib/converter/context.d.ts +1 -1
  17. package/dist/lib/converter/context.js +5 -25
  18. package/dist/lib/converter/convert-expression.d.ts +1 -1
  19. package/dist/lib/converter/convert-expression.js +15 -35
  20. package/dist/lib/converter/converter.d.ts +6 -4
  21. package/dist/lib/converter/converter.js +17 -36
  22. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  23. package/dist/lib/converter/factories/index-signature.js +3 -26
  24. package/dist/lib/converter/factories/signature.d.ts +1 -1
  25. package/dist/lib/converter/factories/signature.js +36 -53
  26. package/dist/lib/converter/index.d.ts +1 -0
  27. package/dist/lib/converter/jsdoc.d.ts +1 -1
  28. package/dist/lib/converter/jsdoc.js +17 -37
  29. package/dist/lib/converter/plugins/CommentPlugin.d.ts +2 -0
  30. package/dist/lib/converter/plugins/CommentPlugin.js +19 -4
  31. package/dist/lib/converter/plugins/ImplementsPlugin.js +9 -29
  32. package/dist/lib/converter/plugins/LinkResolverPlugin.js +10 -2
  33. package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -0
  34. package/dist/lib/converter/plugins/PackagePlugin.js +32 -37
  35. package/dist/lib/converter/plugins/SourcePlugin.js +6 -26
  36. package/dist/lib/converter/symbols.d.ts +1 -1
  37. package/dist/lib/converter/symbols.js +120 -142
  38. package/dist/lib/converter/types.d.ts +1 -1
  39. package/dist/lib/converter/types.js +89 -112
  40. package/dist/lib/converter/utils/nodes.d.ts +1 -1
  41. package/dist/lib/converter/utils/nodes.js +4 -24
  42. package/dist/lib/converter/utils/symbols.d.ts +1 -1
  43. package/dist/lib/converter/utils/symbols.js +4 -24
  44. package/dist/lib/models/comments/comment.d.ts +6 -0
  45. package/dist/lib/models/comments/comment.js +50 -0
  46. package/dist/lib/models/reflections/declaration.d.ts +2 -2
  47. package/dist/lib/models/reflections/declaration.js +1 -1
  48. package/dist/lib/models/reflections/type-parameter.d.ts +1 -1
  49. package/dist/lib/models/types.d.ts +1 -1
  50. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +1 -1
  51. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +1 -2
  52. package/dist/lib/output/themes/default/layouts/default.js +5 -5
  53. package/dist/lib/output/themes/default/partials/header.js +1 -1
  54. package/dist/lib/output/themes/default/partials/navigation.js +2 -2
  55. package/dist/lib/output/themes/lib.d.ts +2 -4
  56. package/dist/lib/output/themes/lib.js +3 -45
  57. package/dist/lib/utils/entry-point.d.ts +2 -2
  58. package/dist/lib/utils/entry-point.js +11 -8
  59. package/dist/lib/utils/fs.d.ts +13 -0
  60. package/dist/lib/utils/fs.js +105 -14
  61. package/dist/lib/utils/index.d.ts +2 -2
  62. package/dist/lib/utils/index.js +4 -1
  63. package/dist/lib/utils/loggers.d.ts +1 -1
  64. package/dist/lib/utils/loggers.js +8 -28
  65. package/dist/lib/utils/options/declaration.d.ts +3 -2
  66. package/dist/lib/utils/options/index.d.ts +1 -1
  67. package/dist/lib/utils/options/index.js +2 -1
  68. package/dist/lib/utils/options/readers/index.d.ts +1 -0
  69. package/dist/lib/utils/options/readers/index.js +3 -1
  70. package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
  71. package/dist/lib/utils/options/readers/package-json.js +45 -0
  72. package/dist/lib/utils/options/readers/tsconfig.js +4 -24
  73. package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
  74. package/dist/lib/utils/options/readers/typedoc.js +15 -4
  75. package/dist/lib/utils/options/sources/typedoc.js +56 -10
  76. package/dist/lib/utils/sort.d.ts +1 -1
  77. package/dist/lib/validation/documentation.js +13 -1
  78. package/package.json +16 -16
  79. package/static/main.js +55 -1
  80. package/static/style.css +4 -7
package/README.md CHANGED
@@ -19,7 +19,7 @@ npm install typedoc --save-dev
19
19
 
20
20
  ## Usage
21
21
 
22
- To generate documentation TypeDoc needs to know your project entry point, and TypeScript
22
+ To generate documentation TypeDoc needs to know your project entry point and TypeScript
23
23
  compiler options. It will automatically try to find your `tsconfig.json` file, so you can
24
24
  just specify the entry point of your library:
25
25
 
@@ -38,37 +38,10 @@ By default, TypeDoc will search for a file called `index` under the directory.
38
38
 
39
39
  ### Monorepos / Workspaces
40
40
 
41
- If your codebase is comprised of one or more npm packages, you can pass the paths to these
42
- packages and TypeDoc will attempt to determine entry points based on `package.json`'s `main`
43
- property (with default value `index.js`) and if it wasn't found, based on `types` property.
44
- If any of the packages given are the root of an [npm Workspace](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
45
- or a [Yarn Workspace](https://classic.yarnpkg.com/en/docs/workspaces/) TypeDoc will find all
46
- the `workspaces` defined in the `package.json`. In order to find your entry points, TypeDoc requires
47
- either that you turn on sourcemaps so that it can discover the original TS file, or that you
48
- specify `"typedocMain": "src/index.ts"` to explicitly state where the package entry point is.
49
- Supports wildcard paths in the same fashion as those found in npm or Yarn workspaces.
50
-
51
- #### Single npm module
52
-
53
- ```bash
54
- typedoc --entryPointStrategy packages .
55
- ```
56
-
57
- #### Monorepo with npm/Yarn workspace at the root
58
-
59
- ```bash
60
- typedoc --entryPointStrategy packages .
61
- ```
62
-
63
- #### Monorepo with manually specified sub-packages to document
64
-
65
- This can be useful if you do not want all your workspaces to be processed.
66
- Accepts the same paths as would go in the `package.json`'s workspaces
67
-
68
- ```bash
69
- # Note the single quotes prevent shell wildcard expansion, allowing typedoc to do the expansion
70
- typedoc --entryPointStrategy packages a-package 'some-more-packages/*' 'some-other-packages/*'
71
- ```
41
+ If your codebase is comprised of one or more npm packages, you can build documentation for each of them individually
42
+ and merge the results together into a single site by setting `entryPointStrategy` to `packages`. In this mode TypeDoc
43
+ requires configuration to be present in each directory to specify the entry points. For an example setup, see
44
+ `<TODO need to create example>`
72
45
 
73
46
  ### Arguments
74
47
 
package/dist/index.d.ts CHANGED
@@ -3,12 +3,12 @@ export { EventDispatcher, Event } from "./lib/utils/events";
3
3
  export { resetReflectionID } from "./lib/models/reflections/abstract";
4
4
  export { normalizePath } from "./lib/utils/fs";
5
5
  export * from "./lib/models";
6
- export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, } from "./lib/converter";
6
+ export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
7
7
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
8
8
  export type { RenderTemplate, RendererHooks } from "./lib/output";
9
- export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } from "./lib/utils";
9
+ export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } from "./lib/utils";
10
10
  export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, } from "./lib/utils";
11
11
  export type { EventMap, EventCallback } from "./lib/utils/events";
12
12
  export { JSONOutput, Serializer, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
13
- import * as TypeScript from "typescript";
13
+ import TypeScript from "typescript";
14
14
  export { TypeScript };
package/dist/index.js CHANGED
@@ -10,23 +10,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
15
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
18
  };
28
19
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
20
+ exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
30
21
  var application_1 = require("./lib/application");
31
22
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
32
23
  var events_1 = require("./lib/utils/events");
@@ -58,6 +49,7 @@ Object.defineProperty(exports, "JSX", { enumerable: true, get: function () { ret
58
49
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return utils_1.LogLevel; } });
59
50
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return utils_1.Logger; } });
60
51
  Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return utils_1.Options; } });
52
+ Object.defineProperty(exports, "PackageJsonReader", { enumerable: true, get: function () { return utils_1.PackageJsonReader; } });
61
53
  Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: function () { return utils_1.ParameterHint; } });
62
54
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return utils_1.ParameterType; } });
63
55
  Object.defineProperty(exports, "TSConfigReader", { enumerable: true, get: function () { return utils_1.TSConfigReader; } });
@@ -70,5 +62,5 @@ Object.defineProperty(exports, "JSONOutput", { enumerable: true, get: function (
70
62
  Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serialization_1.Serializer; } });
71
63
  Object.defineProperty(exports, "Deserializer", { enumerable: true, get: function () { return serialization_1.Deserializer; } });
72
64
  Object.defineProperty(exports, "SerializeEvent", { enumerable: true, get: function () { return serialization_1.SerializeEvent; } });
73
- const TypeScript = __importStar(require("typescript"));
74
- exports.TypeScript = TypeScript;
65
+ const typescript_1 = __importDefault(require("typescript"));
66
+ exports.TypeScript = typescript_1.default;
@@ -1,4 +1,5 @@
1
1
  export declare const ApplicationEvents: {
2
2
  BOOTSTRAP_END: string;
3
3
  REVIVE: string;
4
+ VALIDATE_PROJECT: string;
4
5
  };
@@ -4,4 +4,5 @@ exports.ApplicationEvents = void 0;
4
4
  exports.ApplicationEvents = {
5
5
  BOOTSTRAP_END: "bootstrapEnd",
6
6
  REVIVE: "reviveProject",
7
+ VALIDATE_PROJECT: "validateProject",
7
8
  };
@@ -59,12 +59,16 @@ export declare class Application extends ChildableComponent<Application, Abstrac
59
59
  static readonly EVENT_BOOTSTRAP_END: string;
60
60
  /**
61
61
  * Emitted after a project has been deserialized from JSON.
62
+ * The listener will be given an instance of {@link ProjectReflection}.
62
63
  */
63
64
  static readonly EVENT_PROJECT_REVIVE: string;
65
+ /**
66
+ * Emitted when validation is being run.
67
+ * The listener will be given an instance of {@link ProjectReflection}.
68
+ */
69
+ static readonly EVENT_VALIDATE_PROJECT: string;
64
70
  /**
65
71
  * Create a new TypeDoc application instance.
66
- *
67
- * @param options An object containing the options that should be used.
68
72
  */
69
73
  constructor();
70
74
  /**
@@ -28,11 +28,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  __setModuleDefault(result, mod);
29
29
  return result;
30
30
  };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
31
34
  var Application_1;
32
35
  Object.defineProperty(exports, "__esModule", { value: true });
33
36
  exports.Application = void 0;
34
37
  const Path = __importStar(require("path"));
35
- const ts = __importStar(require("typescript"));
38
+ const typescript_1 = __importDefault(require("typescript"));
36
39
  const index_1 = require("./converter/index");
37
40
  const renderer_1 = require("./output/renderer");
38
41
  const serialization_1 = require("./serialization");
@@ -72,8 +75,6 @@ const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
72
75
  let Application = Application_1 = class Application extends component_1.ChildableComponent {
73
76
  /**
74
77
  * Create a new TypeDoc application instance.
75
- *
76
- * @param options An object containing the options that should be used.
77
78
  */
78
79
  constructor() {
79
80
  super(null); // We own ourselves
@@ -135,7 +136,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
135
136
  return (0, paths_1.nicePath)(Path.dirname(require.resolve("typescript")));
136
137
  }
137
138
  getTypeScriptVersion() {
138
- return ts.version;
139
+ return typescript_1.default.version;
139
140
  }
140
141
  /**
141
142
  * Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
@@ -161,7 +162,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
161
162
  if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Packages) {
162
163
  return this._convertPackages();
163
164
  }
164
- if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
165
+ if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
165
166
  this.logger.warn(`You are running with an unsupported TypeScript version! If TypeDoc crashes, this is why. TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
166
167
  }
167
168
  const entryPoints = this.getEntryPoints();
@@ -172,7 +173,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
172
173
  const programs = (0, array_1.unique)(entryPoints.map((e) => e.program));
173
174
  this.logger.verbose(`Converting with ${programs.length} programs ${entryPoints.length} entry points`);
174
175
  if (this.skipErrorChecking === false) {
175
- const errors = programs.flatMap((program) => ts.getPreEmitDiagnostics(program));
176
+ const errors = programs.flatMap((program) => typescript_1.default.getPreEmitDiagnostics(program));
176
177
  if (errors.length) {
177
178
  this.logger.diagnostics(errors);
178
179
  return;
@@ -193,10 +194,10 @@ let Application = Application_1 = class Application extends component_1.Childabl
193
194
  this.options.freeze();
194
195
  if (!this.options.getValue("preserveWatchOutput") &&
195
196
  this.logger instanceof index_2.ConsoleLogger) {
196
- ts.sys.clearScreen?.();
197
+ typescript_1.default.sys.clearScreen?.();
197
198
  }
198
199
  this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
199
- if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
200
+ if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
200
201
  this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
201
202
  }
202
203
  if (Object.keys(this.options.getCompilerOptions()).length === 0) {
@@ -219,15 +220,15 @@ let Application = Application_1 = class Application extends component_1.Childabl
219
220
  // We don't want to do it the first time to preserve initial debug status messages. They'll be lost
220
221
  // after the user saves a file, but better than nothing...
221
222
  let firstStatusReport = true;
222
- const host = ts.createWatchCompilerHost(tsconfigFile, {}, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
223
+ const host = typescript_1.default.createWatchCompilerHost(tsconfigFile, {}, typescript_1.default.sys, typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
223
224
  if (!firstStatusReport &&
224
225
  errorCount === void 0 &&
225
226
  !this.options.getValue("preserveWatchOutput") &&
226
227
  this.logger instanceof index_2.ConsoleLogger) {
227
- ts.sys.clearScreen?.();
228
+ typescript_1.default.sys.clearScreen?.();
228
229
  }
229
230
  firstStatusReport = false;
230
- this.logger.info(ts.flattenDiagnosticMessageText(status.messageText, newLine));
231
+ this.logger.info(typescript_1.default.flattenDiagnosticMessageText(status.messageText, newLine));
231
232
  });
232
233
  let successFinished = true;
233
234
  let currentProgram;
@@ -264,13 +265,13 @@ let Application = Application_1 = class Application extends component_1.Childabl
264
265
  };
265
266
  const origAfterProgramCreate = host.afterProgramCreate;
266
267
  host.afterProgramCreate = (program) => {
267
- if (ts.getPreEmitDiagnostics(program.getProgram()).length === 0) {
268
+ if (typescript_1.default.getPreEmitDiagnostics(program.getProgram()).length === 0) {
268
269
  currentProgram = program.getProgram();
269
270
  runSuccess();
270
271
  }
271
272
  origAfterProgramCreate?.(program);
272
273
  };
273
- ts.createWatchProgram(host);
274
+ typescript_1.default.createWatchProgram(host);
274
275
  }
275
276
  validate(project) {
276
277
  const checks = this.options.getValue("validation");
@@ -287,6 +288,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
287
288
  if (checks.invalidLink) {
288
289
  (0, links_1.validateLinks)(project, this.logger);
289
290
  }
291
+ this.trigger(Application_1.EVENT_VALIDATE_PROJECT, project);
290
292
  this.logger.verbose(`Validation took ${Date.now() - start}ms`);
291
293
  }
292
294
  /**
@@ -404,8 +406,14 @@ Application.VERSION = packageInfo.version;
404
406
  Application.EVENT_BOOTSTRAP_END = application_events_1.ApplicationEvents.BOOTSTRAP_END;
405
407
  /**
406
408
  * Emitted after a project has been deserialized from JSON.
409
+ * The listener will be given an instance of {@link ProjectReflection}.
407
410
  */
408
411
  Application.EVENT_PROJECT_REVIVE = application_events_1.ApplicationEvents.REVIVE;
412
+ /**
413
+ * Emitted when validation is being run.
414
+ * The listener will be given an instance of {@link ProjectReflection}.
415
+ */
416
+ Application.EVENT_VALIDATE_PROJECT = application_events_1.ApplicationEvents.VALIDATE_PROJECT;
409
417
  __decorate([
410
418
  (0, utils_1.BindOption)("skipErrorChecking")
411
419
  ], Application.prototype, "skipErrorChecking", void 0);
package/dist/lib/cli.js CHANGED
@@ -36,6 +36,7 @@ const td = __importStar(require("typedoc"));
36
36
  const app = new td.Application();
37
37
  app.options.addReader(new td.ArgumentsReader(0));
38
38
  app.options.addReader(new td.TypeDocReader());
39
+ app.options.addReader(new td.PackageJsonReader());
39
40
  app.options.addReader(new td.TSConfigReader());
40
41
  app.options.addReader(new td.ArgumentsReader(300));
41
42
  void run(app)
@@ -74,17 +75,13 @@ async function run(app) {
74
75
  }
75
76
  if (app.options.getValue("watch")) {
76
77
  app.convertAndWatch(async (project) => {
77
- const out = app.options.getValue("out");
78
- if (out) {
79
- await app.generateDocs(project, out);
80
- }
81
78
  const json = app.options.getValue("json");
79
+ if (!json || app.options.isSet("out")) {
80
+ await app.generateDocs(project, app.options.getValue("out"));
81
+ }
82
82
  if (json) {
83
83
  await app.generateJson(project, json);
84
84
  }
85
- if (!out && !json) {
86
- await app.generateDocs(project, "./docs");
87
- }
88
85
  });
89
86
  return ExitCodes.Ok;
90
87
  }
@@ -105,17 +102,13 @@ async function run(app) {
105
102
  return ExitCodes.ValidationError;
106
103
  }
107
104
  if (app.options.getValue("emit") !== "none") {
108
- const out = app.options.getValue("out");
109
- if (out) {
110
- await app.generateDocs(project, out);
111
- }
112
105
  const json = app.options.getValue("json");
106
+ if (!json || app.options.isSet("out")) {
107
+ await app.generateDocs(project, app.options.getValue("out"));
108
+ }
113
109
  if (json) {
114
110
  await app.generateJson(project, json);
115
111
  }
116
- if (!out && !json) {
117
- await app.generateDocs(project, "./docs");
118
- }
119
112
  if (app.logger.hasErrors()) {
120
113
  return ExitCodes.OutputError;
121
114
  }
@@ -6,7 +6,7 @@
6
6
  * @module
7
7
  */
8
8
  export declare const MeaningKeywords: readonly ["class", "interface", "type", "enum", "namespace", "function", "var", "constructor", "member", "event", "call", "new", "index", "complex", "getter", "setter"];
9
- export type MeaningKeyword = typeof MeaningKeywords[number];
9
+ export type MeaningKeyword = (typeof MeaningKeywords)[number];
10
10
  export interface DeclarationReference {
11
11
  resolutionStart: "global" | "local";
12
12
  moduleSource?: string;
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import { ReflectionKind } from "../../models";
3
3
  import { Logger } from "../../utils";
4
4
  import { CommentStyle } from "../../utils/options/declaration";
@@ -1,30 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.discoverSignatureComment = exports.discoverComment = void 0;
27
- const ts = __importStar(require("typescript"));
7
+ const typescript_1 = __importDefault(require("typescript"));
28
8
  const models_1 = require("../../models");
29
9
  const utils_1 = require("../../utils");
30
10
  const declaration_1 = require("../../utils/options/declaration");
@@ -34,84 +14,84 @@ const paths_1 = require("../../utils/paths");
34
14
  // the JSDoc converter because we only want part of the comment when
35
15
  // getting them.
36
16
  const wantedKinds = {
37
- [models_1.ReflectionKind.Project]: [ts.SyntaxKind.SourceFile],
38
- [models_1.ReflectionKind.Module]: [ts.SyntaxKind.SourceFile],
17
+ [models_1.ReflectionKind.Project]: [typescript_1.default.SyntaxKind.SourceFile],
18
+ [models_1.ReflectionKind.Module]: [typescript_1.default.SyntaxKind.SourceFile],
39
19
  [models_1.ReflectionKind.Namespace]: [
40
- ts.SyntaxKind.ModuleDeclaration,
41
- ts.SyntaxKind.SourceFile,
42
- ts.SyntaxKind.BindingElement,
43
- ts.SyntaxKind.ExportSpecifier,
44
- ts.SyntaxKind.NamespaceExport,
20
+ typescript_1.default.SyntaxKind.ModuleDeclaration,
21
+ typescript_1.default.SyntaxKind.SourceFile,
22
+ typescript_1.default.SyntaxKind.BindingElement,
23
+ typescript_1.default.SyntaxKind.ExportSpecifier,
24
+ typescript_1.default.SyntaxKind.NamespaceExport,
45
25
  ],
46
26
  [models_1.ReflectionKind.Enum]: [
47
- ts.SyntaxKind.EnumDeclaration,
48
- ts.SyntaxKind.VariableDeclaration,
27
+ typescript_1.default.SyntaxKind.EnumDeclaration,
28
+ typescript_1.default.SyntaxKind.VariableDeclaration,
49
29
  ],
50
30
  [models_1.ReflectionKind.EnumMember]: [
51
- ts.SyntaxKind.EnumMember,
31
+ typescript_1.default.SyntaxKind.EnumMember,
52
32
  // These here so that @enum gets comments
53
- ts.SyntaxKind.PropertyAssignment,
54
- ts.SyntaxKind.PropertySignature,
33
+ typescript_1.default.SyntaxKind.PropertyAssignment,
34
+ typescript_1.default.SyntaxKind.PropertySignature,
55
35
  ],
56
36
  [models_1.ReflectionKind.Variable]: [
57
- ts.SyntaxKind.VariableDeclaration,
58
- ts.SyntaxKind.BindingElement,
59
- ts.SyntaxKind.ExportAssignment,
60
- ts.SyntaxKind.PropertyAccessExpression,
37
+ typescript_1.default.SyntaxKind.VariableDeclaration,
38
+ typescript_1.default.SyntaxKind.BindingElement,
39
+ typescript_1.default.SyntaxKind.ExportAssignment,
40
+ typescript_1.default.SyntaxKind.PropertyAccessExpression,
61
41
  ],
62
42
  [models_1.ReflectionKind.Function]: [
63
- ts.SyntaxKind.FunctionDeclaration,
64
- ts.SyntaxKind.BindingElement,
65
- ts.SyntaxKind.VariableDeclaration,
66
- ts.SyntaxKind.ExportAssignment,
67
- ts.SyntaxKind.PropertyAccessExpression,
43
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
44
+ typescript_1.default.SyntaxKind.BindingElement,
45
+ typescript_1.default.SyntaxKind.VariableDeclaration,
46
+ typescript_1.default.SyntaxKind.ExportAssignment,
47
+ typescript_1.default.SyntaxKind.PropertyAccessExpression,
68
48
  ],
69
49
  [models_1.ReflectionKind.Class]: [
70
- ts.SyntaxKind.ClassDeclaration,
71
- ts.SyntaxKind.BindingElement,
50
+ typescript_1.default.SyntaxKind.ClassDeclaration,
51
+ typescript_1.default.SyntaxKind.BindingElement,
72
52
  ],
73
- [models_1.ReflectionKind.Interface]: [ts.SyntaxKind.InterfaceDeclaration],
74
- [models_1.ReflectionKind.Constructor]: [ts.SyntaxKind.Constructor],
53
+ [models_1.ReflectionKind.Interface]: [typescript_1.default.SyntaxKind.InterfaceDeclaration],
54
+ [models_1.ReflectionKind.Constructor]: [typescript_1.default.SyntaxKind.Constructor],
75
55
  [models_1.ReflectionKind.Property]: [
76
- ts.SyntaxKind.PropertyDeclaration,
77
- ts.SyntaxKind.PropertySignature,
78
- ts.SyntaxKind.BinaryExpression,
79
- ts.SyntaxKind.PropertyAssignment,
56
+ typescript_1.default.SyntaxKind.PropertyDeclaration,
57
+ typescript_1.default.SyntaxKind.PropertySignature,
58
+ typescript_1.default.SyntaxKind.BinaryExpression,
59
+ typescript_1.default.SyntaxKind.PropertyAssignment,
80
60
  // class X { constructor(/** Comment */ readonly z: string) }
81
- ts.SyntaxKind.Parameter,
61
+ typescript_1.default.SyntaxKind.Parameter,
82
62
  ],
83
63
  [models_1.ReflectionKind.Method]: [
84
- ts.SyntaxKind.FunctionDeclaration,
85
- ts.SyntaxKind.MethodDeclaration,
64
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
65
+ typescript_1.default.SyntaxKind.MethodDeclaration,
86
66
  ],
87
67
  [models_1.ReflectionKind.CallSignature]: [
88
- ts.SyntaxKind.FunctionDeclaration,
89
- ts.SyntaxKind.VariableDeclaration,
90
- ts.SyntaxKind.MethodDeclaration,
91
- ts.SyntaxKind.MethodDeclaration,
92
- ts.SyntaxKind.PropertyDeclaration,
93
- ts.SyntaxKind.PropertySignature,
94
- ts.SyntaxKind.CallSignature,
68
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
69
+ typescript_1.default.SyntaxKind.VariableDeclaration,
70
+ typescript_1.default.SyntaxKind.MethodDeclaration,
71
+ typescript_1.default.SyntaxKind.MethodDeclaration,
72
+ typescript_1.default.SyntaxKind.PropertyDeclaration,
73
+ typescript_1.default.SyntaxKind.PropertySignature,
74
+ typescript_1.default.SyntaxKind.CallSignature,
95
75
  ],
96
- [models_1.ReflectionKind.IndexSignature]: [ts.SyntaxKind.IndexSignature],
97
- [models_1.ReflectionKind.ConstructorSignature]: [ts.SyntaxKind.ConstructSignature],
98
- [models_1.ReflectionKind.Parameter]: [ts.SyntaxKind.Parameter],
99
- [models_1.ReflectionKind.TypeLiteral]: [ts.SyntaxKind.TypeLiteral],
100
- [models_1.ReflectionKind.TypeParameter]: [ts.SyntaxKind.TypeParameter],
101
- [models_1.ReflectionKind.Accessor]: [ts.SyntaxKind.PropertyDeclaration],
102
- [models_1.ReflectionKind.GetSignature]: [ts.SyntaxKind.GetAccessor],
103
- [models_1.ReflectionKind.SetSignature]: [ts.SyntaxKind.SetAccessor],
104
- [models_1.ReflectionKind.ObjectLiteral]: [ts.SyntaxKind.ObjectLiteralExpression],
105
- [models_1.ReflectionKind.TypeAlias]: [ts.SyntaxKind.TypeAliasDeclaration],
76
+ [models_1.ReflectionKind.IndexSignature]: [typescript_1.default.SyntaxKind.IndexSignature],
77
+ [models_1.ReflectionKind.ConstructorSignature]: [typescript_1.default.SyntaxKind.ConstructSignature],
78
+ [models_1.ReflectionKind.Parameter]: [typescript_1.default.SyntaxKind.Parameter],
79
+ [models_1.ReflectionKind.TypeLiteral]: [typescript_1.default.SyntaxKind.TypeLiteral],
80
+ [models_1.ReflectionKind.TypeParameter]: [typescript_1.default.SyntaxKind.TypeParameter],
81
+ [models_1.ReflectionKind.Accessor]: [typescript_1.default.SyntaxKind.PropertyDeclaration],
82
+ [models_1.ReflectionKind.GetSignature]: [typescript_1.default.SyntaxKind.GetAccessor],
83
+ [models_1.ReflectionKind.SetSignature]: [typescript_1.default.SyntaxKind.SetAccessor],
84
+ [models_1.ReflectionKind.ObjectLiteral]: [typescript_1.default.SyntaxKind.ObjectLiteralExpression],
85
+ [models_1.ReflectionKind.TypeAlias]: [typescript_1.default.SyntaxKind.TypeAliasDeclaration],
106
86
  [models_1.ReflectionKind.Reference]: [
107
- ts.SyntaxKind.NamespaceExport,
108
- ts.SyntaxKind.ExportSpecifier,
87
+ typescript_1.default.SyntaxKind.NamespaceExport,
88
+ typescript_1.default.SyntaxKind.ExportSpecifier,
109
89
  ],
110
90
  };
111
91
  function discoverComment(symbol, kind, logger, commentStyle) {
112
92
  // For a module comment, we want the first one defined in the file,
113
93
  // not the last one, since that will apply to the import or declaration.
114
- const reverse = !symbol.declarations?.some(ts.isSourceFile);
94
+ const reverse = !symbol.declarations?.some(typescript_1.default.isSourceFile);
115
95
  const discovered = [];
116
96
  for (const decl of symbol.declarations || []) {
117
97
  const text = decl.getSourceFile().text;
@@ -127,14 +107,14 @@ function discoverComment(symbol, kind, logger, commentStyle) {
127
107
  // See the gh1770 test for an example.
128
108
  if (kind & models_1.ReflectionKind.ContainsCallSignatures &&
129
109
  [
130
- ts.SyntaxKind.FunctionDeclaration,
131
- ts.SyntaxKind.MethodDeclaration,
132
- ts.SyntaxKind.Constructor,
110
+ typescript_1.default.SyntaxKind.FunctionDeclaration,
111
+ typescript_1.default.SyntaxKind.MethodDeclaration,
112
+ typescript_1.default.SyntaxKind.Constructor,
133
113
  ].includes(node.kind) &&
134
114
  !node.body) {
135
115
  continue;
136
116
  }
137
- const comments = collectCommentRanges(ts.getLeadingCommentRanges(text, node.pos));
117
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
138
118
  if (reverse) {
139
119
  comments.reverse();
140
120
  }
@@ -153,7 +133,7 @@ function discoverComment(symbol, kind, logger, commentStyle) {
153
133
  logger.warn(`${symbol.name} has multiple declarations with a comment. An arbitrary comment will be used.`);
154
134
  const locations = discovered.map(([sf, [{ pos }]]) => {
155
135
  const path = (0, paths_1.nicePath)(sf.fileName);
156
- const line = ts.getLineAndCharacterOfPosition(sf, pos).line + 1;
136
+ const line = typescript_1.default.getLineAndCharacterOfPosition(sf, pos).line + 1;
157
137
  return `${path}:${line}`;
158
138
  });
159
139
  logger.info(`The comments for ${symbol.name} are declared at:\n\t${locations.join("\n\t")}`);
@@ -168,7 +148,7 @@ function discoverSignatureComment(declaration, commentStyle) {
168
148
  return;
169
149
  }
170
150
  const text = node.getSourceFile().text;
171
- const comments = collectCommentRanges(ts.getLeadingCommentRanges(text, node.pos));
151
+ const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
172
152
  comments.reverse();
173
153
  const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
174
154
  if (comment) {
@@ -190,7 +170,7 @@ exports.discoverSignatureComment = discoverSignatureComment;
190
170
  * @return TRUE if the given node is the topmost module declaration, FALSE otherwise.
191
171
  */
192
172
  function isTopmostModuleDeclaration(node) {
193
- return node.getChildren().some(ts.isModuleBlock);
173
+ return node.getChildren().some(typescript_1.default.isModuleBlock);
194
174
  }
195
175
  /**
196
176
  * Return the root module declaration of the given module declaration.
@@ -204,7 +184,7 @@ function isTopmostModuleDeclaration(node) {
204
184
  */
205
185
  function getRootModuleDeclaration(node) {
206
186
  while (node.parent &&
207
- node.parent.kind === ts.SyntaxKind.ModuleDeclaration) {
187
+ node.parent.kind === typescript_1.default.SyntaxKind.ModuleDeclaration) {
208
188
  const parent = node.parent;
209
189
  if (node.name.pos === parent.name.end + 1) {
210
190
  node = parent;
@@ -220,12 +200,12 @@ function declarationToCommentNode(node) {
220
200
  return node;
221
201
  // const abc = 123
222
202
  // ^^^
223
- if (node.parent.kind === ts.SyntaxKind.VariableDeclarationList) {
203
+ if (node.parent.kind === typescript_1.default.SyntaxKind.VariableDeclarationList) {
224
204
  return node.parent.parent;
225
205
  }
226
206
  // const a = () => {}
227
207
  // ^^^^^^^^
228
- if (node.parent.kind === ts.SyntaxKind.VariableDeclaration) {
208
+ if (node.parent.kind === typescript_1.default.SyntaxKind.VariableDeclaration) {
229
209
  return node.parent.parent.parent;
230
210
  }
231
211
  // class X { y = () => {} }
@@ -236,13 +216,13 @@ function declarationToCommentNode(node) {
236
216
  // export default () => {}
237
217
  // ^^^^^^^^
238
218
  if ([
239
- ts.SyntaxKind.PropertyDeclaration,
240
- ts.SyntaxKind.BinaryExpression,
241
- ts.SyntaxKind.ExportAssignment,
219
+ typescript_1.default.SyntaxKind.PropertyDeclaration,
220
+ typescript_1.default.SyntaxKind.BinaryExpression,
221
+ typescript_1.default.SyntaxKind.ExportAssignment,
242
222
  ].includes(node.parent.kind)) {
243
223
  return node.parent;
244
224
  }
245
- if (ts.isModuleDeclaration(node)) {
225
+ if (typescript_1.default.isModuleDeclaration(node)) {
246
226
  if (!isTopmostModuleDeclaration(node)) {
247
227
  return;
248
228
  }
@@ -250,10 +230,10 @@ function declarationToCommentNode(node) {
250
230
  return getRootModuleDeclaration(node);
251
231
  }
252
232
  }
253
- if (node.kind === ts.SyntaxKind.ExportSpecifier) {
233
+ if (node.kind === typescript_1.default.SyntaxKind.ExportSpecifier) {
254
234
  return node.parent.parent;
255
235
  }
256
- if ([ts.SyntaxKind.NamespaceExport, ts.SyntaxKind.FunctionType].includes(node.kind)) {
236
+ if ([typescript_1.default.SyntaxKind.NamespaceExport, typescript_1.default.SyntaxKind.FunctionType].includes(node.kind)) {
257
237
  return node.parent;
258
238
  }
259
239
  return node;
@@ -268,14 +248,14 @@ function collectCommentRanges(ranges) {
268
248
  for (const range of ranges || []) {
269
249
  collect.push(range);
270
250
  switch (range.kind) {
271
- case ts.SyntaxKind.MultiLineCommentTrivia:
251
+ case typescript_1.default.SyntaxKind.MultiLineCommentTrivia:
272
252
  if (collect.length) {
273
253
  result.push(collect);
274
254
  collect = [];
275
255
  }
276
256
  result.push([range]);
277
257
  break;
278
- case ts.SyntaxKind.SingleLineCommentTrivia:
258
+ case typescript_1.default.SyntaxKind.SingleLineCommentTrivia:
279
259
  collect.push(range);
280
260
  break;
281
261
  /* istanbul ignore next */
@@ -293,11 +273,11 @@ function permittedRange(text, ranges, commentStyle) {
293
273
  case declaration_1.CommentStyle.All:
294
274
  return true;
295
275
  case declaration_1.CommentStyle.Block:
296
- return ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia;
276
+ return ranges[0].kind === typescript_1.default.SyntaxKind.MultiLineCommentTrivia;
297
277
  case declaration_1.CommentStyle.Line:
298
- return ranges[0].kind === ts.SyntaxKind.SingleLineCommentTrivia;
278
+ return ranges[0].kind === typescript_1.default.SyntaxKind.SingleLineCommentTrivia;
299
279
  case declaration_1.CommentStyle.JSDoc:
300
- return (ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia &&
280
+ return (ranges[0].kind === typescript_1.default.SyntaxKind.MultiLineCommentTrivia &&
301
281
  text[ranges[0].pos] === "/" &&
302
282
  text[ranges[0].pos + 1] === "*" &&
303
283
  text[ranges[0].pos + 2] === "*");