typedoc 0.23.24 → 0.23.26
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.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -2
- package/dist/lib/application-events.d.ts +1 -0
- package/dist/lib/application-events.js +1 -0
- package/dist/lib/application.d.ts +5 -2
- package/dist/lib/application.js +44 -14
- package/dist/lib/converter/comments/discovery.d.ts +1 -1
- package/dist/lib/converter/comments/discovery.js +77 -74
- package/dist/lib/converter/comments/index.d.ts +1 -1
- package/dist/lib/converter/comments/index.js +22 -19
- package/dist/lib/converter/comments/linkResolver.d.ts +7 -2
- package/dist/lib/converter/comments/linkResolver.js +28 -17
- package/dist/lib/converter/context.d.ts +2 -2
- package/dist/lib/converter/context.js +6 -3
- package/dist/lib/converter/convert-expression.d.ts +1 -1
- package/dist/lib/converter/convert-expression.js +16 -13
- package/dist/lib/converter/converter.d.ts +6 -4
- package/dist/lib/converter/converter.js +18 -14
- package/dist/lib/converter/factories/index-signature.d.ts +1 -1
- package/dist/lib/converter/factories/index-signature.js +8 -5
- package/dist/lib/converter/factories/signature.d.ts +1 -1
- package/dist/lib/converter/factories/signature.js +32 -29
- package/dist/lib/converter/index.d.ts +1 -0
- package/dist/lib/converter/jsdoc.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +18 -15
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +2 -0
- package/dist/lib/converter/plugins/CommentPlugin.js +19 -4
- package/dist/lib/converter/plugins/ImplementsPlugin.js +10 -7
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +10 -2
- package/dist/lib/converter/plugins/PackagePlugin.js +25 -2
- package/dist/lib/converter/plugins/SourcePlugin.js +7 -4
- package/dist/lib/converter/symbols.d.ts +1 -1
- package/dist/lib/converter/symbols.js +129 -126
- package/dist/lib/converter/types.d.ts +1 -1
- package/dist/lib/converter/types.js +101 -98
- package/dist/lib/converter/utils/base-path.js +24 -1
- package/dist/lib/converter/utils/nodes.d.ts +1 -1
- package/dist/lib/converter/utils/nodes.js +5 -2
- package/dist/lib/converter/utils/symbols.d.ts +1 -1
- package/dist/lib/converter/utils/symbols.js +5 -2
- package/dist/lib/models/comments/comment.d.ts +6 -0
- package/dist/lib/models/comments/comment.js +50 -0
- package/dist/lib/output/components.js +24 -1
- package/dist/lib/output/events.js +24 -1
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +24 -1
- package/dist/lib/output/renderer.js +25 -2
- package/dist/lib/output/themes/MarkedPlugin.js +26 -3
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +2 -2
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +2 -2
- package/dist/lib/output/themes/lib.d.ts +1 -3
- package/dist/lib/output/themes/lib.js +1 -41
- package/dist/lib/serialization/index.js +24 -1
- package/dist/lib/utils/entry-point.d.ts +1 -1
- package/dist/lib/utils/entry-point.js +35 -9
- package/dist/lib/utils/fs.js +33 -3
- package/dist/lib/utils/general.js +24 -1
- package/dist/lib/utils/highlighter.js +24 -1
- package/dist/lib/utils/index.js +14 -2
- package/dist/lib/utils/loggers.d.ts +1 -1
- package/dist/lib/utils/loggers.js +9 -6
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/readers/tsconfig.js +8 -5
- package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
- package/dist/lib/utils/options/readers/typedoc.js +39 -5
- package/dist/lib/utils/options/sources/typedoc.js +79 -11
- package/dist/lib/utils/plugins.js +25 -2
- package/dist/lib/validation/documentation.js +13 -1
- package/dist/lib/validation/exports.js +5 -2
- package/package.json +12 -12
- package/static/main.js +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
9
|
export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } from "./lib/utils";
|
|
@@ -11,5 +11,5 @@ export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions
|
|
|
11
11
|
export type { EventMap, EventCallback } from "./lib/utils/events";
|
|
12
12
|
export { JSONOutput, Serializer, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
|
|
13
13
|
export type { SerializeEventData } from "./lib/serialization";
|
|
14
|
-
import
|
|
14
|
+
import TypeScript from "typescript";
|
|
15
15
|
export { TypeScript };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
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;
|
|
18
21
|
var application_1 = require("./lib/application");
|
|
@@ -57,5 +60,5 @@ var serialization_1 = require("./lib/serialization");
|
|
|
57
60
|
Object.defineProperty(exports, "JSONOutput", { enumerable: true, get: function () { return serialization_1.JSONOutput; } });
|
|
58
61
|
Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serialization_1.Serializer; } });
|
|
59
62
|
Object.defineProperty(exports, "SerializeEvent", { enumerable: true, get: function () { return serialization_1.SerializeEvent; } });
|
|
60
|
-
const
|
|
61
|
-
exports.TypeScript =
|
|
63
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
64
|
+
exports.TypeScript = typescript_1.default;
|
|
@@ -52,10 +52,13 @@ export declare class Application extends ChildableComponent<Application, Abstrac
|
|
|
52
52
|
* passed to `bootstrap`.
|
|
53
53
|
*/
|
|
54
54
|
static readonly EVENT_BOOTSTRAP_END: string;
|
|
55
|
+
/**
|
|
56
|
+
* Emitted when validation is being run.
|
|
57
|
+
* The listener will be given an instance of {@link ProjectReflection}.
|
|
58
|
+
*/
|
|
59
|
+
static readonly EVENT_VALIDATE_PROJECT: string;
|
|
55
60
|
/**
|
|
56
61
|
* Create a new TypeDoc application instance.
|
|
57
|
-
*
|
|
58
|
-
* @param options An object containing the options that should be used.
|
|
59
62
|
*/
|
|
60
63
|
constructor();
|
|
61
64
|
/**
|
package/dist/lib/application.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
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
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
8
34
|
var Application_1;
|
|
9
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
36
|
exports.Application = void 0;
|
|
11
|
-
const Path = require("path");
|
|
12
|
-
const
|
|
37
|
+
const Path = __importStar(require("path"));
|
|
38
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
13
39
|
const index_1 = require("./converter/index");
|
|
14
40
|
const renderer_1 = require("./output/renderer");
|
|
15
41
|
const serialization_1 = require("./serialization");
|
|
@@ -46,8 +72,6 @@ const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
|
|
|
46
72
|
let Application = Application_1 = class Application extends component_1.ChildableComponent {
|
|
47
73
|
/**
|
|
48
74
|
* Create a new TypeDoc application instance.
|
|
49
|
-
*
|
|
50
|
-
* @param options An object containing the options that should be used.
|
|
51
75
|
*/
|
|
52
76
|
constructor() {
|
|
53
77
|
super(null); // We own ourselves
|
|
@@ -108,7 +132,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
108
132
|
return (0, paths_1.nicePath)(Path.dirname(require.resolve("typescript")));
|
|
109
133
|
}
|
|
110
134
|
getTypeScriptVersion() {
|
|
111
|
-
return
|
|
135
|
+
return typescript_1.default.version;
|
|
112
136
|
}
|
|
113
137
|
/**
|
|
114
138
|
* Gets the entry points to be documented according to the current `entryPoints` and `entryPointStrategy` options.
|
|
@@ -128,7 +152,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
128
152
|
// with a few different settings.
|
|
129
153
|
this.options.freeze();
|
|
130
154
|
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
131
|
-
if (!supportedVersionMajorMinor.some((version) => version ==
|
|
155
|
+
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
|
|
132
156
|
this.logger.warn(`You are running with an unsupported TypeScript version! If TypeDoc crashes, this is why. TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
|
|
133
157
|
}
|
|
134
158
|
const entryPoints = this.getEntryPoints();
|
|
@@ -139,7 +163,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
139
163
|
const programs = (0, array_1.unique)(entryPoints.map((e) => e.program));
|
|
140
164
|
this.logger.verbose(`Converting with ${programs.length} programs ${entryPoints.length} entry points`);
|
|
141
165
|
if (this.skipErrorChecking === false) {
|
|
142
|
-
const errors = programs.flatMap((program) =>
|
|
166
|
+
const errors = programs.flatMap((program) => typescript_1.default.getPreEmitDiagnostics(program));
|
|
143
167
|
if (errors.length) {
|
|
144
168
|
this.logger.diagnostics(errors);
|
|
145
169
|
return;
|
|
@@ -160,10 +184,10 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
160
184
|
this.options.freeze();
|
|
161
185
|
if (!this.options.getValue("preserveWatchOutput") &&
|
|
162
186
|
this.logger instanceof index_2.ConsoleLogger) {
|
|
163
|
-
|
|
187
|
+
typescript_1.default.sys.clearScreen?.();
|
|
164
188
|
}
|
|
165
189
|
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
166
|
-
if (!supportedVersionMajorMinor.some((version) => version ==
|
|
190
|
+
if (!supportedVersionMajorMinor.some((version) => version == typescript_1.default.versionMajorMinor)) {
|
|
167
191
|
this.logger.warn(`You are running with an unsupported TypeScript version! TypeDoc supports ${supportedVersionMajorMinor.join(", ")}`);
|
|
168
192
|
}
|
|
169
193
|
if (Object.keys(this.options.getCompilerOptions()).length === 0) {
|
|
@@ -186,15 +210,15 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
186
210
|
// We don't want to do it the first time to preserve initial debug status messages. They'll be lost
|
|
187
211
|
// after the user saves a file, but better than nothing...
|
|
188
212
|
let firstStatusReport = true;
|
|
189
|
-
const host =
|
|
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) => {
|
|
190
214
|
if (!firstStatusReport &&
|
|
191
215
|
errorCount === void 0 &&
|
|
192
216
|
!this.options.getValue("preserveWatchOutput") &&
|
|
193
217
|
this.logger instanceof index_2.ConsoleLogger) {
|
|
194
|
-
|
|
218
|
+
typescript_1.default.sys.clearScreen?.();
|
|
195
219
|
}
|
|
196
220
|
firstStatusReport = false;
|
|
197
|
-
this.logger.info(
|
|
221
|
+
this.logger.info(typescript_1.default.flattenDiagnosticMessageText(status.messageText, newLine));
|
|
198
222
|
});
|
|
199
223
|
let successFinished = true;
|
|
200
224
|
let currentProgram;
|
|
@@ -231,13 +255,13 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
231
255
|
};
|
|
232
256
|
const origAfterProgramCreate = host.afterProgramCreate;
|
|
233
257
|
host.afterProgramCreate = (program) => {
|
|
234
|
-
if (
|
|
258
|
+
if (typescript_1.default.getPreEmitDiagnostics(program.getProgram()).length === 0) {
|
|
235
259
|
currentProgram = program.getProgram();
|
|
236
260
|
runSuccess();
|
|
237
261
|
}
|
|
238
262
|
origAfterProgramCreate?.(program);
|
|
239
263
|
};
|
|
240
|
-
|
|
264
|
+
typescript_1.default.createWatchProgram(host);
|
|
241
265
|
}
|
|
242
266
|
validate(project) {
|
|
243
267
|
const checks = this.options.getValue("validation");
|
|
@@ -251,6 +275,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
251
275
|
if (checks.invalidLink) {
|
|
252
276
|
(0, links_1.validateLinks)(project, this.logger);
|
|
253
277
|
}
|
|
278
|
+
this.trigger(Application_1.EVENT_VALIDATE_PROJECT, project);
|
|
254
279
|
this.logger.verbose(`Validation took ${Date.now() - start}ms`);
|
|
255
280
|
}
|
|
256
281
|
/**
|
|
@@ -312,6 +337,11 @@ Application.VERSION = packageInfo.version;
|
|
|
312
337
|
* passed to `bootstrap`.
|
|
313
338
|
*/
|
|
314
339
|
Application.EVENT_BOOTSTRAP_END = application_events_1.ApplicationEvents.BOOTSTRAP_END;
|
|
340
|
+
/**
|
|
341
|
+
* Emitted when validation is being run.
|
|
342
|
+
* The listener will be given an instance of {@link ProjectReflection}.
|
|
343
|
+
*/
|
|
344
|
+
Application.EVENT_VALIDATE_PROJECT = application_events_1.ApplicationEvents.VALIDATE_PROJECT;
|
|
315
345
|
__decorate([
|
|
316
346
|
(0, utils_1.BindOption)("logger")
|
|
317
347
|
], Application.prototype, "loggerType", void 0);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.discoverSignatureComment = exports.discoverComment = void 0;
|
|
4
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
5
8
|
const models_1 = require("../../models");
|
|
6
9
|
const utils_1 = require("../../utils");
|
|
7
10
|
const declaration_1 = require("../../utils/options/declaration");
|
|
@@ -11,84 +14,84 @@ const paths_1 = require("../../utils/paths");
|
|
|
11
14
|
// the JSDoc converter because we only want part of the comment when
|
|
12
15
|
// getting them.
|
|
13
16
|
const wantedKinds = {
|
|
14
|
-
[models_1.ReflectionKind.Project]: [
|
|
15
|
-
[models_1.ReflectionKind.Module]: [
|
|
17
|
+
[models_1.ReflectionKind.Project]: [typescript_1.default.SyntaxKind.SourceFile],
|
|
18
|
+
[models_1.ReflectionKind.Module]: [typescript_1.default.SyntaxKind.SourceFile],
|
|
16
19
|
[models_1.ReflectionKind.Namespace]: [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,
|
|
22
25
|
],
|
|
23
26
|
[models_1.ReflectionKind.Enum]: [
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
typescript_1.default.SyntaxKind.EnumDeclaration,
|
|
28
|
+
typescript_1.default.SyntaxKind.VariableDeclaration,
|
|
26
29
|
],
|
|
27
30
|
[models_1.ReflectionKind.EnumMember]: [
|
|
28
|
-
|
|
31
|
+
typescript_1.default.SyntaxKind.EnumMember,
|
|
29
32
|
// These here so that @enum gets comments
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
typescript_1.default.SyntaxKind.PropertyAssignment,
|
|
34
|
+
typescript_1.default.SyntaxKind.PropertySignature,
|
|
32
35
|
],
|
|
33
36
|
[models_1.ReflectionKind.Variable]: [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
typescript_1.default.SyntaxKind.VariableDeclaration,
|
|
38
|
+
typescript_1.default.SyntaxKind.BindingElement,
|
|
39
|
+
typescript_1.default.SyntaxKind.ExportAssignment,
|
|
40
|
+
typescript_1.default.SyntaxKind.PropertyAccessExpression,
|
|
38
41
|
],
|
|
39
42
|
[models_1.ReflectionKind.Function]: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
45
48
|
],
|
|
46
49
|
[models_1.ReflectionKind.Class]: [
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
typescript_1.default.SyntaxKind.ClassDeclaration,
|
|
51
|
+
typescript_1.default.SyntaxKind.BindingElement,
|
|
49
52
|
],
|
|
50
|
-
[models_1.ReflectionKind.Interface]: [
|
|
51
|
-
[models_1.ReflectionKind.Constructor]: [
|
|
53
|
+
[models_1.ReflectionKind.Interface]: [typescript_1.default.SyntaxKind.InterfaceDeclaration],
|
|
54
|
+
[models_1.ReflectionKind.Constructor]: [typescript_1.default.SyntaxKind.Constructor],
|
|
52
55
|
[models_1.ReflectionKind.Property]: [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
typescript_1.default.SyntaxKind.PropertyDeclaration,
|
|
57
|
+
typescript_1.default.SyntaxKind.PropertySignature,
|
|
58
|
+
typescript_1.default.SyntaxKind.BinaryExpression,
|
|
59
|
+
typescript_1.default.SyntaxKind.PropertyAssignment,
|
|
57
60
|
// class X { constructor(/** Comment */ readonly z: string) }
|
|
58
|
-
|
|
61
|
+
typescript_1.default.SyntaxKind.Parameter,
|
|
59
62
|
],
|
|
60
63
|
[models_1.ReflectionKind.Method]: [
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
typescript_1.default.SyntaxKind.FunctionDeclaration,
|
|
65
|
+
typescript_1.default.SyntaxKind.MethodDeclaration,
|
|
63
66
|
],
|
|
64
67
|
[models_1.ReflectionKind.CallSignature]: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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,
|
|
72
75
|
],
|
|
73
|
-
[models_1.ReflectionKind.IndexSignature]: [
|
|
74
|
-
[models_1.ReflectionKind.ConstructorSignature]: [
|
|
75
|
-
[models_1.ReflectionKind.Parameter]: [
|
|
76
|
-
[models_1.ReflectionKind.TypeLiteral]: [
|
|
77
|
-
[models_1.ReflectionKind.TypeParameter]: [
|
|
78
|
-
[models_1.ReflectionKind.Accessor]: [
|
|
79
|
-
[models_1.ReflectionKind.GetSignature]: [
|
|
80
|
-
[models_1.ReflectionKind.SetSignature]: [
|
|
81
|
-
[models_1.ReflectionKind.ObjectLiteral]: [
|
|
82
|
-
[models_1.ReflectionKind.TypeAlias]: [
|
|
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],
|
|
83
86
|
[models_1.ReflectionKind.Reference]: [
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
typescript_1.default.SyntaxKind.NamespaceExport,
|
|
88
|
+
typescript_1.default.SyntaxKind.ExportSpecifier,
|
|
86
89
|
],
|
|
87
90
|
};
|
|
88
91
|
function discoverComment(symbol, kind, logger, commentStyle) {
|
|
89
92
|
// For a module comment, we want the first one defined in the file,
|
|
90
93
|
// not the last one, since that will apply to the import or declaration.
|
|
91
|
-
const reverse = !symbol.declarations?.some(
|
|
94
|
+
const reverse = !symbol.declarations?.some(typescript_1.default.isSourceFile);
|
|
92
95
|
const discovered = [];
|
|
93
96
|
for (const decl of symbol.declarations || []) {
|
|
94
97
|
const text = decl.getSourceFile().text;
|
|
@@ -104,14 +107,14 @@ function discoverComment(symbol, kind, logger, commentStyle) {
|
|
|
104
107
|
// See the gh1770 test for an example.
|
|
105
108
|
if (kind & models_1.ReflectionKind.ContainsCallSignatures &&
|
|
106
109
|
[
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
typescript_1.default.SyntaxKind.FunctionDeclaration,
|
|
111
|
+
typescript_1.default.SyntaxKind.MethodDeclaration,
|
|
112
|
+
typescript_1.default.SyntaxKind.Constructor,
|
|
110
113
|
].includes(node.kind) &&
|
|
111
114
|
!node.body) {
|
|
112
115
|
continue;
|
|
113
116
|
}
|
|
114
|
-
const comments = collectCommentRanges(
|
|
117
|
+
const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
|
|
115
118
|
if (reverse) {
|
|
116
119
|
comments.reverse();
|
|
117
120
|
}
|
|
@@ -130,7 +133,7 @@ function discoverComment(symbol, kind, logger, commentStyle) {
|
|
|
130
133
|
logger.warn(`${symbol.name} has multiple declarations with a comment. An arbitrary comment will be used.`);
|
|
131
134
|
const locations = discovered.map(([sf, [{ pos }]]) => {
|
|
132
135
|
const path = (0, paths_1.nicePath)(sf.fileName);
|
|
133
|
-
const line =
|
|
136
|
+
const line = typescript_1.default.getLineAndCharacterOfPosition(sf, pos).line + 1;
|
|
134
137
|
return `${path}:${line}`;
|
|
135
138
|
});
|
|
136
139
|
logger.info(`The comments for ${symbol.name} are declared at:\n\t${locations.join("\n\t")}`);
|
|
@@ -145,7 +148,7 @@ function discoverSignatureComment(declaration, commentStyle) {
|
|
|
145
148
|
return;
|
|
146
149
|
}
|
|
147
150
|
const text = node.getSourceFile().text;
|
|
148
|
-
const comments = collectCommentRanges(
|
|
151
|
+
const comments = collectCommentRanges(typescript_1.default.getLeadingCommentRanges(text, node.pos));
|
|
149
152
|
comments.reverse();
|
|
150
153
|
const comment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
|
|
151
154
|
if (comment) {
|
|
@@ -167,7 +170,7 @@ exports.discoverSignatureComment = discoverSignatureComment;
|
|
|
167
170
|
* @return TRUE if the given node is the topmost module declaration, FALSE otherwise.
|
|
168
171
|
*/
|
|
169
172
|
function isTopmostModuleDeclaration(node) {
|
|
170
|
-
return node.getChildren().some(
|
|
173
|
+
return node.getChildren().some(typescript_1.default.isModuleBlock);
|
|
171
174
|
}
|
|
172
175
|
/**
|
|
173
176
|
* Return the root module declaration of the given module declaration.
|
|
@@ -181,7 +184,7 @@ function isTopmostModuleDeclaration(node) {
|
|
|
181
184
|
*/
|
|
182
185
|
function getRootModuleDeclaration(node) {
|
|
183
186
|
while (node.parent &&
|
|
184
|
-
node.parent.kind ===
|
|
187
|
+
node.parent.kind === typescript_1.default.SyntaxKind.ModuleDeclaration) {
|
|
185
188
|
const parent = node.parent;
|
|
186
189
|
if (node.name.pos === parent.name.end + 1) {
|
|
187
190
|
node = parent;
|
|
@@ -197,12 +200,12 @@ function declarationToCommentNode(node) {
|
|
|
197
200
|
return node;
|
|
198
201
|
// const abc = 123
|
|
199
202
|
// ^^^
|
|
200
|
-
if (node.parent.kind ===
|
|
203
|
+
if (node.parent.kind === typescript_1.default.SyntaxKind.VariableDeclarationList) {
|
|
201
204
|
return node.parent.parent;
|
|
202
205
|
}
|
|
203
206
|
// const a = () => {}
|
|
204
207
|
// ^^^^^^^^
|
|
205
|
-
if (node.parent.kind ===
|
|
208
|
+
if (node.parent.kind === typescript_1.default.SyntaxKind.VariableDeclaration) {
|
|
206
209
|
return node.parent.parent.parent;
|
|
207
210
|
}
|
|
208
211
|
// class X { y = () => {} }
|
|
@@ -213,13 +216,13 @@ function declarationToCommentNode(node) {
|
|
|
213
216
|
// export default () => {}
|
|
214
217
|
// ^^^^^^^^
|
|
215
218
|
if ([
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
typescript_1.default.SyntaxKind.PropertyDeclaration,
|
|
220
|
+
typescript_1.default.SyntaxKind.BinaryExpression,
|
|
221
|
+
typescript_1.default.SyntaxKind.ExportAssignment,
|
|
219
222
|
].includes(node.parent.kind)) {
|
|
220
223
|
return node.parent;
|
|
221
224
|
}
|
|
222
|
-
if (
|
|
225
|
+
if (typescript_1.default.isModuleDeclaration(node)) {
|
|
223
226
|
if (!isTopmostModuleDeclaration(node)) {
|
|
224
227
|
return;
|
|
225
228
|
}
|
|
@@ -227,10 +230,10 @@ function declarationToCommentNode(node) {
|
|
|
227
230
|
return getRootModuleDeclaration(node);
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
|
-
if (node.kind ===
|
|
233
|
+
if (node.kind === typescript_1.default.SyntaxKind.ExportSpecifier) {
|
|
231
234
|
return node.parent.parent;
|
|
232
235
|
}
|
|
233
|
-
if ([
|
|
236
|
+
if ([typescript_1.default.SyntaxKind.NamespaceExport, typescript_1.default.SyntaxKind.FunctionType].includes(node.kind)) {
|
|
234
237
|
return node.parent;
|
|
235
238
|
}
|
|
236
239
|
return node;
|
|
@@ -245,14 +248,14 @@ function collectCommentRanges(ranges) {
|
|
|
245
248
|
for (const range of ranges || []) {
|
|
246
249
|
collect.push(range);
|
|
247
250
|
switch (range.kind) {
|
|
248
|
-
case
|
|
251
|
+
case typescript_1.default.SyntaxKind.MultiLineCommentTrivia:
|
|
249
252
|
if (collect.length) {
|
|
250
253
|
result.push(collect);
|
|
251
254
|
collect = [];
|
|
252
255
|
}
|
|
253
256
|
result.push([range]);
|
|
254
257
|
break;
|
|
255
|
-
case
|
|
258
|
+
case typescript_1.default.SyntaxKind.SingleLineCommentTrivia:
|
|
256
259
|
collect.push(range);
|
|
257
260
|
break;
|
|
258
261
|
/* istanbul ignore next */
|
|
@@ -270,11 +273,11 @@ function permittedRange(text, ranges, commentStyle) {
|
|
|
270
273
|
case declaration_1.CommentStyle.All:
|
|
271
274
|
return true;
|
|
272
275
|
case declaration_1.CommentStyle.Block:
|
|
273
|
-
return ranges[0].kind ===
|
|
276
|
+
return ranges[0].kind === typescript_1.default.SyntaxKind.MultiLineCommentTrivia;
|
|
274
277
|
case declaration_1.CommentStyle.Line:
|
|
275
|
-
return ranges[0].kind ===
|
|
278
|
+
return ranges[0].kind === typescript_1.default.SyntaxKind.SingleLineCommentTrivia;
|
|
276
279
|
case declaration_1.CommentStyle.JSDoc:
|
|
277
|
-
return (ranges[0].kind ===
|
|
280
|
+
return (ranges[0].kind === typescript_1.default.SyntaxKind.MultiLineCommentTrivia &&
|
|
278
281
|
text[ranges[0].pos] === "/" &&
|
|
279
282
|
text[ranges[0].pos + 1] === "*" &&
|
|
280
283
|
text[ranges[0].pos + 2] === "*");
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getJsDocComment = exports.getSignatureComment = exports.getComment = void 0;
|
|
4
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
5
8
|
const models_1 = require("../../models");
|
|
6
9
|
const utils_1 = require("../../utils");
|
|
7
10
|
const blockLexer_1 = require("./blockLexer");
|
|
@@ -9,11 +12,11 @@ const discovery_1 = require("./discovery");
|
|
|
9
12
|
const lineLexer_1 = require("./lineLexer");
|
|
10
13
|
const parser_1 = require("./parser");
|
|
11
14
|
const jsDocCommentKinds = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
typescript_1.default.SyntaxKind.JSDocPropertyTag,
|
|
16
|
+
typescript_1.default.SyntaxKind.JSDocCallbackTag,
|
|
17
|
+
typescript_1.default.SyntaxKind.JSDocTypedefTag,
|
|
18
|
+
typescript_1.default.SyntaxKind.JSDocTemplateTag,
|
|
19
|
+
typescript_1.default.SyntaxKind.JSDocEnumTag,
|
|
17
20
|
];
|
|
18
21
|
const commentCache = new WeakMap();
|
|
19
22
|
function getCommentWithCache(discovered, config, logger) {
|
|
@@ -26,10 +29,10 @@ function getCommentWithCache(discovered, config, logger) {
|
|
|
26
29
|
}
|
|
27
30
|
let comment;
|
|
28
31
|
switch (ranges[0].kind) {
|
|
29
|
-
case
|
|
32
|
+
case typescript_1.default.SyntaxKind.MultiLineCommentTrivia:
|
|
30
33
|
comment = (0, parser_1.parseComment)((0, blockLexer_1.lexBlockComment)(file.text, ranges[0].pos, ranges[0].end), config, file, logger);
|
|
31
34
|
break;
|
|
32
|
-
case
|
|
35
|
+
case typescript_1.default.SyntaxKind.SingleLineCommentTrivia:
|
|
33
36
|
comment = (0, parser_1.parseComment)((0, lineLexer_1.lexLineComments)(file.text, ranges), config, file, logger);
|
|
34
37
|
break;
|
|
35
38
|
default:
|
|
@@ -59,12 +62,12 @@ function getCommentImpl(commentSource, config, logger, moduleComment) {
|
|
|
59
62
|
return comment;
|
|
60
63
|
}
|
|
61
64
|
function getComment(symbol, kind, config, logger, commentStyle) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return getJsDocComment(
|
|
65
|
+
const declarations = symbol.declarations || [];
|
|
66
|
+
if (declarations.length &&
|
|
67
|
+
declarations.every((d) => jsDocCommentKinds.includes(d.kind))) {
|
|
68
|
+
return getJsDocComment(declarations[0], config, logger);
|
|
66
69
|
}
|
|
67
|
-
const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger,
|
|
70
|
+
const comment = getCommentImpl((0, discovery_1.discoverComment)(symbol, kind, logger, commentStyle), config, logger, declarations.some(typescript_1.default.isSourceFile));
|
|
68
71
|
if (!comment && kind === models_1.ReflectionKind.Property) {
|
|
69
72
|
return getConstructorParamPropertyComment(symbol, config, logger, commentStyle);
|
|
70
73
|
}
|
|
@@ -72,7 +75,7 @@ function getComment(symbol, kind, config, logger, commentStyle) {
|
|
|
72
75
|
}
|
|
73
76
|
exports.getComment = getComment;
|
|
74
77
|
function getConstructorParamPropertyComment(symbol, config, logger, commentStyle) {
|
|
75
|
-
const decl = symbol.declarations?.find(
|
|
78
|
+
const decl = symbol.declarations?.find(typescript_1.default.isParameter);
|
|
76
79
|
if (!decl)
|
|
77
80
|
return;
|
|
78
81
|
const ctor = decl.parent;
|
|
@@ -90,7 +93,7 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
90
93
|
const file = declaration.getSourceFile();
|
|
91
94
|
// First, get the whole comment. We know we'll need all of it.
|
|
92
95
|
let parent = declaration.parent;
|
|
93
|
-
while (!
|
|
96
|
+
while (!typescript_1.default.isJSDoc(parent)) {
|
|
94
97
|
parent = parent.parent;
|
|
95
98
|
}
|
|
96
99
|
// Then parse it.
|
|
@@ -98,17 +101,17 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
98
101
|
file,
|
|
99
102
|
[
|
|
100
103
|
{
|
|
101
|
-
kind:
|
|
104
|
+
kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
|
|
102
105
|
pos: parent.pos,
|
|
103
106
|
end: parent.end,
|
|
104
107
|
},
|
|
105
108
|
],
|
|
106
109
|
], config, logger);
|
|
107
110
|
// And pull out the tag we actually care about.
|
|
108
|
-
if (
|
|
111
|
+
if (typescript_1.default.isJSDocEnumTag(declaration)) {
|
|
109
112
|
return new models_1.Comment(comment.getTag("@enum")?.content);
|
|
110
113
|
}
|
|
111
|
-
if (
|
|
114
|
+
if (typescript_1.default.isJSDocTemplateTag(declaration) &&
|
|
112
115
|
declaration.comment &&
|
|
113
116
|
declaration.typeParameters.length > 1) {
|
|
114
117
|
// We could just put the same comment on everything, but due to how comment parsing works,
|
|
@@ -118,7 +121,7 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
123
|
let name;
|
|
121
|
-
if (
|
|
124
|
+
if (typescript_1.default.isJSDocTemplateTag(declaration)) {
|
|
122
125
|
// This isn't really ideal.
|
|
123
126
|
name = declaration.typeParameters[0].name.text;
|
|
124
127
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Comment, CommentDisplayPart, Reflection } from "../../models";
|
|
2
2
|
import type { Logger, ValidationOptions } from "../../utils";
|
|
3
3
|
import { DeclarationReference } from "./declarationReference";
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export type ExternalResolveResult = {
|
|
5
|
+
target: string;
|
|
6
|
+
caption?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ExternalSymbolResolver = (ref: DeclarationReference, refl: Reflection, part: Readonly<CommentDisplayPart> | undefined) => ExternalResolveResult | string | undefined;
|
|
9
|
+
export declare function resolveLinks(comment: Comment, reflection: Reflection, validation: ValidationOptions, logger: Logger, externalResolver: ExternalSymbolResolver): void;
|
|
10
|
+
export declare function resolvePartLinks(reflection: Reflection, parts: readonly CommentDisplayPart[], warn: () => void, validation: ValidationOptions, logger: Logger, externalResolver: ExternalSymbolResolver): CommentDisplayPart[];
|