typedoc 0.24.0-beta.6 → 0.24.0-beta.7
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/lib/converter/comments/blockLexer.js +2 -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 +3 -3
- package/dist/lib/converter/converter.js +5 -7
- 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/models/comments/comment.d.ts +5 -1
- package/dist/lib/models/comments/comment.js +1 -0
- package/dist/lib/serialization/schema.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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 = (0, comments_1.getComment)(exportSymbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.checker);
|
|
117
|
+
reflection.comment = (0, comments_1.getComment)(exportSymbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
|
|
118
118
|
}
|
|
119
119
|
if (symbol && !reflection.comment) {
|
|
120
|
-
reflection.comment = (0, comments_1.getComment)(symbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.checker);
|
|
120
|
+
reflection.comment = (0, comments_1.getComment)(symbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
|
|
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";
|
|
@@ -137,7 +137,7 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
137
137
|
*/
|
|
138
138
|
addUnknownSymbolResolver(resolver: ExternalSymbolResolver): void;
|
|
139
139
|
/** @internal */
|
|
140
|
-
resolveExternalLink(ref: DeclarationReference, refl: Reflection, part
|
|
140
|
+
resolveExternalLink(ref: DeclarationReference, refl: Reflection, part: CommentDisplayPart | undefined, symbolId: ReflectionSymbolId | undefined): ExternalResolveResult | string | undefined;
|
|
141
141
|
resolveLinks(comment: Comment, owner: Reflection): void;
|
|
142
142
|
resolveLinks(parts: readonly CommentDisplayPart[], owner: Reflection): CommentDisplayPart[];
|
|
143
143
|
/**
|
|
@@ -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");
|
|
@@ -114,19 +113,19 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
114
113
|
this._externalSymbolResolvers.push(resolver);
|
|
115
114
|
}
|
|
116
115
|
/** @internal */
|
|
117
|
-
resolveExternalLink(ref, refl, part) {
|
|
116
|
+
resolveExternalLink(ref, refl, part, symbolId) {
|
|
118
117
|
for (const resolver of this._externalSymbolResolvers) {
|
|
119
|
-
const resolved = resolver(ref, refl, part);
|
|
118
|
+
const resolved = resolver(ref, refl, part, symbolId);
|
|
120
119
|
if (resolved)
|
|
121
120
|
return resolved;
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
resolveLinks(comment, owner) {
|
|
125
124
|
if (comment instanceof index_1.Comment) {
|
|
126
|
-
(0, linkResolver_1.resolveLinks)(comment, owner, (ref, part, refl) => this.resolveExternalLink(ref, part, refl
|
|
125
|
+
(0, linkResolver_1.resolveLinks)(comment, owner, (ref, part, refl, id) => this.resolveExternalLink(ref, part, refl, id));
|
|
127
126
|
}
|
|
128
127
|
else {
|
|
129
|
-
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref, part, refl) => this.resolveExternalLink(ref, part, refl
|
|
128
|
+
return (0, linkResolver_1.resolvePartLinks)(owner, comment, (ref, part, refl, id) => this.resolveExternalLink(ref, part, refl, id));
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
@@ -165,8 +164,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
165
164
|
// create modules for each entry. Register the project as this module.
|
|
166
165
|
context.project.registerReflection(context.project, symbol);
|
|
167
166
|
context.project.comment =
|
|
168
|
-
symbol &&
|
|
169
|
-
(0, comments_1.getComment)(symbol, context.project.kind, this.config, this.application.logger, this.commentStyle, context.checker);
|
|
167
|
+
symbol && context.getComment(symbol, context.project.kind);
|
|
170
168
|
context.trigger(Converter_1.EVENT_CREATE_DECLARATION, context.project);
|
|
171
169
|
moduleContext = context;
|
|
172
170
|
}
|
|
@@ -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;
|
|
@@ -9,13 +9,16 @@ export type CommentDisplayPart = {
|
|
|
9
9
|
} | InlineTagDisplayPart;
|
|
10
10
|
/**
|
|
11
11
|
* The `@link`, `@linkcode`, and `@linkplain` tags may have a `target`
|
|
12
|
-
* property set indicating which reflection/url they link to.
|
|
12
|
+
* property set indicating which reflection/url they link to. They may also
|
|
13
|
+
* have a `tsLinkText` property which includes the part of the `text` which
|
|
14
|
+
* TypeScript thinks should be displayed as the link text.
|
|
13
15
|
*/
|
|
14
16
|
export interface InlineTagDisplayPart {
|
|
15
17
|
kind: "inline-tag";
|
|
16
18
|
tag: `@${string}`;
|
|
17
19
|
text: string;
|
|
18
20
|
target?: Reflection | string | ReflectionSymbolId;
|
|
21
|
+
tsLinkText?: string;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* A model that represents a single TypeDoc comment tag.
|
|
@@ -76,6 +79,7 @@ export declare class Comment {
|
|
|
76
79
|
tag: `@${string}`;
|
|
77
80
|
text: string;
|
|
78
81
|
target?: string | Reflection | ReflectionSymbolId | undefined;
|
|
82
|
+
tsLinkText?: string | undefined;
|
|
79
83
|
})[];
|
|
80
84
|
static serializeDisplayParts(serializer: Serializer, parts: CommentDisplayPart[]): JSONOutput.CommentDisplayPart[];
|
|
81
85
|
/** @hidden no point in showing this signature in api docs */
|
|
@@ -182,6 +182,7 @@ export interface InlineTagDisplayPart {
|
|
|
182
182
|
tag: `@${string}`;
|
|
183
183
|
text: string;
|
|
184
184
|
target?: string | number | ReflectionSymbolId;
|
|
185
|
+
tsLinkText?: string;
|
|
185
186
|
}
|
|
186
187
|
export interface SourceReference extends S<M.SourceReference, "fileName" | "line" | "character" | "url"> {
|
|
187
188
|
}
|