typedoc 0.23.25 → 0.24.0-beta.1

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 (159) hide show
  1. package/bin/typedoc +1 -130
  2. package/dist/index.d.ts +3 -4
  3. package/dist/index.js +15 -5
  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 +26 -10
  7. package/dist/lib/application.js +138 -65
  8. package/dist/lib/cli.d.ts +1 -0
  9. package/dist/lib/cli.js +129 -0
  10. package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
  11. package/dist/lib/converter/comments/declarationReferenceResolver.js +11 -5
  12. package/dist/lib/converter/comments/discovery.d.ts +1 -1
  13. package/dist/lib/converter/comments/discovery.js +96 -76
  14. package/dist/lib/converter/comments/index.d.ts +1 -1
  15. package/dist/lib/converter/comments/index.js +37 -17
  16. package/dist/lib/converter/comments/linkResolver.d.ts +2 -3
  17. package/dist/lib/converter/comments/linkResolver.js +37 -132
  18. package/dist/lib/converter/context.d.ts +1 -1
  19. package/dist/lib/converter/context.js +27 -14
  20. package/dist/lib/converter/convert-expression.d.ts +1 -1
  21. package/dist/lib/converter/convert-expression.js +35 -15
  22. package/dist/lib/converter/converter.d.ts +1 -1
  23. package/dist/lib/converter/converter.js +35 -23
  24. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  25. package/dist/lib/converter/factories/index-signature.js +26 -3
  26. package/dist/lib/converter/factories/signature.d.ts +2 -2
  27. package/dist/lib/converter/factories/signature.js +76 -52
  28. package/dist/lib/converter/jsdoc.d.ts +1 -1
  29. package/dist/lib/converter/jsdoc.js +39 -17
  30. package/dist/lib/converter/plugins/CommentPlugin.d.ts +0 -2
  31. package/dist/lib/converter/plugins/CommentPlugin.js +7 -28
  32. package/dist/lib/converter/plugins/GroupPlugin.d.ts +1 -39
  33. package/dist/lib/converter/plugins/GroupPlugin.js +3 -61
  34. package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +1 -4
  35. package/dist/lib/converter/plugins/ImplementsPlugin.js +49 -28
  36. package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +0 -3
  37. package/dist/lib/converter/plugins/InheritDocPlugin.js +6 -7
  38. package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +2 -3
  39. package/dist/lib/converter/plugins/LinkResolverPlugin.js +12 -10
  40. package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -14
  41. package/dist/lib/converter/plugins/PackagePlugin.js +44 -56
  42. package/dist/lib/converter/plugins/SourcePlugin.js +31 -6
  43. package/dist/lib/converter/plugins/TypePlugin.d.ts +4 -10
  44. package/dist/lib/converter/plugins/TypePlugin.js +23 -13
  45. package/dist/lib/converter/symbols.d.ts +1 -1
  46. package/dist/lib/converter/symbols.js +153 -132
  47. package/dist/lib/converter/types.d.ts +1 -1
  48. package/dist/lib/converter/types.js +121 -95
  49. package/dist/lib/converter/utils/nodes.d.ts +1 -1
  50. package/dist/lib/converter/utils/nodes.js +24 -4
  51. package/dist/lib/converter/utils/symbols.d.ts +1 -1
  52. package/dist/lib/converter/utils/symbols.js +24 -4
  53. package/dist/lib/models/ReflectionCategory.d.ts +2 -1
  54. package/dist/lib/models/ReflectionCategory.js +12 -0
  55. package/dist/lib/models/ReflectionGroup.d.ts +3 -2
  56. package/dist/lib/models/ReflectionGroup.js +20 -0
  57. package/dist/lib/models/comments/comment.d.ts +12 -1
  58. package/dist/lib/models/comments/comment.js +80 -17
  59. package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +29 -0
  60. package/dist/lib/models/reflections/ReflectionSymbolId.js +94 -0
  61. package/dist/lib/models/reflections/abstract.d.ts +12 -37
  62. package/dist/lib/models/reflections/abstract.js +27 -35
  63. package/dist/lib/models/reflections/container.d.ts +6 -10
  64. package/dist/lib/models/reflections/container.js +8 -1
  65. package/dist/lib/models/reflections/declaration.d.ts +19 -4
  66. package/dist/lib/models/reflections/declaration.js +54 -1
  67. package/dist/lib/models/reflections/index.d.ts +2 -0
  68. package/dist/lib/models/reflections/index.js +3 -1
  69. package/dist/lib/models/reflections/kind.d.ts +15 -1
  70. package/dist/lib/models/reflections/kind.js +43 -1
  71. package/dist/lib/models/reflections/parameter.d.ts +3 -1
  72. package/dist/lib/models/reflections/parameter.js +10 -0
  73. package/dist/lib/models/reflections/project.d.ts +32 -5
  74. package/dist/lib/models/reflections/project.js +84 -20
  75. package/dist/lib/models/reflections/reference.d.ts +5 -9
  76. package/dist/lib/models/reflections/reference.js +13 -29
  77. package/dist/lib/models/reflections/signature.d.ts +8 -1
  78. package/dist/lib/models/reflections/signature.js +14 -0
  79. package/dist/lib/models/reflections/type-parameter.d.ts +7 -4
  80. package/dist/lib/models/reflections/type-parameter.js +9 -3
  81. package/dist/lib/models/reflections/variant.d.ts +18 -0
  82. package/dist/lib/models/reflections/variant.js +2 -0
  83. package/dist/lib/models/sources/file.d.ts +2 -0
  84. package/dist/lib/models/sources/file.js +3 -0
  85. package/dist/lib/models/types.d.ts +24 -20
  86. package/dist/lib/models/types.js +132 -33
  87. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +3 -7
  88. package/dist/lib/output/renderer.d.ts +21 -14
  89. package/dist/lib/output/renderer.js +25 -25
  90. package/dist/lib/output/themes/MarkedPlugin.js +2 -3
  91. package/dist/lib/output/themes/default/DefaultTheme.d.ts +2 -20
  92. package/dist/lib/output/themes/default/DefaultTheme.js +4 -75
  93. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +9 -8
  94. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +54 -0
  95. package/dist/lib/output/themes/default/partials/header.js +2 -5
  96. package/dist/lib/output/themes/default/partials/index.js +2 -2
  97. package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +2 -2
  98. package/dist/lib/output/themes/default/partials/member.getterSetter.js +4 -1
  99. package/dist/lib/output/themes/default/partials/member.js +1 -1
  100. package/dist/lib/output/themes/default/partials/member.signatures.js +2 -1
  101. package/dist/lib/output/themes/default/partials/members.d.ts +1 -1
  102. package/dist/lib/output/themes/default/partials/members.js +3 -1
  103. package/dist/lib/output/themes/default/partials/navigation.js +6 -4
  104. package/dist/lib/output/themes/default/partials/parameter.js +1 -1
  105. package/dist/lib/output/themes/default/partials/type.js +4 -4
  106. package/dist/lib/output/themes/default/templates/reflection.js +1 -1
  107. package/dist/lib/output/themes/lib.d.ts +1 -0
  108. package/dist/lib/output/themes/lib.js +13 -3
  109. package/dist/lib/serialization/deserializer.d.ts +54 -0
  110. package/dist/lib/serialization/deserializer.js +212 -0
  111. package/dist/lib/serialization/events.d.ts +0 -15
  112. package/dist/lib/serialization/index.d.ts +2 -3
  113. package/dist/lib/serialization/index.js +4 -3
  114. package/dist/lib/serialization/schema.d.ts +23 -17
  115. package/dist/lib/serialization/serializer.d.ts +5 -5
  116. package/dist/lib/serialization/serializer.js +4 -15
  117. package/dist/lib/utils/array.d.ts +0 -1
  118. package/dist/lib/utils/array.js +1 -2
  119. package/dist/lib/utils/entry-point.d.ts +15 -4
  120. package/dist/lib/utils/entry-point.js +45 -28
  121. package/dist/lib/utils/enum.d.ts +4 -1
  122. package/dist/lib/utils/enum.js +2 -3
  123. package/dist/lib/utils/fs.d.ts +3 -1
  124. package/dist/lib/utils/fs.js +36 -73
  125. package/dist/lib/utils/index.d.ts +4 -3
  126. package/dist/lib/utils/index.js +3 -3
  127. package/dist/lib/utils/loggers.d.ts +5 -26
  128. package/dist/lib/utils/loggers.js +38 -42
  129. package/dist/lib/utils/map.d.ts +17 -0
  130. package/dist/lib/utils/map.js +49 -1
  131. package/dist/lib/utils/options/declaration.d.ts +20 -6
  132. package/dist/lib/utils/options/help.js +1 -1
  133. package/dist/lib/utils/options/options.d.ts +27 -18
  134. package/dist/lib/utils/options/options.js +68 -14
  135. package/dist/lib/utils/options/readers/arguments.d.ts +2 -1
  136. package/dist/lib/utils/options/readers/arguments.js +9 -2
  137. package/dist/lib/utils/options/readers/tsconfig.d.ts +3 -7
  138. package/dist/lib/utils/options/readers/tsconfig.js +35 -36
  139. package/dist/lib/utils/options/readers/typedoc.d.ts +4 -5
  140. package/dist/lib/utils/options/readers/typedoc.js +9 -21
  141. package/dist/lib/utils/options/sources/typedoc.js +18 -64
  142. package/dist/lib/utils/package-manifest.d.ts +1 -1
  143. package/dist/lib/utils/package-manifest.js +1 -2
  144. package/dist/lib/utils/paths.d.ts +2 -2
  145. package/dist/lib/utils/paths.js +2 -0
  146. package/dist/lib/utils/plugins.d.ts +1 -2
  147. package/dist/lib/utils/plugins.js +22 -106
  148. package/dist/lib/utils/sort.d.ts +1 -1
  149. package/dist/lib/utils/sort.js +8 -11
  150. package/dist/lib/utils/tsconfig.d.ts +4 -0
  151. package/dist/lib/utils/tsconfig.js +36 -0
  152. package/dist/lib/utils/tsutils.d.ts +3 -2
  153. package/dist/lib/utils/tsutils.js +46 -12
  154. package/dist/lib/validation/documentation.d.ts +1 -1
  155. package/dist/lib/validation/documentation.js +5 -16
  156. package/dist/lib/validation/exports.js +18 -21
  157. package/dist/lib/validation/links.js +1 -1
  158. package/package.json +18 -19
  159. package/static/main.js +0 -54
package/bin/typedoc CHANGED
@@ -2,133 +2,4 @@
2
2
  //@ts-check
3
3
 
4
4
  /* eslint-disable @typescript-eslint/no-var-requires */
5
-
6
- const ExitCodes = {
7
- Ok: 0,
8
- OptionError: 1,
9
- NoEntryPoints: 2,
10
- CompileError: 3,
11
- ValidationError: 4,
12
- OutputError: 5,
13
- ExceptionThrown: 6,
14
- };
15
-
16
- const td = require("..");
17
- const { getOptionsHelp } = require("../dist/lib/utils/options/help");
18
-
19
- const app = new td.Application();
20
-
21
- app.options.addReader(new td.ArgumentsReader(0));
22
- app.options.addReader(new td.TypeDocReader());
23
- app.options.addReader(new td.TSConfigReader());
24
- app.options.addReader(new td.ArgumentsReader(300));
25
-
26
- app.bootstrap();
27
-
28
- run(app)
29
- .catch((error) => {
30
- console.error("TypeDoc exiting with unexpected error:");
31
- console.error(error);
32
- return ExitCodes.ExceptionThrown;
33
- })
34
- .then((exitCode) => (process.exitCode = exitCode));
35
-
36
- /** @param {td.Application} app */
37
- async function run(app) {
38
- if (app.options.getValue("version")) {
39
- console.log(app.toString());
40
- return ExitCodes.Ok;
41
- }
42
-
43
- if (app.options.getValue("help")) {
44
- console.log(getOptionsHelp(app.options));
45
- return ExitCodes.Ok;
46
- }
47
-
48
- if (app.options.getValue("showConfig")) {
49
- console.log(app.options.getRawValues());
50
- return ExitCodes.Ok;
51
- }
52
-
53
- if (app.logger.hasErrors()) {
54
- return ExitCodes.OptionError;
55
- }
56
- if (
57
- app.options.getValue("treatWarningsAsErrors") &&
58
- app.logger.hasWarnings()
59
- ) {
60
- return ExitCodes.OptionError;
61
- }
62
-
63
- if (app.options.getValue("entryPoints").length === 0) {
64
- app.logger.error("No entry points provided");
65
- return ExitCodes.NoEntryPoints;
66
- }
67
-
68
- if (app.options.getValue("watch")) {
69
- app.convertAndWatch(async (project) => {
70
- const out = app.options.getValue("out");
71
- if (out) {
72
- await app.generateDocs(project, out);
73
- }
74
- const json = app.options.getValue("json");
75
- if (json) {
76
- await app.generateJson(project, json);
77
- }
78
-
79
- if (!out && !json) {
80
- await app.generateDocs(project, "./docs");
81
- }
82
- });
83
- return ExitCodes.Ok;
84
- }
85
-
86
- const project = app.convert();
87
- if (!project) {
88
- return ExitCodes.CompileError;
89
- }
90
- if (
91
- app.options.getValue("treatWarningsAsErrors") &&
92
- app.logger.hasWarnings()
93
- ) {
94
- return ExitCodes.CompileError;
95
- }
96
-
97
- app.validate(project);
98
- if (app.logger.hasErrors()) {
99
- return ExitCodes.ValidationError;
100
- }
101
- if (
102
- app.options.getValue("treatWarningsAsErrors") &&
103
- app.logger.hasWarnings()
104
- ) {
105
- return ExitCodes.ValidationError;
106
- }
107
-
108
- if (app.options.getValue("emit") !== "none") {
109
- const out = app.options.getValue("out");
110
- if (out) {
111
- await app.generateDocs(project, out);
112
- }
113
- const json = app.options.getValue("json");
114
- if (json) {
115
- await app.generateJson(project, json);
116
- }
117
-
118
- if (!out && !json) {
119
- await app.generateDocs(project, "./docs");
120
- }
121
-
122
- if (app.logger.hasErrors()) {
123
- return ExitCodes.OutputError;
124
- }
125
- if (
126
- app.options.getValue("treatWarningsAsErrors") &&
127
- app.logger.hasWarnings()
128
- ) {
129
- return ExitCodes.OutputError;
130
- }
131
- }
132
-
133
- return ExitCodes.Ok;
134
- }
5
+ require("../dist/lib/cli");
package/dist/index.d.ts CHANGED
@@ -7,9 +7,8 @@ export { Converter, Context, type CommentParserConfig, type DeclarationReference
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
9
  export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } from "./lib/utils";
10
- export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, } from "./lib/utils";
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
- export { JSONOutput, Serializer, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
13
- export type { SerializeEventData } from "./lib/serialization";
14
- import TypeScript from "typescript";
12
+ export { JSONOutput, Serializer, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
13
+ import * as TypeScript from "typescript";
15
14
  export { TypeScript };
package/dist/index.js CHANGED
@@ -10,14 +10,23 @@ 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
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
18
27
  };
19
28
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.TypeScript = exports.SerializeEvent = 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;
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;
21
30
  var application_1 = require("./lib/application");
22
31
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
23
32
  var events_1 = require("./lib/utils/events");
@@ -59,6 +68,7 @@ Object.defineProperty(exports, "MinimalSourceFile", { enumerable: true, get: fun
59
68
  var serialization_1 = require("./lib/serialization");
60
69
  Object.defineProperty(exports, "JSONOutput", { enumerable: true, get: function () { return serialization_1.JSONOutput; } });
61
70
  Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serialization_1.Serializer; } });
71
+ Object.defineProperty(exports, "Deserializer", { enumerable: true, get: function () { return serialization_1.Deserializer; } });
62
72
  Object.defineProperty(exports, "SerializeEvent", { enumerable: true, get: function () { return serialization_1.SerializeEvent; } });
63
- const typescript_1 = __importDefault(require("typescript"));
64
- exports.TypeScript = typescript_1.default;
73
+ const TypeScript = __importStar(require("typescript"));
74
+ exports.TypeScript = TypeScript;
@@ -1,3 +1,4 @@
1
1
  export declare const ApplicationEvents: {
2
2
  BOOTSTRAP_END: string;
3
+ REVIVE: string;
3
4
  };
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApplicationEvents = void 0;
4
4
  exports.ApplicationEvents = {
5
5
  BOOTSTRAP_END: "bootstrapEnd",
6
+ REVIVE: "reviveProject",
6
7
  };
@@ -1,12 +1,12 @@
1
1
  import { Converter } from "./converter/index";
2
2
  import { Renderer } from "./output/renderer";
3
- import { Serializer } from "./serialization";
3
+ import { Deserializer, Serializer } from "./serialization";
4
4
  import type { ProjectReflection } from "./models/index";
5
5
  import { Logger } from "./utils/index";
6
6
  import { AbstractComponent, ChildableComponent } from "./utils/component";
7
7
  import { Options } from "./utils";
8
8
  import type { TypeDocOptions } from "./utils/options/declaration";
9
- import { DocumentationEntryPoint } from "./utils/entry-point";
9
+ import { DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-point";
10
10
  /**
11
11
  * The default TypeDoc main application class.
12
12
  *
@@ -33,35 +33,49 @@ export declare class Application extends ChildableComponent<Application, Abstrac
33
33
  * The serializer used to generate JSON output.
34
34
  */
35
35
  serializer: Serializer;
36
+ /**
37
+ * The deserializer used to restore previously serialized JSON output.
38
+ */
39
+ deserializer: Deserializer;
36
40
  /**
37
41
  * The logger that should be used to output messages.
38
42
  */
39
43
  logger: Logger;
40
44
  options: Options;
41
45
  /** @internal */
42
- readonly loggerType: string | Function;
43
- /** @internal */
44
46
  readonly skipErrorChecking: boolean;
47
+ /** @internal */
48
+ readonly entryPointStrategy: EntryPointStrategy;
49
+ /** @internal */
50
+ readonly entryPoints: string[];
45
51
  /**
46
52
  * The version number of TypeDoc.
47
53
  */
48
54
  static VERSION: string;
49
55
  /**
50
56
  * Emitted after plugins have been loaded and options have been read, but before they have been frozen.
51
- * The listener will be given an instance of {@link Application} and the {@link TypeDocOptions | Partial<TypeDocOptions>}
52
- * passed to `bootstrap`.
57
+ * The listener will be given an instance of {@link Application}.
53
58
  */
54
59
  static readonly EVENT_BOOTSTRAP_END: string;
60
+ /**
61
+ * Emitted after a project has been deserialized from JSON.
62
+ */
63
+ static readonly EVENT_PROJECT_REVIVE: string;
55
64
  /**
56
65
  * Create a new TypeDoc application instance.
66
+ *
67
+ * @param options An object containing the options that should be used.
57
68
  */
58
69
  constructor();
59
70
  /**
60
- * Initialize TypeDoc with the given options object.
61
- *
62
- * @param options The desired options to set.
71
+ * Initialize TypeDoc, loading plugins if applicable.
72
+ */
73
+ bootstrapWithPlugins(options?: Partial<TypeDocOptions>): Promise<void>;
74
+ /**
75
+ * Initialize TypeDoc without loading plugins.
63
76
  */
64
77
  bootstrap(options?: Partial<TypeDocOptions>): void;
78
+ private setOptions;
65
79
  /**
66
80
  * Return the path to the TypeScript compiler.
67
81
  */
@@ -85,7 +99,7 @@ export declare class Application extends ChildableComponent<Application, Abstrac
85
99
  */
86
100
  generateDocs(project: ProjectReflection, out: string): Promise<void>;
87
101
  /**
88
- * Run the converter for the given set of files and write the reflections to a json file.
102
+ * Write the reflections to a json file.
89
103
  *
90
104
  * @param out The path and file name of the target file.
91
105
  * @returns Whether the JSON file could be written successfully.
@@ -95,4 +109,6 @@ export declare class Application extends ChildableComponent<Application, Abstrac
95
109
  * Print the version number.
96
110
  */
97
111
  toString(): string;
112
+ private _convertPackages;
113
+ private _merge;
98
114
  }
@@ -28,14 +28,11 @@ 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
- };
34
31
  var Application_1;
35
32
  Object.defineProperty(exports, "__esModule", { value: true });
36
33
  exports.Application = void 0;
37
34
  const Path = __importStar(require("path"));
38
- const typescript_1 = __importDefault(require("typescript"));
35
+ const ts = __importStar(require("typescript"));
39
36
  const index_1 = require("./converter/index");
40
37
  const renderer_1 = require("./output/renderer");
41
38
  const serialization_1 = require("./serialization");
@@ -51,6 +48,9 @@ const exports_1 = require("./validation/exports");
51
48
  const documentation_1 = require("./validation/documentation");
52
49
  const links_1 = require("./validation/links");
53
50
  const application_events_1 = require("./application-events");
51
+ const tsconfig_1 = require("./utils/tsconfig");
52
+ const fs_1 = require("./utils/fs");
53
+ const abstract_1 = require("./models/reflections/abstract");
54
54
  // eslint-disable-next-line @typescript-eslint/no-var-requires
55
55
  const packageInfo = require("../../package.json");
56
56
  const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
@@ -72,58 +72,61 @@ const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
72
72
  let Application = Application_1 = class Application extends component_1.ChildableComponent {
73
73
  /**
74
74
  * Create a new TypeDoc application instance.
75
+ *
76
+ * @param options An object containing the options that should be used.
75
77
  */
76
78
  constructor() {
77
79
  super(null); // We own ourselves
80
+ /**
81
+ * The serializer used to generate JSON output.
82
+ */
83
+ this.serializer = new serialization_1.Serializer();
84
+ /**
85
+ * The deserializer used to restore previously serialized JSON output.
86
+ */
87
+ this.deserializer = new serialization_1.Deserializer(this);
78
88
  this.logger = new index_2.ConsoleLogger();
79
89
  this.options = new utils_1.Options(this.logger);
80
- this.options.addDefaultDeclarations();
81
- this.serializer = new serialization_1.Serializer();
82
90
  this.converter = this.addComponent("converter", index_1.Converter);
83
91
  this.renderer = this.addComponent("renderer", renderer_1.Renderer);
84
92
  }
85
93
  /**
86
- * Initialize TypeDoc with the given options object.
87
- *
88
- * @param options The desired options to set.
94
+ * Initialize TypeDoc, loading plugins if applicable.
89
95
  */
90
- bootstrap(options = {}) {
91
- for (const [key, val] of Object.entries(options)) {
92
- try {
93
- this.options.setValue(key, val);
94
- }
95
- catch {
96
- // Ignore errors, plugins haven't been loaded yet and may declare an option.
97
- }
98
- }
96
+ async bootstrapWithPlugins(options = {}) {
97
+ this.options.reset();
98
+ this.setOptions(options, /* reportErrors */ false);
99
99
  this.options.read(new index_2.Logger());
100
- const logger = this.loggerType;
101
- if (typeof logger === "function") {
102
- this.logger = new index_2.CallbackLogger(logger);
103
- this.options.setLogger(this.logger);
104
- }
105
- else if (logger === "none") {
106
- this.logger = new index_2.Logger();
107
- this.options.setLogger(this.logger);
108
- }
109
100
  this.logger.level = this.options.getValue("logLevel");
110
- const plugins = (0, index_2.discoverPlugins)(this);
111
- (0, index_2.loadPlugins)(this, plugins);
101
+ await (0, index_2.loadPlugins)(this, this.options.getValue("plugin"));
102
+ this.bootstrap(options);
103
+ }
104
+ /**
105
+ * Initialize TypeDoc without loading plugins.
106
+ */
107
+ bootstrap(options = {}) {
112
108
  this.options.reset();
109
+ this.setOptions(options, /* reportErrors */ false);
110
+ this.options.read(this.logger);
111
+ this.setOptions(options);
112
+ this.logger.level = this.options.getValue("logLevel");
113
+ if ((0, general_1.hasBeenLoadedMultipleTimes)()) {
114
+ this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${(0, general_1.getLoadedPaths)().join("\n\t")}`);
115
+ }
116
+ this.trigger(application_events_1.ApplicationEvents.BOOTSTRAP_END, this);
117
+ }
118
+ setOptions(options, reportErrors = true) {
113
119
  for (const [key, val] of Object.entries(options)) {
114
120
  try {
115
121
  this.options.setValue(key, val);
116
122
  }
117
123
  catch (error) {
118
124
  (0, assert_1.ok)(error instanceof Error);
119
- this.logger.error(error.message);
125
+ if (reportErrors) {
126
+ this.logger.error(error.message);
127
+ }
120
128
  }
121
129
  }
122
- this.options.read(this.logger);
123
- if ((0, general_1.hasBeenLoadedMultipleTimes)()) {
124
- this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${(0, general_1.getLoadedPaths)().join("\n\t")}`);
125
- }
126
- this.trigger(application_events_1.ApplicationEvents.BOOTSTRAP_END, this, options);
127
130
  }
128
131
  /**
129
132
  * Return the path to the TypeScript compiler.
@@ -132,7 +135,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
132
135
  return (0, paths_1.nicePath)(Path.dirname(require.resolve("typescript")));
133
136
  }
134
137
  getTypeScriptVersion() {
135
- return typescript_1.default.version;
138
+ return ts.version;
136
139
  }
137
140
  /**
138
141
  * Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
@@ -148,11 +151,17 @@ let Application = Application_1 = class Application extends component_1.Childabl
148
151
  */
149
152
  convert() {
150
153
  const start = Date.now();
151
- // We seal here rather than in the Converter class since TypeDoc's tests reuse the Application
154
+ // We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
152
155
  // with a few different settings.
153
156
  this.options.freeze();
154
157
  this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
155
- if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
158
+ if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Merge) {
159
+ return this._merge();
160
+ }
161
+ if (this.entryPointStrategy === entry_point_1.EntryPointStrategy.Packages) {
162
+ return this._convertPackages();
163
+ }
164
+ if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
156
165
  this.logger.warn(`You are running with an unsupported TypeScript version! If TypeDoc crashes, this is why. TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
157
166
  }
158
167
  const entryPoints = this.getEntryPoints();
@@ -163,7 +172,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
163
172
  const programs = (0, array_1.unique)(entryPoints.map((e) => e.program));
164
173
  this.logger.verbose(`Converting with ${programs.length} programs ${entryPoints.length} entry points`);
165
174
  if (this.skipErrorChecking === false) {
166
- const errors = programs.flatMap((program) => typescript_1.default.getPreEmitDiagnostics(program));
175
+ const errors = programs.flatMap((program) => ts.getPreEmitDiagnostics(program));
167
176
  if (errors.length) {
168
177
  this.logger.diagnostics(errors);
169
178
  return;
@@ -184,10 +193,10 @@ let Application = Application_1 = class Application extends component_1.Childabl
184
193
  this.options.freeze();
185
194
  if (!this.options.getValue("preserveWatchOutput") &&
186
195
  this.logger instanceof index_2.ConsoleLogger) {
187
- typescript_1.default.sys.clearScreen?.();
196
+ ts.sys.clearScreen?.();
188
197
  }
189
198
  this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
190
- if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
199
+ if (!supportedVersionMajorMinor.some((version) => version == ts.versionMajorMinor)) {
191
200
  this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
192
201
  }
193
202
  if (Object.keys(this.options.getCompilerOptions()).length === 0) {
@@ -200,25 +209,25 @@ let Application = Application_1 = class Application extends component_1.Childabl
200
209
  return;
201
210
  }
202
211
  // Support for packages mode is currently unimplemented
203
- if (this.options.getValue("entryPointStrategy") ===
204
- entry_point_1.EntryPointStrategy.Packages) {
205
- this.logger.error("The packages option of entryPointStrategy is not supported in watch mode.");
212
+ if (this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Resolve &&
213
+ this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Expand) {
214
+ this.logger.error("entryPointStrategy must be set to either resolve or expand for watch mode.");
206
215
  return;
207
216
  }
208
- const tsconfigFile = index_2.TSConfigReader.findConfigFile(this.options.getValue("tsconfig")) ??
217
+ const tsconfigFile = (0, tsconfig_1.findTsConfigFile)(this.options.getValue("tsconfig")) ??
209
218
  "tsconfig.json";
210
219
  // We don't want to do it the first time to preserve initial debug status messages. They'll be lost
211
220
  // after the user saves a file, but better than nothing...
212
221
  let firstStatusReport = true;
213
- const host = typescript_1.default.createWatchCompilerHost(tsconfigFile, {}, typescript_1.default.sys, typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
222
+ const host = ts.createWatchCompilerHost(tsconfigFile, {}, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, (diagnostic) => this.logger.diagnostic(diagnostic), (status, newLine, _options, errorCount) => {
214
223
  if (!firstStatusReport &&
215
224
  errorCount === void 0 &&
216
225
  !this.options.getValue("preserveWatchOutput") &&
217
226
  this.logger instanceof index_2.ConsoleLogger) {
218
- typescript_1.default.sys.clearScreen?.();
227
+ ts.sys.clearScreen?.();
219
228
  }
220
229
  firstStatusReport = false;
221
- this.logger.info(typescript_1.default.flattenDiagnosticMessageText(status.messageText, newLine));
230
+ this.logger.info(ts.flattenDiagnosticMessageText(status.messageText, newLine));
222
231
  });
223
232
  let successFinished = true;
224
233
  let currentProgram;
@@ -255,18 +264,21 @@ let Application = Application_1 = class Application extends component_1.Childabl
255
264
  };
256
265
  const origAfterProgramCreate = host.afterProgramCreate;
257
266
  host.afterProgramCreate = (program) => {
258
- if (typescript_1.default.getPreEmitDiagnostics(program.getProgram()).length === 0) {
267
+ if (ts.getPreEmitDiagnostics(program.getProgram()).length === 0) {
259
268
  currentProgram = program.getProgram();
260
269
  runSuccess();
261
270
  }
262
271
  origAfterProgramCreate?.(program);
263
272
  };
264
- typescript_1.default.createWatchProgram(host);
273
+ ts.createWatchProgram(host);
265
274
  }
266
275
  validate(project) {
267
276
  const checks = this.options.getValue("validation");
268
277
  const start = Date.now();
269
- if (checks.notExported) {
278
+ // No point in validating exports when merging. Warnings will have already been emitted when
279
+ // creating the project jsons that this run merges together.
280
+ if (checks.notExported &&
281
+ this.entryPointStrategy !== entry_point_1.EntryPointStrategy.Merge) {
270
282
  (0, exports_1.validateExports)(project, this.logger, this.options.getValue("intentionallyNotExported"));
271
283
  }
272
284
  if (checks.notDocumented) {
@@ -293,7 +305,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
293
305
  }
294
306
  }
295
307
  /**
296
- * Run the converter for the given set of files and write the reflections to a json file.
308
+ * Write the reflections to a json file.
297
309
  *
298
310
  * @param out The path and file name of the target file.
299
311
  * @returns Whether the JSON file could be written successfully.
@@ -301,14 +313,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
301
313
  async generateJson(project, out) {
302
314
  const start = Date.now();
303
315
  out = Path.resolve(out);
304
- const eventData = {
305
- outputDirectory: Path.dirname(out),
306
- outputFile: Path.basename(out),
307
- };
308
- const ser = this.serializer.projectToObject(project, {
309
- begin: eventData,
310
- end: eventData,
311
- });
316
+ const ser = this.serializer.projectToObject(project, process.cwd());
312
317
  const space = this.options.getValue("pretty") ? "\t" : "";
313
318
  await (0, index_2.writeFile)(out, JSON.stringify(ser, null, space));
314
319
  this.logger.info(`JSON written to ${(0, paths_1.nicePath)(out)}`);
@@ -325,6 +330,68 @@ let Application = Application_1 = class Application extends component_1.Childabl
325
330
  "",
326
331
  ].join("\n");
327
332
  }
333
+ _convertPackages() {
334
+ const packageDirs = (0, entry_point_1.getPackageDirectories)(this.logger, this.options, this.options.getValue("entryPoints"));
335
+ if (packageDirs.length === 0) {
336
+ this.logger.error("Failed to find any packages, ensure you have provided at least one directory as an entry point containing package.json");
337
+ return;
338
+ }
339
+ const origOptions = this.options;
340
+ const projects = [];
341
+ // Generate a json file for each package
342
+ for (const dir of packageDirs) {
343
+ this.logger.info(`Converting project at ${(0, paths_1.nicePath)(dir)}`);
344
+ const opts = origOptions.copyForPackage();
345
+ // Invalid links should only be reported after everything has been merged.
346
+ opts.setValue("validation", { invalidLink: false });
347
+ opts.read(this.logger, dir);
348
+ if (opts.getValue("entryPointStrategy") ===
349
+ entry_point_1.EntryPointStrategy.Packages) {
350
+ this.logger.error(`Project at ${(0, paths_1.nicePath)(dir)} has entryPointStrategy set to packages, but nested packages are not supported.`);
351
+ continue;
352
+ }
353
+ this.options = opts;
354
+ const project = this.convert();
355
+ if (project) {
356
+ projects.push(this.serializer.projectToObject(project, process.cwd()));
357
+ }
358
+ (0, abstract_1.resetReflectionID)();
359
+ }
360
+ this.options = origOptions;
361
+ this.logger.info(`Merging converted projects`);
362
+ if (projects.length !== packageDirs.length) {
363
+ this.logger.error("Failed to convert one or more packages, result will not be merged together.");
364
+ return;
365
+ }
366
+ const result = this.deserializer.reviveProjects(this.options.getValue("name") || "Documentation", projects);
367
+ this.trigger(application_events_1.ApplicationEvents.REVIVE, result);
368
+ return result;
369
+ }
370
+ _merge() {
371
+ const start = Date.now();
372
+ const rootDir = (0, fs_1.getCommonDirectory)(this.entryPoints);
373
+ const entryPoints = this.entryPoints.flatMap((entry) => (0, fs_1.glob)(entry, rootDir));
374
+ this.logger.verbose(`Merging entry points:\n\t${entryPoints.map(paths_1.nicePath).join("\n\t")}`);
375
+ if (entryPoints.length < 1) {
376
+ this.logger.error("No entry points provided to merge.");
377
+ return;
378
+ }
379
+ const jsonProjects = entryPoints.map((path) => {
380
+ try {
381
+ return JSON.parse((0, fs_1.readFile)(path));
382
+ }
383
+ catch {
384
+ this.logger.error(`Failed to parse file at ${(0, paths_1.nicePath)(path)} as json.`);
385
+ return null;
386
+ }
387
+ });
388
+ if (this.logger.hasErrors())
389
+ return;
390
+ const result = this.deserializer.reviveProjects(this.options.getValue("name"), jsonProjects);
391
+ this.logger.verbose(`Reviving projects took ${Date.now() - start}ms`);
392
+ this.trigger(application_events_1.ApplicationEvents.REVIVE, result);
393
+ return result;
394
+ }
328
395
  };
329
396
  /**
330
397
  * The version number of TypeDoc.
@@ -332,16 +399,22 @@ let Application = Application_1 = class Application extends component_1.Childabl
332
399
  Application.VERSION = packageInfo.version;
333
400
  /**
334
401
  * Emitted after plugins have been loaded and options have been read, but before they have been frozen.
335
- * The listener will be given an instance of {@link Application} and the {@link TypeDocOptions | Partial<TypeDocOptions>}
336
- * passed to `bootstrap`.
402
+ * The listener will be given an instance of {@link Application}.
337
403
  */
338
404
  Application.EVENT_BOOTSTRAP_END = application_events_1.ApplicationEvents.BOOTSTRAP_END;
339
- __decorate([
340
- (0, utils_1.BindOption)("logger")
341
- ], Application.prototype, "loggerType", void 0);
405
+ /**
406
+ * Emitted after a project has been deserialized from JSON.
407
+ */
408
+ Application.EVENT_PROJECT_REVIVE = application_events_1.ApplicationEvents.REVIVE;
342
409
  __decorate([
343
410
  (0, utils_1.BindOption)("skipErrorChecking")
344
411
  ], Application.prototype, "skipErrorChecking", void 0);
412
+ __decorate([
413
+ (0, utils_1.BindOption)("entryPointStrategy")
414
+ ], Application.prototype, "entryPointStrategy", void 0);
415
+ __decorate([
416
+ (0, utils_1.BindOption)("entryPoints")
417
+ ], Application.prototype, "entryPoints", void 0);
345
418
  Application = Application_1 = __decorate([
346
419
  (0, component_1.Component)({ name: "application", internal: true })
347
420
  ], Application);
@@ -0,0 +1 @@
1
+ export {};