typedoc 0.23.23 → 0.23.25
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 +1 -1
- package/dist/index.js +5 -2
- package/dist/lib/application.d.ts +0 -2
- package/dist/lib/application.js +38 -14
- package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
- 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 +18 -15
- package/dist/lib/converter/comments/linkResolver.js +6 -3
- 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 +1 -1
- package/dist/lib/converter/converter.js +12 -9
- 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 +42 -33
- 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/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 +132 -128
- 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/reflections/declaration.d.ts +1 -1
- package/dist/lib/models/reflections/declaration.js +1 -1
- package/dist/lib/models/reflections/type-parameter.d.ts +1 -1
- package/dist/lib/models/types.d.ts +1 -1
- 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/serialization/index.js +24 -1
- package/dist/lib/utils/entry-point.d.ts +2 -2
- package/dist/lib/utils/entry-point.js +36 -10
- package/dist/lib/utils/fs.d.ts +1 -0
- package/dist/lib/utils/fs.js +96 -14
- 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 +3 -2
- 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/package-manifest.d.ts +1 -1
- package/dist/lib/utils/paths.d.ts +2 -2
- package/dist/lib/utils/plugins.js +25 -2
- package/dist/lib/utils/sort.d.ts +1 -1
- package/dist/lib/validation/exports.js +5 -2
- package/package.json +16 -16
- package/static/main.js +54 -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.convertExpression = exports.convertDefaultValue = void 0;
|
|
4
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
5
8
|
/**
|
|
6
9
|
* Return the default value of the given node.
|
|
7
10
|
*
|
|
@@ -20,32 +23,32 @@ function convertDefaultValue(node) {
|
|
|
20
23
|
exports.convertDefaultValue = convertDefaultValue;
|
|
21
24
|
function convertExpression(expression) {
|
|
22
25
|
switch (expression.kind) {
|
|
23
|
-
case
|
|
24
|
-
case
|
|
25
|
-
case
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
26
|
+
case typescript_1.default.SyntaxKind.StringLiteral:
|
|
27
|
+
case typescript_1.default.SyntaxKind.TrueKeyword:
|
|
28
|
+
case typescript_1.default.SyntaxKind.FalseKeyword:
|
|
29
|
+
case typescript_1.default.SyntaxKind.NullKeyword:
|
|
30
|
+
case typescript_1.default.SyntaxKind.NumericLiteral:
|
|
31
|
+
case typescript_1.default.SyntaxKind.PrefixUnaryExpression:
|
|
32
|
+
case typescript_1.default.SyntaxKind.Identifier:
|
|
30
33
|
return expression.getText();
|
|
31
34
|
}
|
|
32
|
-
if (
|
|
35
|
+
if (typescript_1.default.isArrayLiteralExpression(expression) &&
|
|
33
36
|
expression.elements.length === 0) {
|
|
34
37
|
return "[]";
|
|
35
38
|
}
|
|
36
|
-
if (
|
|
39
|
+
if (typescript_1.default.isObjectLiteralExpression(expression) &&
|
|
37
40
|
expression.properties.length === 0) {
|
|
38
41
|
return "{}";
|
|
39
42
|
}
|
|
40
43
|
// a.b.c.d
|
|
41
|
-
if (
|
|
44
|
+
if (typescript_1.default.isPropertyAccessExpression(expression)) {
|
|
42
45
|
const parts = [expression.name.getText()];
|
|
43
46
|
let iter = expression.expression;
|
|
44
|
-
while (
|
|
47
|
+
while (typescript_1.default.isPropertyAccessExpression(iter)) {
|
|
45
48
|
parts.unshift(iter.name.getText());
|
|
46
49
|
iter = iter.expression;
|
|
47
50
|
}
|
|
48
|
-
if (
|
|
51
|
+
if (typescript_1.default.isIdentifier(iter)) {
|
|
49
52
|
parts.unshift(iter.text);
|
|
50
53
|
return parts.join(".");
|
|
51
54
|
}
|
|
@@ -5,10 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
var Converter_1;
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.Converter = void 0;
|
|
11
|
-
const
|
|
14
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
12
15
|
const index_1 = require("../models/index");
|
|
13
16
|
const context_1 = require("./context");
|
|
14
17
|
const components_1 = require("./components");
|
|
@@ -356,15 +359,15 @@ function getSymbolForModuleLike(context, node) {
|
|
|
356
359
|
// "globals" file, but this is uncommon enough that I'm skipping it for now.
|
|
357
360
|
const sourceFile = node.getSourceFile();
|
|
358
361
|
const globalSymbols = context.checker
|
|
359
|
-
.getSymbolsInScope(node,
|
|
362
|
+
.getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
|
|
360
363
|
.filter((s) => s.getDeclarations()?.some((d) => d.getSourceFile() === sourceFile));
|
|
361
364
|
// Detect declaration files with declare module "foo" as their only export
|
|
362
365
|
// and lift that up one level as the source file symbol
|
|
363
366
|
if (globalSymbols.length === 1 &&
|
|
364
367
|
globalSymbols[0]
|
|
365
368
|
.getDeclarations()
|
|
366
|
-
?.every((declaration) =>
|
|
367
|
-
|
|
369
|
+
?.every((declaration) => typescript_1.default.isModuleDeclaration(declaration) &&
|
|
370
|
+
typescript_1.default.isStringLiteral(declaration.name))) {
|
|
368
371
|
return globalSymbols[0];
|
|
369
372
|
}
|
|
370
373
|
}
|
|
@@ -379,15 +382,15 @@ function getExports(context, node, symbol) {
|
|
|
379
382
|
// members of the export= class and as functions if a class is directly exported.
|
|
380
383
|
result = [exportEq].concat(context.checker
|
|
381
384
|
.getExportsOfModule(symbol)
|
|
382
|
-
.filter((s) => !(0, enum_1.hasAnyFlag)(s.flags,
|
|
385
|
+
.filter((s) => !(0, enum_1.hasAnyFlag)(s.flags, typescript_1.default.SymbolFlags.Prototype | typescript_1.default.SymbolFlags.Value)));
|
|
383
386
|
}
|
|
384
387
|
else if (symbol) {
|
|
385
388
|
result = context.checker
|
|
386
389
|
.getExportsOfModule(symbol)
|
|
387
|
-
.filter((s) => !(0, enum_1.hasAllFlags)(s.flags,
|
|
390
|
+
.filter((s) => !(0, enum_1.hasAllFlags)(s.flags, typescript_1.default.SymbolFlags.Prototype));
|
|
388
391
|
if (result.length === 0) {
|
|
389
|
-
const globalDecl = node.statements.find((s) =>
|
|
390
|
-
s.flags &
|
|
392
|
+
const globalDecl = node.statements.find((s) => typescript_1.default.isModuleDeclaration(s) &&
|
|
393
|
+
s.flags & typescript_1.default.NodeFlags.GlobalAugmentation);
|
|
391
394
|
if (globalDecl) {
|
|
392
395
|
const globalSymbol = context.getSymbolAtLocation(globalDecl);
|
|
393
396
|
if (globalSymbol) {
|
|
@@ -402,7 +405,7 @@ function getExports(context, node, symbol) {
|
|
|
402
405
|
// Global file with no inferred top level symbol, get all symbols declared in this file.
|
|
403
406
|
const sourceFile = node.getSourceFile();
|
|
404
407
|
result = context.checker
|
|
405
|
-
.getSymbolsInScope(node,
|
|
408
|
+
.getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
|
|
406
409
|
.filter((s) => s
|
|
407
410
|
.getDeclarations()
|
|
408
411
|
?.some((d) => d.getSourceFile() === sourceFile));
|
|
@@ -1,21 +1,24 @@
|
|
|
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.convertIndexSignature = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
6
9
|
const models_1 = require("../../models");
|
|
7
10
|
const converter_events_1 = require("../converter-events");
|
|
8
11
|
function convertIndexSignature(context, symbol) {
|
|
9
|
-
|
|
12
|
+
(0, assert_1.default)(context.scope instanceof models_1.DeclarationReflection);
|
|
10
13
|
const indexSymbol = symbol.members?.get("__index");
|
|
11
14
|
if (indexSymbol) {
|
|
12
15
|
// Right now TypeDoc models don't have a way to distinguish between string
|
|
13
16
|
// and number index signatures... { [x: string]: 1 | 2; [x: number]: 2 }
|
|
14
17
|
// will be misrepresented.
|
|
15
18
|
const indexDeclaration = indexSymbol.getDeclarations()?.[0];
|
|
16
|
-
|
|
19
|
+
(0, assert_1.default)(indexDeclaration && typescript_1.default.isIndexSignatureDeclaration(indexDeclaration));
|
|
17
20
|
const param = indexDeclaration.parameters[0];
|
|
18
|
-
|
|
21
|
+
(0, assert_1.default)(param && typescript_1.default.isParameter(param));
|
|
19
22
|
const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope);
|
|
20
23
|
index.parameters = [
|
|
21
24
|
new models_1.ParameterReflection(param.name.getText(), models_1.ReflectionKind.Parameter, index),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
import { ParameterReflection, ReflectionKind, SignatureReflection, TypeParameterReflection } from "../../models";
|
|
3
3
|
import type { Context } from "../context";
|
|
4
4
|
export declare function createSignature(context: Context, kind: ReflectionKind.CallSignature | ReflectionKind.ConstructorSignature | ReflectionKind.GetSignature | ReflectionKind.SetSignature, signature: ts.Signature, declaration?: ts.SignatureDeclaration | ts.JSDocSignature): void;
|
|
@@ -1,8 +1,11 @@
|
|
|
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.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createSignature = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
6
9
|
const models_1 = require("../../models");
|
|
7
10
|
const converter_events_1 = require("../converter-events");
|
|
8
11
|
const convert_expression_1 = require("../convert-expression");
|
|
@@ -10,17 +13,23 @@ const reflections_1 = require("../utils/reflections");
|
|
|
10
13
|
const comments_1 = require("../comments");
|
|
11
14
|
function createSignature(context, kind, signature, declaration) {
|
|
12
15
|
var _a;
|
|
13
|
-
|
|
16
|
+
(0, assert_1.default)(context.scope instanceof models_1.DeclarationReflection);
|
|
14
17
|
declaration || (declaration = signature.getDeclaration());
|
|
15
18
|
const sigRef = new models_1.SignatureReflection(kind == models_1.ReflectionKind.ConstructorSignature
|
|
16
19
|
? `new ${context.scope.parent.name}`
|
|
17
20
|
: context.scope.name, kind, context.scope);
|
|
18
|
-
// If we are creating signatures for a variable and
|
|
19
|
-
// then we should prefer that
|
|
21
|
+
// If we are creating signatures for a variable or property and it has a comment associated with it
|
|
22
|
+
// then we should prefer that comment over any comment on the signature. The comment plugin
|
|
20
23
|
// will copy the comment down if this signature doesn't have one, so don't set one.
|
|
24
|
+
let parentReflection = context.scope;
|
|
25
|
+
if (parentReflection.kindOf(models_1.ReflectionKind.TypeLiteral) &&
|
|
26
|
+
parentReflection.parent instanceof models_1.DeclarationReflection) {
|
|
27
|
+
parentReflection = parentReflection.parent;
|
|
28
|
+
}
|
|
21
29
|
if (declaration &&
|
|
22
|
-
(!
|
|
23
|
-
!(
|
|
30
|
+
(!parentReflection.comment ||
|
|
31
|
+
!(parentReflection.conversionFlags &
|
|
32
|
+
models_1.ConversionFlags.VariableOrPropertySource))) {
|
|
24
33
|
sigRef.comment = (0, comments_1.getSignatureComment)(declaration, context.converter.config, context.logger, context.converter.commentStyle);
|
|
25
34
|
}
|
|
26
35
|
sigRef.typeParameters = convertTypeParameters(context, sigRef, signature.typeParameters);
|
|
@@ -36,7 +45,7 @@ function createSignature(context, kind, signature, declaration) {
|
|
|
36
45
|
sigRef.type = new models_1.IntrinsicType("void");
|
|
37
46
|
}
|
|
38
47
|
else {
|
|
39
|
-
sigRef.type = context.converter.convertType(context.withScope(sigRef), (declaration?.kind ===
|
|
48
|
+
sigRef.type = context.converter.convertType(context.withScope(sigRef), (declaration?.kind === typescript_1.default.SyntaxKind.FunctionDeclaration &&
|
|
40
49
|
declaration.type) ||
|
|
41
50
|
signature.getReturnType());
|
|
42
51
|
}
|
|
@@ -60,11 +69,11 @@ exports.createSignature = createSignature;
|
|
|
60
69
|
function convertParameters(context, sigRef, parameters, parameterNodes) {
|
|
61
70
|
return parameters.map((param, i) => {
|
|
62
71
|
const declaration = param.valueDeclaration;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
(0, assert_1.default)(!declaration ||
|
|
73
|
+
typescript_1.default.isParameter(declaration) ||
|
|
74
|
+
typescript_1.default.isJSDocParameterTag(declaration));
|
|
66
75
|
const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name) ? "__namedParameters" : param.name, models_1.ReflectionKind.Parameter, sigRef);
|
|
67
|
-
if (declaration &&
|
|
76
|
+
if (declaration && typescript_1.default.isJSDocParameterTag(declaration)) {
|
|
68
77
|
paramRefl.comment = (0, comments_1.getJsDocComment)(declaration, context.converter.config, context.logger);
|
|
69
78
|
}
|
|
70
79
|
paramRefl.comment || (paramRefl.comment = (0, comments_1.getComment)(param, paramRefl.kind, context.converter.config, context.logger, context.converter.commentStyle));
|
|
@@ -80,9 +89,9 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
|
|
|
80
89
|
paramRefl.type = context.converter.convertType(context.withScope(paramRefl), type);
|
|
81
90
|
let isOptional = false;
|
|
82
91
|
if (declaration) {
|
|
83
|
-
isOptional =
|
|
92
|
+
isOptional = typescript_1.default.isParameter(declaration)
|
|
84
93
|
? !!declaration.questionToken ||
|
|
85
|
-
|
|
94
|
+
typescript_1.default
|
|
86
95
|
.getJSDocParameterTags(declaration)
|
|
87
96
|
.some((tag) => tag.isBracketed)
|
|
88
97
|
: declaration.isBracketed;
|
|
@@ -96,10 +105,10 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
|
|
|
96
105
|
// because the method body uses `arguments`... which is always a rest argument
|
|
97
106
|
let isRest = true;
|
|
98
107
|
if (declaration) {
|
|
99
|
-
isRest =
|
|
108
|
+
isRest = typescript_1.default.isParameter(declaration)
|
|
100
109
|
? !!declaration.dotDotDotToken
|
|
101
110
|
: !!declaration.typeExpression &&
|
|
102
|
-
|
|
111
|
+
typescript_1.default.isJSDocVariadicType(declaration.typeExpression.type);
|
|
103
112
|
}
|
|
104
113
|
paramRefl.setFlag(models_1.ReflectionFlag.Rest, isRest);
|
|
105
114
|
return paramRefl;
|
|
@@ -110,13 +119,13 @@ function convertParameterNodes(context, sigRef, parameters) {
|
|
|
110
119
|
const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name.getText())
|
|
111
120
|
? "__namedParameters"
|
|
112
121
|
: param.name.getText(), models_1.ReflectionKind.Parameter, sigRef);
|
|
113
|
-
if (
|
|
122
|
+
if (typescript_1.default.isJSDocParameterTag(param)) {
|
|
114
123
|
paramRefl.comment = (0, comments_1.getJsDocComment)(param, context.converter.config, context.logger);
|
|
115
124
|
}
|
|
116
125
|
context.registerReflection(paramRefl, context.getSymbolAtLocation(param));
|
|
117
126
|
context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
|
|
118
|
-
paramRefl.type = context.converter.convertType(context.withScope(paramRefl),
|
|
119
|
-
const isOptional =
|
|
127
|
+
paramRefl.type = context.converter.convertType(context.withScope(paramRefl), typescript_1.default.isParameter(param) ? param.type : param.typeExpression?.type);
|
|
128
|
+
const isOptional = typescript_1.default.isParameter(param)
|
|
120
129
|
? !!param.questionToken
|
|
121
130
|
: param.isBracketed;
|
|
122
131
|
if (isOptional) {
|
|
@@ -124,10 +133,10 @@ function convertParameterNodes(context, sigRef, parameters) {
|
|
|
124
133
|
}
|
|
125
134
|
paramRefl.defaultValue = (0, convert_expression_1.convertDefaultValue)(param);
|
|
126
135
|
paramRefl.setFlag(models_1.ReflectionFlag.Optional, isOptional);
|
|
127
|
-
paramRefl.setFlag(models_1.ReflectionFlag.Rest,
|
|
136
|
+
paramRefl.setFlag(models_1.ReflectionFlag.Rest, typescript_1.default.isParameter(param)
|
|
128
137
|
? !!param.dotDotDotToken
|
|
129
138
|
: !!param.typeExpression &&
|
|
130
|
-
|
|
139
|
+
typescript_1.default.isJSDocVariadicType(param.typeExpression.type));
|
|
131
140
|
return paramRefl;
|
|
132
141
|
});
|
|
133
142
|
}
|
|
@@ -144,7 +153,7 @@ function convertTypeParameters(context, parent, parameters) {
|
|
|
144
153
|
: void 0;
|
|
145
154
|
// There's no way to determine directly from a ts.TypeParameter what it's variance modifiers are
|
|
146
155
|
// so unfortunately we have to go back to the node for this...
|
|
147
|
-
const variance = getVariance(param.getSymbol()?.declarations?.find(
|
|
156
|
+
const variance = getVariance(param.getSymbol()?.declarations?.find(typescript_1.default.isTypeParameterDeclaration)
|
|
148
157
|
?.modifiers);
|
|
149
158
|
const paramRefl = new models_1.TypeParameterReflection(param.symbol.name, constraint, defaultType, parent, variance);
|
|
150
159
|
context.registerReflection(paramRefl, param.getSymbol());
|
|
@@ -165,7 +174,7 @@ function createTypeParamReflection(param, context) {
|
|
|
165
174
|
: void 0;
|
|
166
175
|
const paramRefl = new models_1.TypeParameterReflection(param.name.text, constraint, defaultType, context.scope, getVariance(param.modifiers));
|
|
167
176
|
context.registerReflection(paramRefl, param.symbol);
|
|
168
|
-
if (
|
|
177
|
+
if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
|
|
169
178
|
paramRefl.comment = (0, comments_1.getJsDocComment)(param.parent, context.converter.config, context.logger);
|
|
170
179
|
}
|
|
171
180
|
context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
|
|
@@ -173,8 +182,8 @@ function createTypeParamReflection(param, context) {
|
|
|
173
182
|
}
|
|
174
183
|
exports.createTypeParamReflection = createTypeParamReflection;
|
|
175
184
|
function getVariance(modifiers) {
|
|
176
|
-
const hasIn = modifiers?.some((mod) => mod.kind ===
|
|
177
|
-
const hasOut = modifiers?.some((mod) => mod.kind ===
|
|
185
|
+
const hasIn = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.InKeyword);
|
|
186
|
+
const hasOut = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.OutKeyword);
|
|
178
187
|
if (hasIn && hasOut) {
|
|
179
188
|
return models_1.VarianceModifier.inOut;
|
|
180
189
|
}
|
|
@@ -188,23 +197,23 @@ function getVariance(modifiers) {
|
|
|
188
197
|
function convertPredicate(predicate, context) {
|
|
189
198
|
let name;
|
|
190
199
|
switch (predicate.kind) {
|
|
191
|
-
case
|
|
192
|
-
case
|
|
200
|
+
case typescript_1.default.TypePredicateKind.This:
|
|
201
|
+
case typescript_1.default.TypePredicateKind.AssertsThis:
|
|
193
202
|
name = "this";
|
|
194
203
|
break;
|
|
195
|
-
case
|
|
196
|
-
case
|
|
204
|
+
case typescript_1.default.TypePredicateKind.Identifier:
|
|
205
|
+
case typescript_1.default.TypePredicateKind.AssertsIdentifier:
|
|
197
206
|
name = predicate.parameterName;
|
|
198
207
|
break;
|
|
199
208
|
}
|
|
200
209
|
let asserts;
|
|
201
210
|
switch (predicate.kind) {
|
|
202
|
-
case
|
|
203
|
-
case
|
|
211
|
+
case typescript_1.default.TypePredicateKind.This:
|
|
212
|
+
case typescript_1.default.TypePredicateKind.Identifier:
|
|
204
213
|
asserts = false;
|
|
205
214
|
break;
|
|
206
|
-
case
|
|
207
|
-
case
|
|
215
|
+
case typescript_1.default.TypePredicateKind.AssertsThis:
|
|
216
|
+
case typescript_1.default.TypePredicateKind.AssertsIdentifier:
|
|
208
217
|
asserts = true;
|
|
209
218
|
break;
|
|
210
219
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
import type { Context } from "./context";
|
|
3
3
|
export declare function convertJsDocAlias(context: Context, symbol: ts.Symbol, declaration: ts.JSDocTypedefTag | ts.JSDocEnumTag, exportSymbol?: ts.Symbol): void;
|
|
4
4
|
export declare function convertJsDocCallback(context: Context, symbol: ts.Symbol, declaration: ts.JSDocCallbackTag, exportSymbol?: ts.Symbol): void;
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
// Converter functions for JSDoc defined types
|
|
3
3
|
// @typedef
|
|
4
4
|
// @callback
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
9
|
exports.convertJsDocCallback = exports.convertJsDocAlias = void 0;
|
|
7
10
|
const assert_1 = require("assert");
|
|
8
|
-
const
|
|
11
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
9
12
|
const models_1 = require("../models");
|
|
10
13
|
const comments_1 = require("./comments");
|
|
11
14
|
const converter_events_1 = require("./converter-events");
|
|
12
15
|
const signature_1 = require("./factories/signature");
|
|
13
16
|
function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
|
|
14
17
|
if (declaration.typeExpression &&
|
|
15
|
-
|
|
18
|
+
typescript_1.default.isJSDocTypeLiteral(declaration.typeExpression)) {
|
|
16
19
|
convertJsDocInterface(context, declaration, symbol, exportSymbol);
|
|
17
20
|
return;
|
|
18
21
|
}
|
|
@@ -71,7 +74,7 @@ function convertJsDocSignature(context, node) {
|
|
|
71
74
|
}
|
|
72
75
|
function convertTemplateParameters(context, node) {
|
|
73
76
|
(0, assert_1.ok)(context.scope instanceof models_1.DeclarationReflection);
|
|
74
|
-
context.scope.typeParameters = convertTemplateParameterNodes(context, node.tags?.filter(
|
|
77
|
+
context.scope.typeParameters = convertTemplateParameterNodes(context, node.tags?.filter(typescript_1.default.isJSDocTemplateTag));
|
|
75
78
|
}
|
|
76
79
|
function convertTemplateParameterNodes(context, nodes) {
|
|
77
80
|
const params = (nodes ?? []).flatMap((tag) => tag.typeParameters);
|
|
@@ -79,31 +82,31 @@ function convertTemplateParameterNodes(context, nodes) {
|
|
|
79
82
|
}
|
|
80
83
|
function getTypedefReExportTarget(context, declaration) {
|
|
81
84
|
const typeExpression = declaration.typeExpression;
|
|
82
|
-
if (!
|
|
85
|
+
if (!typescript_1.default.isJSDocTypedefTag(declaration) ||
|
|
83
86
|
!typeExpression ||
|
|
84
|
-
|
|
85
|
-
!
|
|
87
|
+
typescript_1.default.isJSDocTypeLiteral(typeExpression) ||
|
|
88
|
+
!typescript_1.default.isImportTypeNode(typeExpression.type) ||
|
|
86
89
|
!typeExpression.type.qualifier ||
|
|
87
|
-
!
|
|
90
|
+
!typescript_1.default.isIdentifier(typeExpression.type.qualifier)) {
|
|
88
91
|
return;
|
|
89
92
|
}
|
|
90
93
|
const targetSymbol = context.expectSymbolAtLocation(typeExpression.type.qualifier);
|
|
91
94
|
const decl = targetSymbol.declarations?.[0];
|
|
92
95
|
if (!decl ||
|
|
93
|
-
!(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
!(typescript_1.default.isTypeAliasDeclaration(decl) ||
|
|
97
|
+
typescript_1.default.isInterfaceDeclaration(decl) ||
|
|
98
|
+
typescript_1.default.isJSDocTypedefTag(decl) ||
|
|
99
|
+
typescript_1.default.isJSDocCallbackTag(decl))) {
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
|
-
const targetParams =
|
|
100
|
-
const localParams =
|
|
102
|
+
const targetParams = typescript_1.default.getEffectiveTypeParameterDeclarations(decl);
|
|
103
|
+
const localParams = typescript_1.default.getEffectiveTypeParameterDeclarations(declaration);
|
|
101
104
|
const localArgs = typeExpression.type.typeArguments || [];
|
|
102
105
|
// If we have type parameters, ensure they are forwarding parameters with no transformations.
|
|
103
106
|
// This doesn't check constraints since they aren't checked in JSDoc types.
|
|
104
107
|
if (targetParams.length !== localParams.length ||
|
|
105
|
-
localArgs.some((arg, i) => !
|
|
106
|
-
!
|
|
108
|
+
localArgs.some((arg, i) => !typescript_1.default.isTypeReferenceNode(arg) ||
|
|
109
|
+
!typescript_1.default.isIdentifier(arg.typeName) ||
|
|
107
110
|
arg.typeArguments ||
|
|
108
111
|
localParams[i]?.name.text !== arg.typeName.text)) {
|
|
109
112
|
return;
|
|
@@ -61,6 +61,8 @@ export declare class CommentPlugin extends ConverterComponent {
|
|
|
61
61
|
excludePrivate: boolean;
|
|
62
62
|
excludeProtected: boolean;
|
|
63
63
|
excludeNotDocumented: boolean;
|
|
64
|
+
private _excludeKinds;
|
|
65
|
+
private get excludeNotDocumentedKinds();
|
|
64
66
|
/**
|
|
65
67
|
* Create a new CommentPlugin instance.
|
|
66
68
|
*/
|
|
@@ -89,6 +89,12 @@ const NEVER_RENDERED = [
|
|
|
89
89
|
*
|
|
90
90
|
*/
|
|
91
91
|
let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent {
|
|
92
|
+
get excludeNotDocumentedKinds() {
|
|
93
|
+
this._excludeKinds ?? (this._excludeKinds = this.application.options
|
|
94
|
+
.getValue("excludeNotDocumentedKinds")
|
|
95
|
+
.reduce((a, b) => a | models_1.ReflectionKind[b], 0));
|
|
96
|
+
return this._excludeKinds;
|
|
97
|
+
}
|
|
92
98
|
/**
|
|
93
99
|
* Create a new CommentPlugin instance.
|
|
94
100
|
*/
|
|
@@ -99,6 +105,9 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
|
|
|
99
105
|
[converter_1.Converter.EVENT_CREATE_TYPE_PARAMETER]: this.onCreateTypeParameter,
|
|
100
106
|
[converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
|
|
101
107
|
[converter_1.Converter.EVENT_RESOLVE]: this.onResolve,
|
|
108
|
+
[converter_1.Converter.EVENT_END]: () => {
|
|
109
|
+
this._excludeKinds = undefined;
|
|
110
|
+
},
|
|
102
111
|
});
|
|
103
112
|
}
|
|
104
113
|
/**
|
|
@@ -335,12 +344,22 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
|
|
|
335
344
|
return true;
|
|
336
345
|
}
|
|
337
346
|
if (!comment) {
|
|
347
|
+
// We haven't moved comments from the parent for signatures without a direct
|
|
348
|
+
// comment, so don't exclude those due to not being documented.
|
|
349
|
+
if (reflection.kindOf(models_1.ReflectionKind.CallSignature |
|
|
350
|
+
models_1.ReflectionKind.ConstructorSignature) &&
|
|
351
|
+
reflection.parent?.comment) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
338
354
|
if (this.excludeNotDocumented) {
|
|
339
355
|
// Don't let excludeNotDocumented remove parameters.
|
|
340
356
|
if (!(reflection instanceof models_1.DeclarationReflection) &&
|
|
341
357
|
!(reflection instanceof models_1.SignatureReflection)) {
|
|
342
358
|
return false;
|
|
343
359
|
}
|
|
360
|
+
if (!reflection.kindOf(this.excludeNotDocumentedKinds)) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
344
363
|
// excludeNotDocumented should hide a module only if it has no visible children
|
|
345
364
|
if (reflection.kindOf(models_1.ReflectionKind.SomeModule)) {
|
|
346
365
|
if (!reflection.children) {
|
|
@@ -348,10 +367,6 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
|
|
|
348
367
|
}
|
|
349
368
|
return reflection.children.every((child) => this.isHidden(child));
|
|
350
369
|
}
|
|
351
|
-
// enum members should all be included if the parent enum is documented
|
|
352
|
-
if (reflection.kind === models_1.ReflectionKind.EnumMember) {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
370
|
// signature containers should only be hidden if all their signatures are hidden
|
|
356
371
|
if (reflection.kindOf(models_1.ReflectionKind.SignatureContainer)) {
|
|
357
372
|
return reflection
|
|
@@ -5,9 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.ImplementsPlugin = void 0;
|
|
10
|
-
const
|
|
13
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
11
14
|
const index_1 = require("../../models/reflections/index");
|
|
12
15
|
const types_1 = require("../../models/types");
|
|
13
16
|
const array_1 = require("../../utils/array");
|
|
@@ -150,7 +153,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
150
153
|
}
|
|
151
154
|
const declaration = symbol
|
|
152
155
|
.getDeclarations()
|
|
153
|
-
?.find((n) =>
|
|
156
|
+
?.find((n) => typescript_1.default.isClassDeclaration(n) || typescript_1.default.isInterfaceDeclaration(n));
|
|
154
157
|
if (!declaration) {
|
|
155
158
|
return;
|
|
156
159
|
}
|
|
@@ -171,7 +174,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
171
174
|
return;
|
|
172
175
|
}
|
|
173
176
|
if (reflection.kind === index_1.ReflectionKind.Constructor) {
|
|
174
|
-
const ctor = info.declaration.members.find(
|
|
177
|
+
const ctor = info.declaration.members.find(typescript_1.default.isConstructorDeclaration);
|
|
175
178
|
constructorInheritance(context, reflection, info.declaration, ctor);
|
|
176
179
|
return;
|
|
177
180
|
}
|
|
@@ -188,7 +191,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
188
191
|
out: for (const clause of info.declaration.heritageClauses ?? []) {
|
|
189
192
|
// No point checking implemented types for static members, they won't exist.
|
|
190
193
|
if (reflection.flags.isStatic &&
|
|
191
|
-
clause.token ===
|
|
194
|
+
clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
|
|
192
195
|
continue;
|
|
193
196
|
}
|
|
194
197
|
for (const expr of clause.types) {
|
|
@@ -202,7 +205,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
202
205
|
createLink(context, reflection, clause, expr, parentProperty, isInherit);
|
|
203
206
|
// Can't always break because we need to also set `implementationOf` if we
|
|
204
207
|
// inherit from a base class and also implement an interface.
|
|
205
|
-
if (clause.token ===
|
|
208
|
+
if (clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
|
|
206
209
|
break out;
|
|
207
210
|
}
|
|
208
211
|
}
|
|
@@ -215,7 +218,7 @@ ImplementsPlugin = __decorate([
|
|
|
215
218
|
], ImplementsPlugin);
|
|
216
219
|
exports.ImplementsPlugin = ImplementsPlugin;
|
|
217
220
|
function constructorInheritance(context, reflection, childDecl, constructorDecl) {
|
|
218
|
-
const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token ===
|
|
221
|
+
const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token === typescript_1.default.SyntaxKind.ExtendsKeyword);
|
|
219
222
|
if (!extendsClause)
|
|
220
223
|
return;
|
|
221
224
|
const name = `${extendsClause.types[0].getText()}.constructor`;
|
|
@@ -247,7 +250,7 @@ function createLink(context, reflection, clause, expr, symbol, isOverwrite) {
|
|
|
247
250
|
function link(target) {
|
|
248
251
|
if (!target)
|
|
249
252
|
return;
|
|
250
|
-
if (clause.token ===
|
|
253
|
+
if (clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
|
|
251
254
|
target.implementationOf ?? (target.implementationOf = types_1.ReferenceType.createBrokenReference(name, project));
|
|
252
255
|
return;
|
|
253
256
|
}
|
|
@@ -1,14 +1,37 @@
|
|
|
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
|
+
};
|
|
8
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
32
|
exports.PackagePlugin = void 0;
|
|
10
|
-
const Path = require("path");
|
|
11
|
-
const FS = require("fs");
|
|
33
|
+
const Path = __importStar(require("path"));
|
|
34
|
+
const FS = __importStar(require("fs"));
|
|
12
35
|
const components_1 = require("../components");
|
|
13
36
|
const converter_1 = require("../converter");
|
|
14
37
|
const utils_1 = require("../../utils");
|