typedoc 0.24.0-beta.1 → 0.24.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -32
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -14
- package/dist/lib/application-events.d.ts +1 -0
- package/dist/lib/application-events.js +1 -0
- package/dist/lib/application.d.ts +6 -2
- package/dist/lib/application.js +21 -13
- package/dist/lib/cli.js +7 -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 +76 -96
- package/dist/lib/converter/comments/index.d.ts +1 -1
- package/dist/lib/converter/comments/index.js +21 -41
- package/dist/lib/converter/comments/linkResolver.d.ts +7 -2
- package/dist/lib/converter/comments/linkResolver.js +27 -39
- package/dist/lib/converter/context.d.ts +1 -1
- package/dist/lib/converter/context.js +5 -25
- package/dist/lib/converter/convert-expression.d.ts +1 -1
- package/dist/lib/converter/convert-expression.js +15 -35
- package/dist/lib/converter/converter.d.ts +6 -4
- package/dist/lib/converter/converter.js +17 -36
- package/dist/lib/converter/factories/index-signature.d.ts +1 -1
- package/dist/lib/converter/factories/index-signature.js +3 -26
- package/dist/lib/converter/factories/signature.d.ts +1 -1
- package/dist/lib/converter/factories/signature.js +36 -53
- package/dist/lib/converter/index.d.ts +1 -0
- package/dist/lib/converter/jsdoc.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +17 -37
- 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 +9 -29
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +10 -2
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -0
- package/dist/lib/converter/plugins/PackagePlugin.js +32 -37
- package/dist/lib/converter/plugins/SourcePlugin.js +6 -26
- package/dist/lib/converter/symbols.d.ts +1 -1
- package/dist/lib/converter/symbols.js +120 -142
- package/dist/lib/converter/types.d.ts +1 -1
- package/dist/lib/converter/types.js +89 -112
- package/dist/lib/converter/utils/nodes.d.ts +1 -1
- package/dist/lib/converter/utils/nodes.js +4 -24
- package/dist/lib/converter/utils/symbols.d.ts +1 -1
- package/dist/lib/converter/utils/symbols.js +4 -24
- package/dist/lib/models/comments/comment.d.ts +6 -0
- package/dist/lib/models/comments/comment.js +50 -0
- package/dist/lib/models/reflections/declaration.d.ts +2 -2
- 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/themes/default/DefaultThemeRenderContext.d.ts +1 -1
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +1 -2
- package/dist/lib/output/themes/default/layouts/default.js +5 -5
- package/dist/lib/output/themes/default/partials/header.js +1 -1
- package/dist/lib/output/themes/default/partials/navigation.js +2 -2
- package/dist/lib/output/themes/lib.d.ts +2 -4
- package/dist/lib/output/themes/lib.js +3 -45
- package/dist/lib/utils/entry-point.d.ts +2 -2
- package/dist/lib/utils/entry-point.js +11 -8
- package/dist/lib/utils/fs.d.ts +13 -0
- package/dist/lib/utils/fs.js +105 -14
- package/dist/lib/utils/index.d.ts +2 -2
- package/dist/lib/utils/index.js +4 -1
- package/dist/lib/utils/loggers.d.ts +1 -1
- package/dist/lib/utils/loggers.js +8 -28
- package/dist/lib/utils/options/declaration.d.ts +3 -2
- package/dist/lib/utils/options/index.d.ts +1 -1
- package/dist/lib/utils/options/index.js +2 -1
- package/dist/lib/utils/options/readers/index.d.ts +1 -0
- package/dist/lib/utils/options/readers/index.js +3 -1
- package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
- package/dist/lib/utils/options/readers/package-json.js +45 -0
- package/dist/lib/utils/options/readers/tsconfig.js +4 -24
- package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
- package/dist/lib/utils/options/readers/typedoc.js +15 -4
- package/dist/lib/utils/options/sources/typedoc.js +56 -10
- package/dist/lib/utils/sort.d.ts +1 -1
- package/dist/lib/validation/documentation.js +13 -1
- package/package.json +16 -16
- package/static/main.js +55 -1
- package/static/style.css +4 -7
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.getJsDocComment = exports.getSignatureComment = exports.getComment = void 0;
|
|
27
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
28
8
|
const models_1 = require("../../models");
|
|
29
9
|
const utils_1 = require("../../utils");
|
|
30
10
|
const blockLexer_1 = require("./blockLexer");
|
|
@@ -32,11 +12,11 @@ const discovery_1 = require("./discovery");
|
|
|
32
12
|
const lineLexer_1 = require("./lineLexer");
|
|
33
13
|
const parser_1 = require("./parser");
|
|
34
14
|
const jsDocCommentKinds = [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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,
|
|
40
20
|
];
|
|
41
21
|
const commentCache = new WeakMap();
|
|
42
22
|
function getCommentWithCache(discovered, config, logger) {
|
|
@@ -49,10 +29,10 @@ function getCommentWithCache(discovered, config, logger) {
|
|
|
49
29
|
}
|
|
50
30
|
let comment;
|
|
51
31
|
switch (ranges[0].kind) {
|
|
52
|
-
case
|
|
32
|
+
case typescript_1.default.SyntaxKind.MultiLineCommentTrivia:
|
|
53
33
|
comment = (0, parser_1.parseComment)((0, blockLexer_1.lexBlockComment)(file.text, ranges[0].pos, ranges[0].end), config, file, logger);
|
|
54
34
|
break;
|
|
55
|
-
case
|
|
35
|
+
case typescript_1.default.SyntaxKind.SingleLineCommentTrivia:
|
|
56
36
|
comment = (0, parser_1.parseComment)((0, lineLexer_1.lexLineComments)(file.text, ranges), config, file, logger);
|
|
57
37
|
break;
|
|
58
38
|
default:
|
|
@@ -82,12 +62,12 @@ function getCommentImpl(commentSource, config, logger, moduleComment) {
|
|
|
82
62
|
return comment;
|
|
83
63
|
}
|
|
84
64
|
function getComment(symbol, kind, config, logger, commentStyle) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
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);
|
|
89
69
|
}
|
|
90
|
-
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));
|
|
91
71
|
if (!comment && kind === models_1.ReflectionKind.Property) {
|
|
92
72
|
return getConstructorParamPropertyComment(symbol, config, logger, commentStyle);
|
|
93
73
|
}
|
|
@@ -95,7 +75,7 @@ function getComment(symbol, kind, config, logger, commentStyle) {
|
|
|
95
75
|
}
|
|
96
76
|
exports.getComment = getComment;
|
|
97
77
|
function getConstructorParamPropertyComment(symbol, config, logger, commentStyle) {
|
|
98
|
-
const decl = symbol.declarations?.find(
|
|
78
|
+
const decl = symbol.declarations?.find(typescript_1.default.isParameter);
|
|
99
79
|
if (!decl)
|
|
100
80
|
return;
|
|
101
81
|
const ctor = decl.parent;
|
|
@@ -113,7 +93,7 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
113
93
|
const file = declaration.getSourceFile();
|
|
114
94
|
// First, get the whole comment. We know we'll need all of it.
|
|
115
95
|
let parent = declaration.parent;
|
|
116
|
-
while (!
|
|
96
|
+
while (!typescript_1.default.isJSDoc(parent)) {
|
|
117
97
|
parent = parent.parent;
|
|
118
98
|
}
|
|
119
99
|
// Then parse it.
|
|
@@ -121,17 +101,17 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
121
101
|
file,
|
|
122
102
|
[
|
|
123
103
|
{
|
|
124
|
-
kind:
|
|
104
|
+
kind: typescript_1.default.SyntaxKind.MultiLineCommentTrivia,
|
|
125
105
|
pos: parent.pos,
|
|
126
106
|
end: parent.end,
|
|
127
107
|
},
|
|
128
108
|
],
|
|
129
109
|
], config, logger);
|
|
130
110
|
// And pull out the tag we actually care about.
|
|
131
|
-
if (
|
|
111
|
+
if (typescript_1.default.isJSDocEnumTag(declaration)) {
|
|
132
112
|
return new models_1.Comment(comment.getTag("@enum")?.content);
|
|
133
113
|
}
|
|
134
|
-
if (
|
|
114
|
+
if (typescript_1.default.isJSDocTemplateTag(declaration) &&
|
|
135
115
|
declaration.comment &&
|
|
136
116
|
declaration.typeParameters.length > 1) {
|
|
137
117
|
// We could just put the same comment on everything, but due to how comment parsing works,
|
|
@@ -141,7 +121,7 @@ function getJsDocComment(declaration, config, logger) {
|
|
|
141
121
|
return;
|
|
142
122
|
}
|
|
143
123
|
let name;
|
|
144
|
-
if (
|
|
124
|
+
if (typescript_1.default.isJSDocTemplateTag(declaration)) {
|
|
145
125
|
// This isn't really ideal.
|
|
146
126
|
name = declaration.typeParameters[0].name.text;
|
|
147
127
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Comment, CommentDisplayPart, Reflection } from "../../models";
|
|
2
2
|
import { DeclarationReference } from "./declarationReference";
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export type ExternalResolveResult = {
|
|
4
|
+
target: string;
|
|
5
|
+
caption?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ExternalSymbolResolver = (ref: DeclarationReference, refl: Reflection, part: Readonly<CommentDisplayPart> | undefined) => ExternalResolveResult | string | undefined;
|
|
8
|
+
export declare function resolveLinks(comment: Comment, reflection: Reflection, externalResolver: ExternalSymbolResolver): void;
|
|
9
|
+
export declare function resolvePartLinks(reflection: Reflection, parts: readonly CommentDisplayPart[], externalResolver: ExternalSymbolResolver): CommentDisplayPart[];
|
|
@@ -1,68 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.resolvePartLinks = exports.resolveLinks = void 0;
|
|
27
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
28
8
|
const models_1 = require("../../models");
|
|
29
9
|
const declarationReference_1 = require("./declarationReference");
|
|
30
10
|
const declarationReferenceResolver_1 = require("./declarationReferenceResolver");
|
|
31
11
|
const urlPrefix = /^(http|ftp)s?:\/\//;
|
|
32
|
-
function resolveLinks(comment, reflection,
|
|
33
|
-
comment.summary = resolvePartLinks(reflection, comment.summary,
|
|
12
|
+
function resolveLinks(comment, reflection, externalResolver) {
|
|
13
|
+
comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver);
|
|
34
14
|
for (const tag of comment.blockTags) {
|
|
35
|
-
tag.content = resolvePartLinks(reflection, tag.content,
|
|
15
|
+
tag.content = resolvePartLinks(reflection, tag.content, externalResolver);
|
|
36
16
|
}
|
|
37
17
|
if (reflection instanceof models_1.DeclarationReflection && reflection.readme) {
|
|
38
|
-
reflection.readme = resolvePartLinks(reflection, reflection.readme,
|
|
18
|
+
reflection.readme = resolvePartLinks(reflection, reflection.readme, externalResolver);
|
|
39
19
|
}
|
|
40
20
|
}
|
|
41
21
|
exports.resolveLinks = resolveLinks;
|
|
42
|
-
function resolvePartLinks(reflection, parts,
|
|
43
|
-
return parts.flatMap((part) => processPart(reflection, part,
|
|
22
|
+
function resolvePartLinks(reflection, parts, externalResolver) {
|
|
23
|
+
return parts.flatMap((part) => processPart(reflection, part, externalResolver));
|
|
44
24
|
}
|
|
45
25
|
exports.resolvePartLinks = resolvePartLinks;
|
|
46
|
-
function processPart(reflection, part,
|
|
26
|
+
function processPart(reflection, part, externalResolver) {
|
|
47
27
|
if (part.kind === "inline-tag") {
|
|
48
28
|
if (part.tag === "@link" ||
|
|
49
29
|
part.tag === "@linkcode" ||
|
|
50
30
|
part.tag === "@linkplain") {
|
|
51
|
-
return resolveLinkTag(reflection, part,
|
|
31
|
+
return resolveLinkTag(reflection, part, externalResolver);
|
|
52
32
|
}
|
|
53
33
|
}
|
|
54
34
|
return part;
|
|
55
35
|
}
|
|
56
|
-
function resolveLinkTag(reflection, part,
|
|
36
|
+
function resolveLinkTag(reflection, part, externalResolver) {
|
|
57
37
|
let pos = 0;
|
|
58
38
|
const end = part.text.length;
|
|
59
|
-
while (pos < end &&
|
|
39
|
+
while (pos < end && typescript_1.default.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
|
|
60
40
|
pos++;
|
|
61
41
|
}
|
|
62
42
|
// Try to parse one
|
|
63
43
|
const declRef = (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
|
|
64
44
|
let target;
|
|
65
|
-
let defaultDisplayText;
|
|
45
|
+
let defaultDisplayText = "";
|
|
66
46
|
if (declRef) {
|
|
67
47
|
// Got one, great! Try to resolve the link
|
|
68
48
|
target = (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
|
|
@@ -72,9 +52,16 @@ function resolveLinkTag(reflection, part, attemptExternalResolve) {
|
|
|
72
52
|
}
|
|
73
53
|
else {
|
|
74
54
|
// If we didn't find a link, it might be a @link tag to an external symbol, check that next.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
const externalResolveResult = externalResolver(declRef[0], reflection, part);
|
|
56
|
+
defaultDisplayText = part.text.substring(0, pos);
|
|
57
|
+
switch (typeof externalResolveResult) {
|
|
58
|
+
case "string":
|
|
59
|
+
target = externalResolveResult;
|
|
60
|
+
break;
|
|
61
|
+
case "object":
|
|
62
|
+
target = externalResolveResult.target;
|
|
63
|
+
defaultDisplayText =
|
|
64
|
+
externalResolveResult.caption || defaultDisplayText;
|
|
78
65
|
}
|
|
79
66
|
}
|
|
80
67
|
}
|
|
@@ -89,7 +76,7 @@ function resolveLinkTag(reflection, part, attemptExternalResolve) {
|
|
|
89
76
|
}
|
|
90
77
|
// Remaining text after an optional pipe is the link text, so advance
|
|
91
78
|
// until that's consumed.
|
|
92
|
-
while (pos < end &&
|
|
79
|
+
while (pos < end && typescript_1.default.isWhiteSpaceLike(part.text.charCodeAt(pos))) {
|
|
93
80
|
pos++;
|
|
94
81
|
}
|
|
95
82
|
if (pos < end && part.text[pos] === "|") {
|
|
@@ -99,6 +86,7 @@ function resolveLinkTag(reflection, part, attemptExternalResolve) {
|
|
|
99
86
|
return part;
|
|
100
87
|
}
|
|
101
88
|
part.target = target;
|
|
102
|
-
part.text =
|
|
89
|
+
part.text =
|
|
90
|
+
part.text.substring(pos).trim() || defaultDisplayText || part.text;
|
|
103
91
|
return part;
|
|
104
92
|
}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.Context = void 0;
|
|
27
7
|
const assert_1 = require("assert");
|
|
28
|
-
const
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
29
9
|
const index_1 = require("../models/index");
|
|
30
10
|
const nodes_1 = require("./utils/nodes");
|
|
31
11
|
const converter_events_1 = require("./converter-events");
|
|
@@ -120,8 +100,8 @@ class Context {
|
|
|
120
100
|
expectSymbolAtLocation(node) {
|
|
121
101
|
const symbol = this.getSymbolAtLocation(node);
|
|
122
102
|
if (!symbol) {
|
|
123
|
-
const { line } =
|
|
124
|
-
throw new Error(`Expected a symbol for node with kind ${
|
|
103
|
+
const { line } = typescript_1.default.getLineAndCharacterOfPosition(node.getSourceFile(), node.pos);
|
|
104
|
+
throw new Error(`Expected a symbol for node with kind ${typescript_1.default.SyntaxKind[node.kind]} at ${node.getSourceFile().fileName}:${line + 1}`);
|
|
125
105
|
}
|
|
126
106
|
return symbol;
|
|
127
107
|
}
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.convertExpression = exports.convertDefaultValue = void 0;
|
|
27
|
-
const
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
28
8
|
/**
|
|
29
9
|
* Return the default value of the given node.
|
|
30
10
|
*
|
|
@@ -43,32 +23,32 @@ function convertDefaultValue(node) {
|
|
|
43
23
|
exports.convertDefaultValue = convertDefaultValue;
|
|
44
24
|
function convertExpression(expression) {
|
|
45
25
|
switch (expression.kind) {
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
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:
|
|
53
33
|
return expression.getText();
|
|
54
34
|
}
|
|
55
|
-
if (
|
|
35
|
+
if (typescript_1.default.isArrayLiteralExpression(expression) &&
|
|
56
36
|
expression.elements.length === 0) {
|
|
57
37
|
return "[]";
|
|
58
38
|
}
|
|
59
|
-
if (
|
|
39
|
+
if (typescript_1.default.isObjectLiteralExpression(expression) &&
|
|
60
40
|
expression.properties.length === 0) {
|
|
61
41
|
return "{}";
|
|
62
42
|
}
|
|
63
43
|
// a.b.c.d
|
|
64
|
-
if (
|
|
44
|
+
if (typescript_1.default.isPropertyAccessExpression(expression)) {
|
|
65
45
|
const parts = [expression.name.getText()];
|
|
66
46
|
let iter = expression.expression;
|
|
67
|
-
while (
|
|
47
|
+
while (typescript_1.default.isPropertyAccessExpression(iter)) {
|
|
68
48
|
parts.unshift(iter.name.getText());
|
|
69
49
|
iter = iter.expression;
|
|
70
50
|
}
|
|
71
|
-
if (
|
|
51
|
+
if (typescript_1.default.isIdentifier(iter)) {
|
|
72
52
|
parts.unshift(iter.text);
|
|
73
53
|
return parts.join(".");
|
|
74
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
import type { Application } from "../application";
|
|
3
3
|
import { Comment, CommentDisplayPart, ProjectReflection, Reflection, SomeType } from "../models/index";
|
|
4
4
|
import { Context } from "./context";
|
|
@@ -8,6 +8,7 @@ import { MinimalSourceFile } from "../utils";
|
|
|
8
8
|
import type { DocumentationEntryPoint } from "../utils/entry-point";
|
|
9
9
|
import { CommentParserConfig } from "./comments";
|
|
10
10
|
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration";
|
|
11
|
+
import { ExternalSymbolResolver, ExternalResolveResult } from "./comments/linkResolver";
|
|
11
12
|
import type { DeclarationReference } from "./comments/declarationReference";
|
|
12
13
|
/**
|
|
13
14
|
* Compiles source files using TypeScript and converts compiler symbols to reflections.
|
|
@@ -128,12 +129,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
128
129
|
*
|
|
129
130
|
* Note: This will be used for both references to types declared in node_modules (in which case the
|
|
130
131
|
* reference passed will have the `moduleSource` set and the `symbolReference` will navigate via `.`)
|
|
131
|
-
* and user defined \{\@link\} tags which cannot be resolved.
|
|
132
|
+
* and user defined \{\@link\} tags which cannot be resolved. If the link being resolved is inferred
|
|
133
|
+
* from a type, then no `part` will be passed to the resolver function.
|
|
132
134
|
* @since 0.22.14
|
|
133
135
|
*/
|
|
134
|
-
addUnknownSymbolResolver(resolver:
|
|
136
|
+
addUnknownSymbolResolver(resolver: ExternalSymbolResolver): void;
|
|
135
137
|
/** @internal */
|
|
136
|
-
resolveExternalLink(ref: DeclarationReference): string | undefined;
|
|
138
|
+
resolveExternalLink(ref: DeclarationReference, refl: Reflection, part?: CommentDisplayPart): ExternalResolveResult | string | undefined;
|
|
137
139
|
resolveLinks(comment: Comment, owner: Reflection): void;
|
|
138
140
|
resolveLinks(parts: readonly CommentDisplayPart[], owner: Reflection): CommentDisplayPart[];
|
|
139
141
|
/**
|
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
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;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var
|
|
25
|
-
|
|
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;
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
10
|
};
|
|
31
11
|
var Converter_1;
|
|
32
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
13
|
exports.Converter = void 0;
|
|
34
|
-
const
|
|
14
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
35
15
|
const index_1 = require("../models/index");
|
|
36
16
|
const context_1 = require("./context");
|
|
37
17
|
const components_1 = require("./components");
|
|
@@ -126,26 +106,27 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
126
106
|
*
|
|
127
107
|
* Note: This will be used for both references to types declared in node_modules (in which case the
|
|
128
108
|
* reference passed will have the `moduleSource` set and the `symbolReference` will navigate via `.`)
|
|
129
|
-
* and user defined \{\@link\} tags which cannot be resolved.
|
|
109
|
+
* and user defined \{\@link\} tags which cannot be resolved. If the link being resolved is inferred
|
|
110
|
+
* from a type, then no `part` will be passed to the resolver function.
|
|
130
111
|
* @since 0.22.14
|
|
131
112
|
*/
|
|
132
113
|
addUnknownSymbolResolver(resolver) {
|
|
133
114
|
this._externalSymbolResolvers.push(resolver);
|
|
134
115
|
}
|
|
135
116
|
/** @internal */
|
|
136
|
-
resolveExternalLink(ref) {
|
|
117
|
+
resolveExternalLink(ref, refl, part) {
|
|
137
118
|
for (const resolver of this._externalSymbolResolvers) {
|
|
138
|
-
const resolved = resolver(ref);
|
|
119
|
+
const resolved = resolver(ref, refl, part);
|
|
139
120
|
if (resolved)
|
|
140
121
|
return resolved;
|
|
141
122
|
}
|
|
142
123
|
}
|
|
143
124
|
resolveLinks(comment, owner) {
|
|
144
125
|
if (comment instanceof index_1.Comment) {
|
|
145
|
-
(0, linkResolver_1.resolveLinks)(comment, owner, (ref) => this.resolveExternalLink(ref));
|
|
126
|
+
(0, linkResolver_1.resolveLinks)(comment, owner, (ref, part, refl) => this.resolveExternalLink(ref, part, refl));
|
|
146
127
|
}
|
|
147
128
|
else {
|
|
148
|
-
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref) => this.resolveExternalLink(ref));
|
|
129
|
+
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref, part, refl) => this.resolveExternalLink(ref, part, refl));
|
|
149
130
|
}
|
|
150
131
|
}
|
|
151
132
|
/**
|
|
@@ -371,15 +352,15 @@ function getSymbolForModuleLike(context, node) {
|
|
|
371
352
|
// "globals" file, but this is uncommon enough that I'm skipping it for now.
|
|
372
353
|
const sourceFile = node.getSourceFile();
|
|
373
354
|
const globalSymbols = context.checker
|
|
374
|
-
.getSymbolsInScope(node,
|
|
355
|
+
.getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
|
|
375
356
|
.filter((s) => s.getDeclarations()?.some((d) => d.getSourceFile() === sourceFile));
|
|
376
357
|
// Detect declaration files with declare module "foo" as their only export
|
|
377
358
|
// and lift that up one level as the source file symbol
|
|
378
359
|
if (globalSymbols.length === 1 &&
|
|
379
360
|
globalSymbols[0]
|
|
380
361
|
.getDeclarations()
|
|
381
|
-
?.every((declaration) =>
|
|
382
|
-
|
|
362
|
+
?.every((declaration) => typescript_1.default.isModuleDeclaration(declaration) &&
|
|
363
|
+
typescript_1.default.isStringLiteral(declaration.name))) {
|
|
383
364
|
return globalSymbols[0];
|
|
384
365
|
}
|
|
385
366
|
}
|
|
@@ -394,15 +375,15 @@ function getExports(context, node, symbol) {
|
|
|
394
375
|
// members of the export= class and as functions if a class is directly exported.
|
|
395
376
|
result = [exportEq].concat(context.checker
|
|
396
377
|
.getExportsOfModule(symbol)
|
|
397
|
-
.filter((s) => !(0, enum_1.hasAnyFlag)(s.flags,
|
|
378
|
+
.filter((s) => !(0, enum_1.hasAnyFlag)(s.flags, typescript_1.default.SymbolFlags.Prototype | typescript_1.default.SymbolFlags.Value)));
|
|
398
379
|
}
|
|
399
380
|
else if (symbol) {
|
|
400
381
|
result = context.checker
|
|
401
382
|
.getExportsOfModule(symbol)
|
|
402
|
-
.filter((s) => !(0, enum_1.hasAllFlags)(s.flags,
|
|
383
|
+
.filter((s) => !(0, enum_1.hasAllFlags)(s.flags, typescript_1.default.SymbolFlags.Prototype));
|
|
403
384
|
if (result.length === 0) {
|
|
404
|
-
const globalDecl = node.statements.find((s) =>
|
|
405
|
-
s.flags &
|
|
385
|
+
const globalDecl = node.statements.find((s) => typescript_1.default.isModuleDeclaration(s) &&
|
|
386
|
+
s.flags & typescript_1.default.NodeFlags.GlobalAugmentation);
|
|
406
387
|
if (globalDecl) {
|
|
407
388
|
const globalSymbol = context.getSymbolAtLocation(globalDecl);
|
|
408
389
|
if (globalSymbol) {
|
|
@@ -417,7 +398,7 @@ function getExports(context, node, symbol) {
|
|
|
417
398
|
// Global file with no inferred top level symbol, get all symbols declared in this file.
|
|
418
399
|
const sourceFile = node.getSourceFile();
|
|
419
400
|
result = context.checker
|
|
420
|
-
.getSymbolsInScope(node,
|
|
401
|
+
.getSymbolsInScope(node, typescript_1.default.SymbolFlags.ModuleMember)
|
|
421
402
|
.filter((s) => s
|
|
422
403
|
.getDeclarations()
|
|
423
404
|
?.some((d) => d.getSourceFile() === sourceFile));
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.convertIndexSignature = void 0;
|
|
30
7
|
const assert_1 = __importDefault(require("assert"));
|
|
31
|
-
const
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
32
9
|
const models_1 = require("../../models");
|
|
33
10
|
const converter_events_1 = require("../converter-events");
|
|
34
11
|
function convertIndexSignature(context, symbol) {
|
|
@@ -39,9 +16,9 @@ function convertIndexSignature(context, symbol) {
|
|
|
39
16
|
// and number index signatures... { [x: string]: 1 | 2; [x: number]: 2 }
|
|
40
17
|
// will be misrepresented.
|
|
41
18
|
const indexDeclaration = indexSymbol.getDeclarations()?.[0];
|
|
42
|
-
(0, assert_1.default)(indexDeclaration &&
|
|
19
|
+
(0, assert_1.default)(indexDeclaration && typescript_1.default.isIndexSignatureDeclaration(indexDeclaration));
|
|
43
20
|
const param = indexDeclaration.parameters[0];
|
|
44
|
-
(0, assert_1.default)(param &&
|
|
21
|
+
(0, assert_1.default)(param && typescript_1.default.isParameter(param));
|
|
45
22
|
const index = new models_1.SignatureReflection("__index", models_1.ReflectionKind.IndexSignature, context.scope);
|
|
46
23
|
index.parameters = [
|
|
47
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, symbol: ts.Symbol | undefined, declaration?: ts.SignatureDeclaration | ts.JSDocSignature): void;
|