typedoc 0.24.0-beta.6 → 0.24.0-beta.8
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 +4 -0
- package/dist/index.js +17 -1
- package/dist/lib/converter/comments/blockLexer.js +2 -1
- package/dist/lib/converter/comments/discovery.js +1 -1
- package/dist/lib/converter/comments/index.d.ts +4 -3
- package/dist/lib/converter/comments/index.js +9 -2
- package/dist/lib/converter/comments/lexer.d.ts +2 -1
- package/dist/lib/converter/comments/linkResolver.d.ts +12 -4
- package/dist/lib/converter/comments/linkResolver.js +39 -18
- package/dist/lib/converter/comments/parser.js +3 -2
- package/dist/lib/converter/context.d.ts +3 -0
- package/dist/lib/converter/context.js +11 -2
- package/dist/lib/converter/converter.d.ts +9 -7
- package/dist/lib/converter/converter.js +12 -12
- package/dist/lib/converter/factories/signature.js +5 -6
- package/dist/lib/converter/jsdoc.js +3 -4
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +1 -1
- package/dist/lib/converter/plugins/PackagePlugin.js +3 -1
- package/dist/lib/converter/symbols.js +9 -4
- package/dist/lib/models/comments/comment.d.ts +7 -3
- package/dist/lib/models/comments/comment.js +26 -5
- package/dist/lib/models/reflections/declaration.d.ts +1 -1
- package/dist/lib/models/reflections/project.d.ts +0 -6
- package/dist/lib/models/reflections/project.js +0 -16
- package/dist/lib/models/types.js +2 -31
- package/dist/lib/output/components.d.ts +3 -3
- package/dist/lib/output/components.js +1 -5
- package/dist/lib/output/events.d.ts +22 -10
- package/dist/lib/output/events.js +14 -6
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +1 -3
- package/dist/lib/output/renderer.d.ts +12 -4
- package/dist/lib/output/renderer.js +3 -3
- package/dist/lib/output/theme.d.ts +2 -2
- package/dist/lib/output/themes/MarkedPlugin.d.ts +2 -2
- package/dist/lib/output/themes/MarkedPlugin.js +15 -12
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +5 -5
- package/dist/lib/output/themes/default/DefaultTheme.js +58 -11
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +15 -13
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +9 -59
- package/dist/lib/output/themes/default/layouts/default.d.ts +2 -1
- package/dist/lib/output/themes/default/layouts/default.js +18 -12
- package/dist/lib/output/themes/default/partials/footer.js +1 -1
- package/dist/lib/output/themes/default/partials/member.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/member.js +22 -14
- package/dist/lib/output/themes/default/partials/members.group.js +3 -3
- package/dist/lib/output/themes/default/partials/navigation.d.ts +4 -3
- package/dist/lib/output/themes/default/partials/navigation.js +71 -74
- package/dist/lib/output/themes/default/partials/toolbar.js +2 -1
- package/dist/lib/serialization/schema.d.ts +2 -0
- package/dist/lib/serialization/schema.js +1 -0
- package/dist/lib/serialization/serializer.d.ts +1 -1
- package/dist/lib/utils/entry-point.d.ts +3 -3
- package/dist/lib/utils/entry-point.js +4 -4
- package/dist/lib/utils/fs.d.ts +5 -0
- package/dist/lib/utils/fs.js +35 -2
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/options.d.ts +5 -0
- package/dist/lib/utils/options/sources/typedoc.js +5 -0
- package/package.json +1 -1
- package/static/main.js +3 -3
- package/static/style.css +186 -257
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { Application } from "./lib/application";
|
|
|
2
2
|
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
|
+
/**
|
|
6
|
+
* All symbols documented under the Models namespace are also available in the root import.
|
|
7
|
+
*/
|
|
8
|
+
export * as Models from "./lib/models";
|
|
5
9
|
export * from "./lib/models";
|
|
6
10
|
export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
|
|
7
11
|
export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
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
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
@@ -17,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
|
|
32
|
+
exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Models = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
|
|
21
33
|
var application_1 = require("./lib/application");
|
|
22
34
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
23
35
|
var events_1 = require("./lib/utils/events");
|
|
@@ -27,6 +39,10 @@ var abstract_1 = require("./lib/models/reflections/abstract");
|
|
|
27
39
|
Object.defineProperty(exports, "resetReflectionID", { enumerable: true, get: function () { return abstract_1.resetReflectionID; } });
|
|
28
40
|
var fs_1 = require("./lib/utils/fs");
|
|
29
41
|
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return fs_1.normalizePath; } });
|
|
42
|
+
/**
|
|
43
|
+
* All symbols documented under the Models namespace are also available in the root import.
|
|
44
|
+
*/
|
|
45
|
+
exports.Models = __importStar(require("./lib/models"));
|
|
30
46
|
__exportStar(require("./lib/models"), exports);
|
|
31
47
|
var converter_1 = require("./lib/converter");
|
|
32
48
|
Object.defineProperty(exports, "Converter", { enumerable: true, get: function () { return converter_1.Converter; } });
|
|
@@ -249,7 +249,8 @@ function* lexBlockComment2(file, pos, end, linkTags, checker) {
|
|
|
249
249
|
if (link.name) {
|
|
250
250
|
const tsTarget = checker?.getSymbolAtLocation(link.name);
|
|
251
251
|
if (tsTarget) {
|
|
252
|
-
token.
|
|
252
|
+
token.tsLinkTarget = new ReflectionSymbolId_1.ReflectionSymbolId((0, symbols_1.resolveAliasedSymbol)(tsTarget, checker));
|
|
253
|
+
token.tsLinkText = link.text.replace(/^\s*\|\s*/, "");
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
}
|
|
@@ -7,6 +7,7 @@ export interface CommentParserConfig {
|
|
|
7
7
|
inlineTags: Set<string>;
|
|
8
8
|
modifierTags: Set<string>;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
10
|
+
export declare function clearCommentCache(): void;
|
|
11
|
+
export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
|
|
12
|
+
export declare function getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
|
|
13
|
+
export declare function getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag, config: CommentParserConfig, logger: Logger, checker: ts.TypeChecker | undefined): Comment | undefined;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getJsDocComment = exports.getSignatureComment = exports.getComment = void 0;
|
|
6
|
+
exports.getJsDocComment = exports.getSignatureComment = exports.getComment = exports.clearCommentCache = void 0;
|
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
|
8
8
|
const models_1 = require("../../models");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
@@ -18,7 +18,14 @@ const jsDocCommentKinds = [
|
|
|
18
18
|
typescript_1.default.SyntaxKind.JSDocTemplateTag,
|
|
19
19
|
typescript_1.default.SyntaxKind.JSDocEnumTag,
|
|
20
20
|
];
|
|
21
|
-
|
|
21
|
+
let commentCache = new WeakMap();
|
|
22
|
+
// We need to do this for tests so that changing the tsLinkResolution option
|
|
23
|
+
// actually works. Without it, we'd get the old parsed comment which doesn't
|
|
24
|
+
// have the TS symbols attached.
|
|
25
|
+
function clearCommentCache() {
|
|
26
|
+
commentCache = new WeakMap();
|
|
27
|
+
}
|
|
28
|
+
exports.clearCommentCache = clearCommentCache;
|
|
22
29
|
function getCommentWithCache(discovered, config, logger, checker) {
|
|
23
30
|
if (!discovered)
|
|
24
31
|
return;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { Comment, CommentDisplayPart, Reflection } from "../../models";
|
|
1
|
+
import { Comment, CommentDisplayPart, Reflection, ReflectionSymbolId } from "../../models";
|
|
2
2
|
import { DeclarationReference } from "./declarationReference";
|
|
3
3
|
export type ExternalResolveResult = {
|
|
4
4
|
target: string;
|
|
5
5
|
caption?: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param ref - Parsed declaration reference to resolve. This may be created automatically for some symbol, or
|
|
9
|
+
* parsed from user input.
|
|
10
|
+
* @param refl - Reflection that contains the resolved link
|
|
11
|
+
* @param part - If the declaration reference was created from a comment, the originating part.
|
|
12
|
+
* @param symbolId - If the declaration reference was created from a symbol, or `useTsLinkResolution` is turned
|
|
13
|
+
* on and TypeScript resolved the link to some symbol, the ID of that symbol.
|
|
14
|
+
*/
|
|
15
|
+
export type ExternalSymbolResolver = (ref: DeclarationReference, refl: Reflection, part: Readonly<CommentDisplayPart> | undefined, symbolId: ReflectionSymbolId | undefined) => ExternalResolveResult | string | undefined;
|
|
16
|
+
export declare function resolveLinks(comment: Comment, reflection: Reflection, externalResolver: ExternalSymbolResolver): void;
|
|
17
|
+
export declare function resolvePartLinks(reflection: Reflection, parts: readonly CommentDisplayPart[], externalResolver: ExternalSymbolResolver): CommentDisplayPart[];
|
|
@@ -9,31 +9,31 @@ const models_1 = require("../../models");
|
|
|
9
9
|
const declarationReference_1 = require("./declarationReference");
|
|
10
10
|
const declarationReferenceResolver_1 = require("./declarationReferenceResolver");
|
|
11
11
|
const urlPrefix = /^(http|ftp)s?:\/\//;
|
|
12
|
-
function resolveLinks(comment, reflection, externalResolver
|
|
13
|
-
comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver
|
|
12
|
+
function resolveLinks(comment, reflection, externalResolver) {
|
|
13
|
+
comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver);
|
|
14
14
|
for (const tag of comment.blockTags) {
|
|
15
|
-
tag.content = resolvePartLinks(reflection, tag.content, externalResolver
|
|
15
|
+
tag.content = resolvePartLinks(reflection, tag.content, externalResolver);
|
|
16
16
|
}
|
|
17
17
|
if (reflection instanceof models_1.DeclarationReflection && reflection.readme) {
|
|
18
|
-
reflection.readme = resolvePartLinks(reflection, reflection.readme, externalResolver
|
|
18
|
+
reflection.readme = resolvePartLinks(reflection, reflection.readme, externalResolver);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.resolveLinks = resolveLinks;
|
|
22
|
-
function resolvePartLinks(reflection, parts, externalResolver
|
|
23
|
-
return parts.flatMap((part) => processPart(reflection, part, externalResolver
|
|
22
|
+
function resolvePartLinks(reflection, parts, externalResolver) {
|
|
23
|
+
return parts.flatMap((part) => processPart(reflection, part, externalResolver));
|
|
24
24
|
}
|
|
25
25
|
exports.resolvePartLinks = resolvePartLinks;
|
|
26
|
-
function processPart(reflection, part, externalResolver
|
|
26
|
+
function processPart(reflection, part, externalResolver) {
|
|
27
27
|
if (part.kind === "inline-tag") {
|
|
28
28
|
if (part.tag === "@link" ||
|
|
29
29
|
part.tag === "@linkcode" ||
|
|
30
30
|
part.tag === "@linkplain") {
|
|
31
|
-
return resolveLinkTag(reflection, part, externalResolver
|
|
31
|
+
return resolveLinkTag(reflection, part, externalResolver);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return part;
|
|
35
35
|
}
|
|
36
|
-
function resolveLinkTag(reflection, part, externalResolver
|
|
36
|
+
function resolveLinkTag(reflection, part, externalResolver) {
|
|
37
37
|
let defaultDisplayText = "";
|
|
38
38
|
let pos = 0;
|
|
39
39
|
const end = part.text.length;
|
|
@@ -41,17 +41,36 @@ function resolveLinkTag(reflection, part, externalResolver, useTsResolution) {
|
|
|
41
41
|
pos++;
|
|
42
42
|
}
|
|
43
43
|
let target;
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
// Try to parse a declaration reference if we didn't use the TS symbol for resolution
|
|
45
|
+
const declRef = (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
|
|
46
|
+
// Might already know where it should go if useTsLinkResolution is turned on
|
|
47
|
+
if (part.target instanceof models_1.ReflectionSymbolId) {
|
|
48
|
+
const tsTarget = reflection.project.getReflectionFromSymbolId(part.target);
|
|
49
|
+
if (tsTarget) {
|
|
50
|
+
target = tsTarget;
|
|
47
51
|
pos = end;
|
|
48
|
-
defaultDisplayText =
|
|
49
|
-
|
|
52
|
+
defaultDisplayText = part.tsLinkText || target.name;
|
|
53
|
+
}
|
|
54
|
+
else if (declRef) {
|
|
55
|
+
// If we didn't find a target, we might be pointing to a symbol in another project that will be merged in
|
|
56
|
+
// or some external symbol, so ask external resolvers to try resolution. Don't use regular declaration ref
|
|
57
|
+
// resolution in case it matches something that would have been merged in later.
|
|
58
|
+
const externalResolveResult = externalResolver(declRef[0], reflection, part, part.target instanceof models_1.ReflectionSymbolId
|
|
59
|
+
? part.target
|
|
60
|
+
: undefined);
|
|
61
|
+
defaultDisplayText = part.text.substring(0, pos);
|
|
62
|
+
switch (typeof externalResolveResult) {
|
|
63
|
+
case "string":
|
|
64
|
+
target = externalResolveResult;
|
|
65
|
+
break;
|
|
66
|
+
case "object":
|
|
67
|
+
target = externalResolveResult.target;
|
|
68
|
+
defaultDisplayText =
|
|
69
|
+
externalResolveResult.caption || defaultDisplayText;
|
|
70
|
+
}
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
|
-
|
|
53
|
-
const declRef = !target && (0, declarationReference_1.parseDeclarationReference)(part.text, pos, end);
|
|
54
|
-
if (declRef) {
|
|
73
|
+
if (!target && declRef) {
|
|
55
74
|
// Got one, great! Try to resolve the link
|
|
56
75
|
target = (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
|
|
57
76
|
pos = declRef[1];
|
|
@@ -60,7 +79,9 @@ function resolveLinkTag(reflection, part, externalResolver, useTsResolution) {
|
|
|
60
79
|
}
|
|
61
80
|
else {
|
|
62
81
|
// If we didn't find a link, it might be a @link tag to an external symbol, check that next.
|
|
63
|
-
const externalResolveResult = externalResolver(declRef[0], reflection, part
|
|
82
|
+
const externalResolveResult = externalResolver(declRef[0], reflection, part, part.target instanceof models_1.ReflectionSymbolId
|
|
83
|
+
? part.target
|
|
84
|
+
: undefined);
|
|
64
85
|
defaultDisplayText = part.text.substring(0, pos);
|
|
65
86
|
switch (typeof externalResolveResult) {
|
|
66
87
|
case "string":
|
|
@@ -304,8 +304,9 @@ function inlineTag(lexer, block, config, warning) {
|
|
|
304
304
|
tag: tagName.text,
|
|
305
305
|
text: content.join(""),
|
|
306
306
|
};
|
|
307
|
-
if (tagName.
|
|
308
|
-
inlineTag.target = tagName.
|
|
307
|
+
if (tagName.tsLinkTarget) {
|
|
308
|
+
inlineTag.target = tagName.tsLinkTarget;
|
|
309
|
+
inlineTag.tsLinkText = tagName.tsLinkText;
|
|
309
310
|
}
|
|
310
311
|
block.push(inlineTag);
|
|
311
312
|
}
|
|
@@ -78,6 +78,9 @@ export declare class Context {
|
|
|
78
78
|
trigger(name: string, reflection: Reflection, node?: ts.Node): void;
|
|
79
79
|
/** @internal */
|
|
80
80
|
setActiveProgram(program: ts.Program | undefined): void;
|
|
81
|
+
getComment(symbol: ts.Symbol, kind: ReflectionKind): import("../models/index").Comment | undefined;
|
|
82
|
+
getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag): import("../models/index").Comment | undefined;
|
|
83
|
+
getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature): import("../models/index").Comment | undefined;
|
|
81
84
|
/**
|
|
82
85
|
* @param callback The callback function that should be executed with the changed context.
|
|
83
86
|
*/
|
|
@@ -114,10 +114,10 @@ class Context {
|
|
|
114
114
|
if (exportSymbol &&
|
|
115
115
|
reflection.kind &
|
|
116
116
|
(index_1.ReflectionKind.SomeModule | index_1.ReflectionKind.Reference)) {
|
|
117
|
-
reflection.comment =
|
|
117
|
+
reflection.comment = this.getComment(exportSymbol, reflection.kind);
|
|
118
118
|
}
|
|
119
119
|
if (symbol && !reflection.comment) {
|
|
120
|
-
reflection.comment =
|
|
120
|
+
reflection.comment = this.getComment(symbol, reflection.kind);
|
|
121
121
|
}
|
|
122
122
|
if (this.shouldBeStatic) {
|
|
123
123
|
reflection.setFlag(index_1.ReflectionFlag.Static);
|
|
@@ -173,6 +173,15 @@ class Context {
|
|
|
173
173
|
setActiveProgram(program) {
|
|
174
174
|
this._program = program;
|
|
175
175
|
}
|
|
176
|
+
getComment(symbol, kind) {
|
|
177
|
+
return (0, comments_1.getComment)(symbol, kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
|
|
178
|
+
}
|
|
179
|
+
getJsDocComment(declaration) {
|
|
180
|
+
return (0, comments_1.getJsDocComment)(declaration, this.converter.config, this.logger, this.converter.useTsLinkResolution ? this.checker : undefined);
|
|
181
|
+
}
|
|
182
|
+
getSignatureComment(declaration) {
|
|
183
|
+
return (0, comments_1.getSignatureComment)(declaration, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
|
|
184
|
+
}
|
|
176
185
|
/**
|
|
177
186
|
* @param callback The callback function that should be executed with the changed context.
|
|
178
187
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import type { Application } from "../application";
|
|
3
|
-
import { Comment, CommentDisplayPart, ProjectReflection, Reflection, SomeType } from "../models/index";
|
|
3
|
+
import { Comment, CommentDisplayPart, ProjectReflection, Reflection, ReflectionSymbolId, SomeType } from "../models/index";
|
|
4
4
|
import { Context } from "./context";
|
|
5
5
|
import { ConverterComponent } from "./components";
|
|
6
6
|
import { ChildableComponent } from "../utils/component";
|
|
7
7
|
import { MinimalSourceFile } from "../utils";
|
|
8
8
|
import type { DocumentationEntryPoint } from "../utils/entry-point";
|
|
9
|
-
import { CommentParserConfig } from "./comments";
|
|
9
|
+
import type { CommentParserConfig } from "./comments";
|
|
10
10
|
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration";
|
|
11
11
|
import { ExternalSymbolResolver, ExternalResolveResult } from "./comments/linkResolver";
|
|
12
12
|
import type { DeclarationReference } from "./comments/declarationReference";
|
|
@@ -27,6 +27,8 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
27
27
|
/** @internal */
|
|
28
28
|
excludeProtected: boolean;
|
|
29
29
|
/** @internal */
|
|
30
|
+
excludeReferences: boolean;
|
|
31
|
+
/** @internal */
|
|
30
32
|
commentStyle: CommentStyle;
|
|
31
33
|
/** @internal */
|
|
32
34
|
validation: ValidationOptions;
|
|
@@ -57,13 +59,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
57
59
|
*/
|
|
58
60
|
/**
|
|
59
61
|
* Triggered when the converter has created a declaration reflection.
|
|
60
|
-
* The listener will be given {@link Context} and a {@link DeclarationReflection}.
|
|
62
|
+
* The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
|
|
61
63
|
* @event
|
|
62
64
|
*/
|
|
63
65
|
static readonly EVENT_CREATE_DECLARATION: "createDeclaration";
|
|
64
66
|
/**
|
|
65
67
|
* Triggered when the converter has created a signature reflection.
|
|
66
|
-
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
|
|
68
|
+
* The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
|
|
67
69
|
* `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
|
|
68
70
|
* and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
|
|
69
71
|
* @event
|
|
@@ -71,13 +73,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
71
73
|
static readonly EVENT_CREATE_SIGNATURE: "createSignature";
|
|
72
74
|
/**
|
|
73
75
|
* Triggered when the converter has created a parameter reflection.
|
|
74
|
-
* The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
|
|
76
|
+
* The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
|
|
75
77
|
* @event
|
|
76
78
|
*/
|
|
77
79
|
static readonly EVENT_CREATE_PARAMETER: "createParameter";
|
|
78
80
|
/**
|
|
79
81
|
* Triggered when the converter has created a type parameter reflection.
|
|
80
|
-
* The listener will be given {@link Context} and a {@link TypeParameterReflection}
|
|
82
|
+
* The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
|
|
81
83
|
* @event
|
|
82
84
|
*/
|
|
83
85
|
static readonly EVENT_CREATE_TYPE_PARAMETER: "createTypeParameter";
|
|
@@ -137,7 +139,7 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
137
139
|
*/
|
|
138
140
|
addUnknownSymbolResolver(resolver: ExternalSymbolResolver): void;
|
|
139
141
|
/** @internal */
|
|
140
|
-
resolveExternalLink(ref: DeclarationReference, refl: Reflection, part
|
|
142
|
+
resolveExternalLink(ref: DeclarationReference, refl: Reflection, part: CommentDisplayPart | undefined, symbolId: ReflectionSymbolId | undefined): ExternalResolveResult | string | undefined;
|
|
141
143
|
resolveLinks(comment: Comment, owner: Reflection): void;
|
|
142
144
|
resolveLinks(parts: readonly CommentDisplayPart[], owner: Reflection): CommentDisplayPart[];
|
|
143
145
|
/**
|
|
@@ -22,7 +22,6 @@ const converter_events_1 = require("./converter-events");
|
|
|
22
22
|
const symbols_1 = require("./symbols");
|
|
23
23
|
const paths_1 = require("../utils/paths");
|
|
24
24
|
const enum_1 = require("../utils/enum");
|
|
25
|
-
const comments_1 = require("./comments");
|
|
26
25
|
const parser_1 = require("./comments/parser");
|
|
27
26
|
const rawLexer_1 = require("./comments/rawLexer");
|
|
28
27
|
const linkResolver_1 = require("./comments/linkResolver");
|
|
@@ -73,7 +72,6 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
73
72
|
this.compile(entryPoints, context);
|
|
74
73
|
this.resolve(context);
|
|
75
74
|
this.trigger(Converter_1.EVENT_END, context);
|
|
76
|
-
project.forgetTsReferences();
|
|
77
75
|
return project;
|
|
78
76
|
}
|
|
79
77
|
/** @internal */
|
|
@@ -114,19 +112,19 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
114
112
|
this._externalSymbolResolvers.push(resolver);
|
|
115
113
|
}
|
|
116
114
|
/** @internal */
|
|
117
|
-
resolveExternalLink(ref, refl, part) {
|
|
115
|
+
resolveExternalLink(ref, refl, part, symbolId) {
|
|
118
116
|
for (const resolver of this._externalSymbolResolvers) {
|
|
119
|
-
const resolved = resolver(ref, refl, part);
|
|
117
|
+
const resolved = resolver(ref, refl, part, symbolId);
|
|
120
118
|
if (resolved)
|
|
121
119
|
return resolved;
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
122
|
resolveLinks(comment, owner) {
|
|
125
123
|
if (comment instanceof index_1.Comment) {
|
|
126
|
-
(0, linkResolver_1.resolveLinks)(comment, owner, (ref, part, refl) => this.resolveExternalLink(ref, part, refl
|
|
124
|
+
(0, linkResolver_1.resolveLinks)(comment, owner, (ref, part, refl, id) => this.resolveExternalLink(ref, part, refl, id));
|
|
127
125
|
}
|
|
128
126
|
else {
|
|
129
|
-
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref, part, refl) => this.resolveExternalLink(ref, part, refl
|
|
127
|
+
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref, part, refl, id) => this.resolveExternalLink(ref, part, refl, id));
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
/**
|
|
@@ -165,8 +163,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
165
163
|
// create modules for each entry. Register the project as this module.
|
|
166
164
|
context.project.registerReflection(context.project, symbol);
|
|
167
165
|
context.project.comment =
|
|
168
|
-
symbol &&
|
|
169
|
-
(0, comments_1.getComment)(symbol, context.project.kind, this.config, this.application.logger, this.commentStyle, context.checker);
|
|
166
|
+
symbol && context.getComment(symbol, context.project.kind);
|
|
170
167
|
context.trigger(Converter_1.EVENT_CREATE_DECLARATION, context.project);
|
|
171
168
|
moduleContext = context;
|
|
172
169
|
}
|
|
@@ -265,13 +262,13 @@ Converter.EVENT_END = converter_events_1.ConverterEvents.END;
|
|
|
265
262
|
*/
|
|
266
263
|
/**
|
|
267
264
|
* Triggered when the converter has created a declaration reflection.
|
|
268
|
-
* The listener will be given {@link Context} and a {@link DeclarationReflection}.
|
|
265
|
+
* The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
|
|
269
266
|
* @event
|
|
270
267
|
*/
|
|
271
268
|
Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_DECLARATION;
|
|
272
269
|
/**
|
|
273
270
|
* Triggered when the converter has created a signature reflection.
|
|
274
|
-
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
|
|
271
|
+
* The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
|
|
275
272
|
* `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
|
|
276
273
|
* and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
|
|
277
274
|
* @event
|
|
@@ -279,13 +276,13 @@ Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_D
|
|
|
279
276
|
Converter.EVENT_CREATE_SIGNATURE = converter_events_1.ConverterEvents.CREATE_SIGNATURE;
|
|
280
277
|
/**
|
|
281
278
|
* Triggered when the converter has created a parameter reflection.
|
|
282
|
-
* The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
|
|
279
|
+
* The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
|
|
283
280
|
* @event
|
|
284
281
|
*/
|
|
285
282
|
Converter.EVENT_CREATE_PARAMETER = converter_events_1.ConverterEvents.CREATE_PARAMETER;
|
|
286
283
|
/**
|
|
287
284
|
* Triggered when the converter has created a type parameter reflection.
|
|
288
|
-
* The listener will be given {@link Context} and a {@link TypeParameterReflection}
|
|
285
|
+
* The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
|
|
289
286
|
* @event
|
|
290
287
|
*/
|
|
291
288
|
Converter.EVENT_CREATE_TYPE_PARAMETER = converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER;
|
|
@@ -325,6 +322,9 @@ __decorate([
|
|
|
325
322
|
__decorate([
|
|
326
323
|
(0, utils_1.BindOption)("excludeProtected")
|
|
327
324
|
], Converter.prototype, "excludeProtected", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
(0, utils_1.BindOption)("excludeReferences")
|
|
327
|
+
], Converter.prototype, "excludeReferences", void 0);
|
|
328
328
|
__decorate([
|
|
329
329
|
(0, utils_1.BindOption)("commentStyle")
|
|
330
330
|
], Converter.prototype, "commentStyle", void 0);
|
|
@@ -10,7 +10,6 @@ const models_1 = require("../../models");
|
|
|
10
10
|
const converter_events_1 = require("../converter-events");
|
|
11
11
|
const convert_expression_1 = require("../convert-expression");
|
|
12
12
|
const reflections_1 = require("../utils/reflections");
|
|
13
|
-
const comments_1 = require("../comments");
|
|
14
13
|
const ReflectionSymbolId_1 = require("../../models/reflections/ReflectionSymbolId");
|
|
15
14
|
function createSignature(context, kind, signature, symbol, declaration) {
|
|
16
15
|
var _a;
|
|
@@ -35,7 +34,7 @@ function createSignature(context, kind, signature, symbol, declaration) {
|
|
|
35
34
|
(!parentReflection.comment ||
|
|
36
35
|
!(parentReflection.conversionFlags &
|
|
37
36
|
models_1.ConversionFlags.VariableOrPropertySource))) {
|
|
38
|
-
sigRef.comment =
|
|
37
|
+
sigRef.comment = context.getSignatureComment(declaration);
|
|
39
38
|
}
|
|
40
39
|
sigRef.typeParameters = convertTypeParameters(sigRefCtx, sigRef, signature.typeParameters);
|
|
41
40
|
const parameterSymbols = signature.thisParameter
|
|
@@ -79,9 +78,9 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
|
|
|
79
78
|
typescript_1.default.isJSDocParameterTag(declaration));
|
|
80
79
|
const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name) ? "__namedParameters" : param.name, models_1.ReflectionKind.Parameter, sigRef);
|
|
81
80
|
if (declaration && typescript_1.default.isJSDocParameterTag(declaration)) {
|
|
82
|
-
paramRefl.comment =
|
|
81
|
+
paramRefl.comment = context.getJsDocComment(declaration);
|
|
83
82
|
}
|
|
84
|
-
paramRefl.comment || (paramRefl.comment =
|
|
83
|
+
paramRefl.comment || (paramRefl.comment = context.getComment(param, paramRefl.kind));
|
|
85
84
|
context.registerReflection(paramRefl, param);
|
|
86
85
|
context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
|
|
87
86
|
let type;
|
|
@@ -125,7 +124,7 @@ function convertParameterNodes(context, sigRef, parameters) {
|
|
|
125
124
|
? "__namedParameters"
|
|
126
125
|
: param.name.getText(), models_1.ReflectionKind.Parameter, sigRef);
|
|
127
126
|
if (typescript_1.default.isJSDocParameterTag(param)) {
|
|
128
|
-
paramRefl.comment =
|
|
127
|
+
paramRefl.comment = context.getJsDocComment(param);
|
|
129
128
|
}
|
|
130
129
|
context.registerReflection(paramRefl, context.getSymbolAtLocation(param));
|
|
131
130
|
context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
|
|
@@ -191,7 +190,7 @@ function createTypeParamReflection(param, context) {
|
|
|
191
190
|
}
|
|
192
191
|
context.registerReflection(paramRefl, param.symbol);
|
|
193
192
|
if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
|
|
194
|
-
paramRefl.comment =
|
|
193
|
+
paramRefl.comment = context.getJsDocComment(param.parent);
|
|
195
194
|
}
|
|
196
195
|
context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
|
|
197
196
|
return paramRefl;
|
|
@@ -11,7 +11,6 @@ const assert_1 = require("assert");
|
|
|
11
11
|
const typescript_1 = __importDefault(require("typescript"));
|
|
12
12
|
const models_1 = require("../models");
|
|
13
13
|
const ReflectionSymbolId_1 = require("../models/reflections/ReflectionSymbolId");
|
|
14
|
-
const comments_1 = require("./comments");
|
|
15
14
|
const converter_events_1 = require("./converter-events");
|
|
16
15
|
const signature_1 = require("./factories/signature");
|
|
17
16
|
function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
|
|
@@ -29,7 +28,7 @@ function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
|
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
30
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
32
|
-
reflection.comment =
|
|
31
|
+
reflection.comment = context.getJsDocComment(declaration);
|
|
33
32
|
reflection.type = context.converter.convertType(context.withScope(reflection), declaration.typeExpression?.type);
|
|
34
33
|
convertTemplateParameters(context.withScope(reflection), declaration.parent);
|
|
35
34
|
context.finalizeDeclarationReflection(reflection);
|
|
@@ -37,7 +36,7 @@ function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
|
|
|
37
36
|
exports.convertJsDocAlias = convertJsDocAlias;
|
|
38
37
|
function convertJsDocCallback(context, symbol, declaration, exportSymbol) {
|
|
39
38
|
const alias = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
40
|
-
alias.comment =
|
|
39
|
+
alias.comment = context.getJsDocComment(declaration);
|
|
41
40
|
context.finalizeDeclarationReflection(alias);
|
|
42
41
|
const ac = context.withScope(alias);
|
|
43
42
|
alias.type = convertJsDocSignature(ac, declaration.typeExpression);
|
|
@@ -46,7 +45,7 @@ function convertJsDocCallback(context, symbol, declaration, exportSymbol) {
|
|
|
46
45
|
exports.convertJsDocCallback = convertJsDocCallback;
|
|
47
46
|
function convertJsDocInterface(context, declaration, symbol, exportSymbol) {
|
|
48
47
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Interface, symbol, exportSymbol);
|
|
49
|
-
reflection.comment =
|
|
48
|
+
reflection.comment = context.getJsDocComment(declaration);
|
|
50
49
|
context.finalizeDeclarationReflection(reflection);
|
|
51
50
|
const rc = context.withScope(reflection);
|
|
52
51
|
const type = context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
@@ -40,7 +40,7 @@ let LinkResolverPlugin = class LinkResolverPlugin extends components_1.Converter
|
|
|
40
40
|
}
|
|
41
41
|
for (const { type, owner } of (0, reflections_1.discoverAllReferenceTypes)(project, false)) {
|
|
42
42
|
if (!type.reflection) {
|
|
43
|
-
const resolveResult = this.owner.resolveExternalLink(type.toDeclarationReference(), owner);
|
|
43
|
+
const resolveResult = this.owner.resolveExternalLink(type.toDeclarationReference(), owner, undefined, type.symbolId);
|
|
44
44
|
switch (typeof resolveResult) {
|
|
45
45
|
case "string":
|
|
46
46
|
type.externalUrl = resolveResult;
|
|
@@ -50,6 +50,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
50
50
|
[converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
|
|
51
51
|
[converter_1.Converter.EVENT_END]: () => {
|
|
52
52
|
delete this.readmeFile;
|
|
53
|
+
delete this.readmeContents;
|
|
53
54
|
delete this.packageJson;
|
|
54
55
|
},
|
|
55
56
|
});
|
|
@@ -62,6 +63,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
62
63
|
this.addEntries(project);
|
|
63
64
|
delete this.readmeFile;
|
|
64
65
|
delete this.packageJson;
|
|
66
|
+
delete this.readmeContents;
|
|
65
67
|
}
|
|
66
68
|
onBegin() {
|
|
67
69
|
this.readmeFile = undefined;
|
|
@@ -117,7 +119,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
117
119
|
project.name = project.packageName || "Documentation";
|
|
118
120
|
}
|
|
119
121
|
if (this.includeVersion) {
|
|
120
|
-
project.packageVersion = this.packageJson.version;
|
|
122
|
+
project.packageVersion = this.packageJson.version?.replace(/^v/, "");
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
else if (!project.name) {
|
|
@@ -80,7 +80,7 @@ function convertSymbol(context, symbol, exportSymbol) {
|
|
|
80
80
|
// but aren't aliased symbols because `export *` was used.
|
|
81
81
|
const previous = context.project.getReflectionFromSymbol(symbol);
|
|
82
82
|
if (previous &&
|
|
83
|
-
previous.parent?.kindOf(models_1.ReflectionKind.
|
|
83
|
+
previous.parent?.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
|
|
84
84
|
createAlias(previous, context, symbol, exportSymbol);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
@@ -191,7 +191,9 @@ function convertTypeAlias(context, symbol, exportSymbol) {
|
|
|
191
191
|
typescript_1.default.isJSDocEnumTag(d));
|
|
192
192
|
(0, assert_1.default)(declaration);
|
|
193
193
|
if (typescript_1.default.isTypeAliasDeclaration(declaration)) {
|
|
194
|
-
if (
|
|
194
|
+
if (context
|
|
195
|
+
.getComment(symbol, models_1.ReflectionKind.TypeAlias)
|
|
196
|
+
?.hasModifier("@interface")) {
|
|
195
197
|
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
|
|
196
198
|
}
|
|
197
199
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
@@ -444,6 +446,8 @@ function convertAlias(context, symbol, exportSymbol) {
|
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
448
|
function createAlias(target, context, symbol, exportSymbol) {
|
|
449
|
+
if (context.converter.excludeReferences)
|
|
450
|
+
return;
|
|
447
451
|
// We already have this. Create a reference.
|
|
448
452
|
const ref = new models_1.ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
|
|
449
453
|
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
@@ -452,12 +456,13 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
452
456
|
function convertVariable(context, symbol, exportSymbol) {
|
|
453
457
|
const declaration = symbol.getDeclarations()?.[0];
|
|
454
458
|
(0, assert_1.default)(declaration);
|
|
459
|
+
const comment = context.getComment(symbol, models_1.ReflectionKind.Variable);
|
|
455
460
|
const type = context.checker.getTypeOfSymbolAtLocation(symbol, declaration);
|
|
456
461
|
if (isEnumLike(context.checker, type, declaration) &&
|
|
457
|
-
|
|
462
|
+
comment?.hasModifier("@enum")) {
|
|
458
463
|
return convertVariableAsEnum(context, symbol, exportSymbol);
|
|
459
464
|
}
|
|
460
|
-
if (
|
|
465
|
+
if (comment?.hasModifier("@namespace")) {
|
|
461
466
|
return convertVariableAsNamespace(context, symbol, exportSymbol);
|
|
462
467
|
}
|
|
463
468
|
if (type.getCallSignatures().length) {
|