typedoc 0.23.26 → 0.24.0-beta.1
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/bin/typedoc +1 -130
- package/dist/index.d.ts +4 -5
- package/dist/index.js +15 -5
- package/dist/lib/application-events.d.ts +1 -1
- package/dist/lib/application-events.js +1 -1
- package/dist/lib/application.d.ts +24 -13
- package/dist/lib/application.js +136 -69
- package/dist/lib/cli.d.ts +1 -0
- package/dist/lib/cli.js +129 -0
- package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
- package/dist/lib/converter/comments/declarationReferenceResolver.js +11 -5
- package/dist/lib/converter/comments/discovery.d.ts +1 -1
- package/dist/lib/converter/comments/discovery.js +96 -76
- package/dist/lib/converter/comments/index.d.ts +1 -1
- package/dist/lib/converter/comments/index.js +41 -21
- package/dist/lib/converter/comments/linkResolver.d.ts +2 -8
- package/dist/lib/converter/comments/linkResolver.js +42 -145
- package/dist/lib/converter/context.d.ts +1 -1
- package/dist/lib/converter/context.js +27 -14
- package/dist/lib/converter/convert-expression.d.ts +1 -1
- package/dist/lib/converter/convert-expression.js +35 -15
- package/dist/lib/converter/converter.d.ts +4 -6
- package/dist/lib/converter/converter.js +38 -27
- package/dist/lib/converter/factories/index-signature.d.ts +1 -1
- package/dist/lib/converter/factories/index-signature.js +26 -3
- package/dist/lib/converter/factories/signature.d.ts +2 -2
- package/dist/lib/converter/factories/signature.js +76 -52
- package/dist/lib/converter/index.d.ts +0 -1
- package/dist/lib/converter/jsdoc.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +39 -17
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +0 -2
- package/dist/lib/converter/plugins/CommentPlugin.js +7 -28
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +1 -39
- package/dist/lib/converter/plugins/GroupPlugin.js +3 -61
- package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +1 -4
- package/dist/lib/converter/plugins/ImplementsPlugin.js +49 -28
- package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +0 -3
- package/dist/lib/converter/plugins/InheritDocPlugin.js +6 -7
- package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +2 -3
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +12 -18
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -14
- package/dist/lib/converter/plugins/PackagePlugin.js +44 -56
- package/dist/lib/converter/plugins/SourcePlugin.js +31 -6
- package/dist/lib/converter/plugins/TypePlugin.d.ts +4 -10
- package/dist/lib/converter/plugins/TypePlugin.js +23 -13
- package/dist/lib/converter/symbols.d.ts +1 -1
- package/dist/lib/converter/symbols.js +153 -132
- package/dist/lib/converter/types.d.ts +1 -1
- package/dist/lib/converter/types.js +121 -95
- package/dist/lib/converter/utils/nodes.d.ts +1 -1
- package/dist/lib/converter/utils/nodes.js +24 -4
- package/dist/lib/converter/utils/symbols.d.ts +1 -1
- package/dist/lib/converter/utils/symbols.js +24 -4
- package/dist/lib/models/ReflectionCategory.d.ts +2 -1
- package/dist/lib/models/ReflectionCategory.js +12 -0
- package/dist/lib/models/ReflectionGroup.d.ts +3 -2
- package/dist/lib/models/ReflectionGroup.js +20 -0
- package/dist/lib/models/comments/comment.d.ts +12 -7
- package/dist/lib/models/comments/comment.js +77 -64
- package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +29 -0
- package/dist/lib/models/reflections/ReflectionSymbolId.js +94 -0
- package/dist/lib/models/reflections/abstract.d.ts +12 -37
- package/dist/lib/models/reflections/abstract.js +27 -35
- package/dist/lib/models/reflections/container.d.ts +6 -10
- package/dist/lib/models/reflections/container.js +8 -1
- package/dist/lib/models/reflections/declaration.d.ts +19 -4
- package/dist/lib/models/reflections/declaration.js +54 -1
- package/dist/lib/models/reflections/index.d.ts +2 -0
- package/dist/lib/models/reflections/index.js +3 -1
- package/dist/lib/models/reflections/kind.d.ts +15 -1
- package/dist/lib/models/reflections/kind.js +43 -1
- package/dist/lib/models/reflections/parameter.d.ts +3 -1
- package/dist/lib/models/reflections/parameter.js +10 -0
- package/dist/lib/models/reflections/project.d.ts +32 -5
- package/dist/lib/models/reflections/project.js +84 -20
- package/dist/lib/models/reflections/reference.d.ts +5 -9
- package/dist/lib/models/reflections/reference.js +13 -29
- package/dist/lib/models/reflections/signature.d.ts +8 -1
- package/dist/lib/models/reflections/signature.js +14 -0
- package/dist/lib/models/reflections/type-parameter.d.ts +7 -4
- package/dist/lib/models/reflections/type-parameter.js +9 -3
- package/dist/lib/models/reflections/variant.d.ts +18 -0
- package/dist/lib/models/reflections/variant.js +2 -0
- package/dist/lib/models/sources/file.d.ts +2 -0
- package/dist/lib/models/sources/file.js +3 -0
- package/dist/lib/models/types.d.ts +24 -20
- package/dist/lib/models/types.js +132 -33
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +3 -7
- package/dist/lib/output/renderer.d.ts +21 -14
- package/dist/lib/output/renderer.js +25 -25
- package/dist/lib/output/themes/MarkedPlugin.js +2 -3
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +2 -20
- package/dist/lib/output/themes/default/DefaultTheme.js +4 -75
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +10 -9
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +55 -1
- package/dist/lib/output/themes/default/partials/header.js +2 -5
- package/dist/lib/output/themes/default/partials/index.js +2 -2
- package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +2 -2
- package/dist/lib/output/themes/default/partials/member.getterSetter.js +4 -1
- package/dist/lib/output/themes/default/partials/member.js +1 -1
- package/dist/lib/output/themes/default/partials/member.signatures.js +2 -1
- package/dist/lib/output/themes/default/partials/members.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/members.js +3 -1
- package/dist/lib/output/themes/default/partials/navigation.js +6 -4
- package/dist/lib/output/themes/default/partials/parameter.js +1 -1
- package/dist/lib/output/themes/default/partials/type.js +4 -4
- package/dist/lib/output/themes/default/templates/reflection.js +1 -1
- package/dist/lib/output/themes/lib.d.ts +4 -1
- package/dist/lib/output/themes/lib.js +53 -3
- package/dist/lib/serialization/deserializer.d.ts +54 -0
- package/dist/lib/serialization/deserializer.js +212 -0
- package/dist/lib/serialization/events.d.ts +0 -15
- package/dist/lib/serialization/index.d.ts +2 -3
- package/dist/lib/serialization/index.js +4 -3
- package/dist/lib/serialization/schema.d.ts +23 -17
- package/dist/lib/serialization/serializer.d.ts +5 -5
- package/dist/lib/serialization/serializer.js +4 -15
- package/dist/lib/utils/array.d.ts +0 -1
- package/dist/lib/utils/array.js +1 -2
- package/dist/lib/utils/entry-point.d.ts +15 -4
- package/dist/lib/utils/entry-point.js +45 -28
- package/dist/lib/utils/enum.d.ts +4 -1
- package/dist/lib/utils/enum.js +2 -3
- package/dist/lib/utils/fs.d.ts +3 -1
- package/dist/lib/utils/fs.js +36 -73
- package/dist/lib/utils/index.d.ts +4 -3
- package/dist/lib/utils/index.js +3 -3
- package/dist/lib/utils/loggers.d.ts +5 -26
- package/dist/lib/utils/loggers.js +38 -42
- package/dist/lib/utils/map.d.ts +17 -0
- package/dist/lib/utils/map.js +49 -1
- package/dist/lib/utils/options/declaration.d.ts +20 -6
- package/dist/lib/utils/options/help.js +1 -1
- package/dist/lib/utils/options/options.d.ts +27 -18
- package/dist/lib/utils/options/options.js +68 -14
- package/dist/lib/utils/options/readers/arguments.d.ts +2 -1
- package/dist/lib/utils/options/readers/arguments.js +9 -2
- package/dist/lib/utils/options/readers/tsconfig.d.ts +3 -7
- package/dist/lib/utils/options/readers/tsconfig.js +35 -36
- package/dist/lib/utils/options/readers/typedoc.d.ts +4 -5
- package/dist/lib/utils/options/readers/typedoc.js +9 -21
- package/dist/lib/utils/options/sources/typedoc.js +18 -64
- package/dist/lib/utils/package-manifest.js +1 -2
- package/dist/lib/utils/paths.js +2 -0
- package/dist/lib/utils/plugins.d.ts +1 -2
- package/dist/lib/utils/plugins.js +22 -106
- package/dist/lib/utils/sort.d.ts +1 -1
- package/dist/lib/utils/sort.js +8 -11
- package/dist/lib/utils/tsconfig.d.ts +4 -0
- package/dist/lib/utils/tsconfig.js +36 -0
- package/dist/lib/utils/tsutils.d.ts +3 -2
- package/dist/lib/utils/tsutils.js +46 -12
- package/dist/lib/validation/documentation.d.ts +1 -1
- package/dist/lib/validation/documentation.js +6 -29
- package/dist/lib/validation/exports.js +18 -21
- package/dist/lib/validation/links.js +1 -1
- package/package.json +18 -19
- package/static/main.js +1 -55
|
@@ -35,5 +35,17 @@ class ReflectionCategory {
|
|
|
35
35
|
: undefined,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
fromObject(de, obj) {
|
|
39
|
+
if (obj.children) {
|
|
40
|
+
de.defer((project) => {
|
|
41
|
+
for (const childId of obj.children || []) {
|
|
42
|
+
const child = project.getReflectionById(de.oldIdToNewId[childId] ?? -1);
|
|
43
|
+
if (child?.isDeclaration()) {
|
|
44
|
+
this.children.push(child);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
exports.ReflectionCategory = ReflectionCategory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReflectionCategory } from "./ReflectionCategory";
|
|
2
2
|
import type { DeclarationReflection } from ".";
|
|
3
|
-
import type { Serializer, JSONOutput } from "../serialization";
|
|
3
|
+
import type { Serializer, JSONOutput, Deserializer } from "../serialization";
|
|
4
4
|
/**
|
|
5
5
|
* A group of reflections. All reflections in a group are of the same kind.
|
|
6
6
|
*
|
|
@@ -32,4 +32,5 @@ export declare class ReflectionGroup {
|
|
|
32
32
|
*/
|
|
33
33
|
allChildrenHaveOwnDocument(): boolean;
|
|
34
34
|
toObject(serializer: Serializer): JSONOutput.ReflectionGroup;
|
|
35
|
+
fromObject(de: Deserializer, obj: JSONOutput.ReflectionGroup): void;
|
|
35
36
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReflectionGroup = void 0;
|
|
4
|
+
const ReflectionCategory_1 = require("./ReflectionCategory");
|
|
4
5
|
/**
|
|
5
6
|
* A group of reflections. All reflections in a group are of the same kind.
|
|
6
7
|
*
|
|
@@ -36,5 +37,24 @@ class ReflectionGroup {
|
|
|
36
37
|
categories: serializer.toObjectsOptional(this.categories),
|
|
37
38
|
};
|
|
38
39
|
}
|
|
40
|
+
fromObject(de, obj) {
|
|
41
|
+
if (obj.categories) {
|
|
42
|
+
this.categories = obj.categories.map((catObj) => {
|
|
43
|
+
const cat = new ReflectionCategory_1.ReflectionCategory(catObj.title);
|
|
44
|
+
de.fromObject(cat, catObj);
|
|
45
|
+
return cat;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (obj.children) {
|
|
49
|
+
de.defer((project) => {
|
|
50
|
+
for (const childId of obj.children || []) {
|
|
51
|
+
const child = project.getReflectionById(de.oldIdToNewId[childId] ?? -1);
|
|
52
|
+
if (child?.isDeclaration()) {
|
|
53
|
+
this.children.push(child);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
39
59
|
}
|
|
40
60
|
exports.ReflectionGroup = ReflectionGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Reflection } from "../reflections";
|
|
2
|
-
import type { Serializer, JSONOutput } from "../../serialization";
|
|
2
|
+
import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
|
|
3
3
|
export type CommentDisplayPart = {
|
|
4
4
|
kind: "text";
|
|
5
5
|
text: string;
|
|
@@ -42,6 +42,7 @@ export declare class CommentTag {
|
|
|
42
42
|
constructor(tag: `@${string}`, text: CommentDisplayPart[]);
|
|
43
43
|
clone(): CommentTag;
|
|
44
44
|
toObject(): JSONOutput.CommentTag;
|
|
45
|
+
fromObject(de: Deserializer, obj: JSONOutput.CommentTag): void;
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* A model that represents a comment.
|
|
@@ -55,12 +56,6 @@ export declare class Comment {
|
|
|
55
56
|
* rendering, but can be useful in tests.
|
|
56
57
|
*/
|
|
57
58
|
static combineDisplayParts(parts: readonly CommentDisplayPart[] | undefined): string;
|
|
58
|
-
/**
|
|
59
|
-
* Helper function to convert an array of comment display parts into markdown suitable for
|
|
60
|
-
* passing into Marked. `urlTo` will be used to resolve urls to any reflections linked to with
|
|
61
|
-
* `@link` tags.
|
|
62
|
-
*/
|
|
63
|
-
static displayPartsToMarkdown(parts: readonly CommentDisplayPart[], urlTo: (ref: Reflection) => string): string;
|
|
64
59
|
/**
|
|
65
60
|
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
|
|
66
61
|
*/
|
|
@@ -76,6 +71,10 @@ export declare class Comment {
|
|
|
76
71
|
text: string;
|
|
77
72
|
target?: string | Reflection | undefined;
|
|
78
73
|
})[];
|
|
74
|
+
static serializeDisplayParts(parts: CommentDisplayPart[]): JSONOutput.CommentDisplayPart[];
|
|
75
|
+
/** @hidden no point in showing this signature in api docs */
|
|
76
|
+
static serializeDisplayParts(parts: CommentDisplayPart[] | undefined): JSONOutput.CommentDisplayPart[] | undefined;
|
|
77
|
+
static deserializeDisplayParts(de: Deserializer, parts: JSONOutput.CommentDisplayPart[]): CommentDisplayPart[];
|
|
79
78
|
/**
|
|
80
79
|
* The content of the comment which is not associated with a block tag.
|
|
81
80
|
*/
|
|
@@ -88,6 +87,11 @@ export declare class Comment {
|
|
|
88
87
|
* All modifier tags present on the comment, e.g. `@alpha`, `@beta`.
|
|
89
88
|
*/
|
|
90
89
|
modifierTags: Set<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
|
|
92
|
+
* Added by the CommentPlugin during resolution.
|
|
93
|
+
*/
|
|
94
|
+
label?: string;
|
|
91
95
|
/**
|
|
92
96
|
* Creates a new Comment instance.
|
|
93
97
|
*/
|
|
@@ -134,4 +138,5 @@ export declare class Comment {
|
|
|
134
138
|
*/
|
|
135
139
|
removeTags(tagName: `@${string}`): void;
|
|
136
140
|
toObject(serializer: Serializer): JSONOutput.Comment;
|
|
141
|
+
fromObject(de: Deserializer, obj: JSONOutput.Comment): void;
|
|
137
142
|
}
|
|
@@ -2,21 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Comment = exports.CommentTag = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
-
function serializeDisplayPart(part) {
|
|
6
|
-
switch (part.kind) {
|
|
7
|
-
case "text":
|
|
8
|
-
case "code":
|
|
9
|
-
return part;
|
|
10
|
-
case "inline-tag": {
|
|
11
|
-
return {
|
|
12
|
-
...part,
|
|
13
|
-
target: typeof part.target === "object"
|
|
14
|
-
? part.target.id
|
|
15
|
-
: part.target,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
5
|
/**
|
|
21
6
|
* A model that represents a single TypeDoc comment tag.
|
|
22
7
|
*
|
|
@@ -41,9 +26,14 @@ class CommentTag {
|
|
|
41
26
|
return {
|
|
42
27
|
tag: this.tag,
|
|
43
28
|
name: this.name,
|
|
44
|
-
content: this.content
|
|
29
|
+
content: Comment.serializeDisplayParts(this.content),
|
|
45
30
|
};
|
|
46
31
|
}
|
|
32
|
+
fromObject(de, obj) {
|
|
33
|
+
// tag already set by Comment.fromObject
|
|
34
|
+
this.name = obj.name;
|
|
35
|
+
this.content = Comment.deserializeDisplayParts(de, obj.content);
|
|
36
|
+
}
|
|
47
37
|
}
|
|
48
38
|
exports.CommentTag = CommentTag;
|
|
49
39
|
/**
|
|
@@ -75,60 +65,64 @@ class Comment {
|
|
|
75
65
|
return result;
|
|
76
66
|
}
|
|
77
67
|
/**
|
|
78
|
-
* Helper
|
|
79
|
-
* passing into Marked. `urlTo` will be used to resolve urls to any reflections linked to with
|
|
80
|
-
* `@link` tags.
|
|
68
|
+
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
|
|
81
69
|
*/
|
|
82
|
-
static
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
static cloneDisplayParts(parts) {
|
|
71
|
+
return parts.map((p) => ({ ...p }));
|
|
72
|
+
}
|
|
73
|
+
static serializeDisplayParts(parts) {
|
|
74
|
+
return parts?.map((part) => {
|
|
85
75
|
switch (part.kind) {
|
|
86
76
|
case "text":
|
|
87
77
|
case "code":
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
default:
|
|
115
|
-
// Hmm... probably want to be able to render these somehow, so custom inline tags can be given
|
|
116
|
-
// special rendering rules. Future capability. For now, just render their text.
|
|
117
|
-
result.push(`{${part.tag} ${part.text}}`);
|
|
118
|
-
break;
|
|
78
|
+
return { ...part };
|
|
79
|
+
case "inline-tag": {
|
|
80
|
+
return {
|
|
81
|
+
...part,
|
|
82
|
+
target: typeof part.target === "object"
|
|
83
|
+
? part.target.id
|
|
84
|
+
: part.target,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//Since display parts are plain objects, this lives here
|
|
91
|
+
static deserializeDisplayParts(de, parts) {
|
|
92
|
+
const links = [];
|
|
93
|
+
const result = parts.map((part) => {
|
|
94
|
+
switch (part.kind) {
|
|
95
|
+
case "text":
|
|
96
|
+
case "code":
|
|
97
|
+
return { ...part };
|
|
98
|
+
case "inline-tag": {
|
|
99
|
+
if (typeof part.target !== "number") {
|
|
100
|
+
// TS isn't quite smart enough here...
|
|
101
|
+
return { ...part };
|
|
119
102
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
else {
|
|
104
|
+
const part2 = {
|
|
105
|
+
kind: part.kind,
|
|
106
|
+
tag: part.tag,
|
|
107
|
+
text: part.text,
|
|
108
|
+
};
|
|
109
|
+
links.push([part.target, part2]);
|
|
110
|
+
return part2;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
123
113
|
}
|
|
114
|
+
});
|
|
115
|
+
if (links.length) {
|
|
116
|
+
de.defer((project) => {
|
|
117
|
+
for (const [oldId, part] of links) {
|
|
118
|
+
part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1);
|
|
119
|
+
if (!part.target) {
|
|
120
|
+
de.logger.warn(`Serialized project contained a link to ${oldId} (${part.text}), which was not a part of the project.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
124
|
}
|
|
125
|
-
return result
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
|
|
129
|
-
*/
|
|
130
|
-
static cloneDisplayParts(parts) {
|
|
131
|
-
return parts.map((p) => ({ ...p }));
|
|
125
|
+
return result;
|
|
132
126
|
}
|
|
133
127
|
/**
|
|
134
128
|
* Creates a new Comment instance.
|
|
@@ -145,6 +139,7 @@ class Comment {
|
|
|
145
139
|
this.summary = summary;
|
|
146
140
|
this.blockTags = blockTags;
|
|
147
141
|
this.modifierTags = modifierTags;
|
|
142
|
+
extractLabelTag(this);
|
|
148
143
|
}
|
|
149
144
|
/**
|
|
150
145
|
* Create a deep clone of this comment.
|
|
@@ -208,12 +203,30 @@ class Comment {
|
|
|
208
203
|
}
|
|
209
204
|
toObject(serializer) {
|
|
210
205
|
return {
|
|
211
|
-
summary: this.summary
|
|
206
|
+
summary: Comment.serializeDisplayParts(this.summary),
|
|
212
207
|
blockTags: serializer.toObjectsOptional(this.blockTags),
|
|
213
208
|
modifierTags: this.modifierTags.size > 0
|
|
214
209
|
? Array.from(this.modifierTags)
|
|
215
210
|
: undefined,
|
|
211
|
+
label: this.label,
|
|
216
212
|
};
|
|
217
213
|
}
|
|
214
|
+
fromObject(de, obj) {
|
|
215
|
+
this.summary = Comment.deserializeDisplayParts(de, obj.summary);
|
|
216
|
+
this.blockTags =
|
|
217
|
+
obj.blockTags?.map((tagObj) => {
|
|
218
|
+
const tag = new CommentTag(tagObj.tag, []);
|
|
219
|
+
de.fromObject(tag, tagObj);
|
|
220
|
+
return tag;
|
|
221
|
+
}) || [];
|
|
222
|
+
this.modifierTags = new Set(obj.modifierTags);
|
|
223
|
+
this.label = obj.label;
|
|
224
|
+
}
|
|
218
225
|
}
|
|
219
226
|
exports.Comment = Comment;
|
|
227
|
+
function extractLabelTag(comment) {
|
|
228
|
+
const index = comment.summary.findIndex((part) => part.kind === "inline-tag" && part.tag === "@label");
|
|
229
|
+
if (index !== -1) {
|
|
230
|
+
comment.label = comment.summary.splice(index, 1)[0].text;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { JSONOutput, Serializer } from "../../serialization/index";
|
|
3
|
+
/**
|
|
4
|
+
* See {@link ReflectionSymbolId}
|
|
5
|
+
*/
|
|
6
|
+
export type ReflectionSymbolIdString = string & {
|
|
7
|
+
readonly __reflectionSymbolId: unique symbol;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* This exists so that TypeDoc can store a unique identifier for a `ts.Symbol` without
|
|
11
|
+
* keeping a reference to the `ts.Symbol` itself. This identifier should be stable across
|
|
12
|
+
* runs so long as the symbol is exported from the same file.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ReflectionSymbolId {
|
|
15
|
+
readonly fileName: string;
|
|
16
|
+
readonly qualifiedName: string;
|
|
17
|
+
/**
|
|
18
|
+
* Note: This is **not** serialized. It exists for sorting by declaration order, but
|
|
19
|
+
* should not be needed when deserializing from JSON.
|
|
20
|
+
*/
|
|
21
|
+
pos: number;
|
|
22
|
+
constructor(symbol: ts.Symbol, declaration?: ts.Declaration);
|
|
23
|
+
constructor(json: JSONOutput.ReflectionSymbolId);
|
|
24
|
+
getStableKey(): ReflectionSymbolIdString;
|
|
25
|
+
toObject(serializer: Serializer): {
|
|
26
|
+
sourceFileName: string;
|
|
27
|
+
qualifiedName: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReflectionSymbolId = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
+
const fs_2 = require("../../utils/fs");
|
|
11
|
+
const tsutils_1 = require("../../utils/tsutils");
|
|
12
|
+
const validation_1 = require("../../utils/validation");
|
|
13
|
+
/**
|
|
14
|
+
* This exists so that TypeDoc can store a unique identifier for a `ts.Symbol` without
|
|
15
|
+
* keeping a reference to the `ts.Symbol` itself. This identifier should be stable across
|
|
16
|
+
* runs so long as the symbol is exported from the same file.
|
|
17
|
+
*/
|
|
18
|
+
class ReflectionSymbolId {
|
|
19
|
+
constructor(symbol, declaration) {
|
|
20
|
+
if ("name" in symbol) {
|
|
21
|
+
declaration ?? (declaration = symbol?.declarations?.[0]);
|
|
22
|
+
this.fileName = declaration?.getSourceFile().fileName ?? "\0";
|
|
23
|
+
if (symbol.declarations?.some(typescript_1.default.isSourceFile)) {
|
|
24
|
+
this.qualifiedName = "";
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.qualifiedName = (0, tsutils_1.getQualifiedName)(symbol, symbol.name);
|
|
28
|
+
}
|
|
29
|
+
this.pos = declaration?.pos ?? Infinity;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.fileName = symbol.sourceFileName;
|
|
33
|
+
this.qualifiedName = symbol.qualifiedName;
|
|
34
|
+
this.pos = Infinity;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
getStableKey() {
|
|
38
|
+
if (Number.isFinite(this.pos)) {
|
|
39
|
+
return `${this.fileName}\0${this.qualifiedName}\0${this.pos}`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return `${this.fileName}\0${this.qualifiedName}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
toObject(serializer) {
|
|
46
|
+
return {
|
|
47
|
+
sourceFileName: (0, path_1.isAbsolute)(this.fileName)
|
|
48
|
+
? (0, path_1.relative)(serializer.projectRoot, resolveDeclarationMaps(this.fileName))
|
|
49
|
+
: this.fileName,
|
|
50
|
+
qualifiedName: this.qualifiedName,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.ReflectionSymbolId = ReflectionSymbolId;
|
|
55
|
+
const declarationMapCache = new Map();
|
|
56
|
+
/**
|
|
57
|
+
* See also getTsSourceFromJsSource in package-manifest.ts.
|
|
58
|
+
*/
|
|
59
|
+
function resolveDeclarationMaps(file) {
|
|
60
|
+
if (!file.endsWith(".d.ts"))
|
|
61
|
+
return file;
|
|
62
|
+
if (declarationMapCache.has(file))
|
|
63
|
+
return declarationMapCache.get(file);
|
|
64
|
+
const mapFile = file + ".map";
|
|
65
|
+
if (!(0, fs_1.existsSync)(mapFile))
|
|
66
|
+
return file;
|
|
67
|
+
let sourceMap;
|
|
68
|
+
try {
|
|
69
|
+
sourceMap = JSON.parse((0, fs_2.readFile)(mapFile));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return file;
|
|
73
|
+
}
|
|
74
|
+
if ((0, validation_1.validate)({
|
|
75
|
+
file: String,
|
|
76
|
+
sourceRoot: (0, validation_1.optional)(String),
|
|
77
|
+
sources: [Array, String],
|
|
78
|
+
}, sourceMap)) {
|
|
79
|
+
// There's a pretty large assumption in here that we only have
|
|
80
|
+
// 1 source file per js file. This is a pretty standard typescript approach,
|
|
81
|
+
// but people might do interesting things with transpilation that could break this.
|
|
82
|
+
let source = sourceMap.sources[0];
|
|
83
|
+
// If we have a sourceRoot, trim any leading slash from the source, and join them
|
|
84
|
+
// Similar to how it's done at https://github.com/mozilla/source-map/blob/58819f09018d56ef84dc41ba9c93f554e0645169/lib/util.js#L412
|
|
85
|
+
if (sourceMap.sourceRoot !== undefined) {
|
|
86
|
+
source = source.replace(/^\//, "");
|
|
87
|
+
source = (0, path_1.join)(sourceMap.sourceRoot, source);
|
|
88
|
+
}
|
|
89
|
+
const result = (0, path_1.resolve)(mapFile, "..", source);
|
|
90
|
+
declarationMapCache.set(file, result);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
return file;
|
|
94
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Comment } from "../comments/comment";
|
|
1
|
+
import { Comment } from "../comments/comment";
|
|
3
2
|
import type { ProjectReflection } from "./project";
|
|
4
3
|
import type { NeverIfInternal } from "../../utils";
|
|
5
4
|
import { ReflectionKind } from "./kind";
|
|
6
|
-
import type { Serializer, JSONOutput } from "../../serialization";
|
|
5
|
+
import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
|
|
6
|
+
import type { ReflectionVariant } from "./variant";
|
|
7
|
+
import type { DeclarationReflection } from "./declaration";
|
|
7
8
|
/**
|
|
8
9
|
* Reset the reflection id.
|
|
9
10
|
*
|
|
@@ -70,6 +71,7 @@ export declare class ReflectionFlags extends Array<string> {
|
|
|
70
71
|
private setSingleFlag;
|
|
71
72
|
private static serializedFlags;
|
|
72
73
|
toObject(): JSONOutput.ReflectionFlags;
|
|
74
|
+
fromObject(obj: JSONOutput.ReflectionFlags): void;
|
|
73
75
|
}
|
|
74
76
|
export declare enum TraverseProperty {
|
|
75
77
|
Children = 0,
|
|
@@ -100,6 +102,10 @@ export interface TraverseCallback {
|
|
|
100
102
|
* contains a list of all children grouped and sorted for rendering.
|
|
101
103
|
*/
|
|
102
104
|
export declare abstract class Reflection {
|
|
105
|
+
/**
|
|
106
|
+
* Discriminator representing the type of reflection represented by this object.
|
|
107
|
+
*/
|
|
108
|
+
abstract readonly variant: keyof ReflectionVariant;
|
|
103
109
|
/**
|
|
104
110
|
* Unique id of this reflection.
|
|
105
111
|
*/
|
|
@@ -108,24 +114,10 @@ export declare abstract class Reflection {
|
|
|
108
114
|
* The symbol name of this reflection.
|
|
109
115
|
*/
|
|
110
116
|
name: string;
|
|
111
|
-
/**
|
|
112
|
-
* The original name of the TypeScript declaration.
|
|
113
|
-
*/
|
|
114
|
-
originalName: string;
|
|
115
|
-
/**
|
|
116
|
-
* Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
|
|
117
|
-
* Added by the CommentPlugin during resolution.
|
|
118
|
-
*/
|
|
119
|
-
label?: string;
|
|
120
117
|
/**
|
|
121
118
|
* The kind of this reflection.
|
|
122
119
|
*/
|
|
123
120
|
kind: ReflectionKind;
|
|
124
|
-
/**
|
|
125
|
-
* The human readable string representation of the kind of this reflection.
|
|
126
|
-
* Set during the resolution phase by GroupPlugin
|
|
127
|
-
*/
|
|
128
|
-
kindString?: string;
|
|
129
121
|
flags: ReflectionFlags;
|
|
130
122
|
/**
|
|
131
123
|
* The reflection this reflection is a child of.
|
|
@@ -136,10 +128,6 @@ export declare abstract class Reflection {
|
|
|
136
128
|
* The parsed documentation comment attached to this reflection.
|
|
137
129
|
*/
|
|
138
130
|
comment?: Comment;
|
|
139
|
-
/**
|
|
140
|
-
* A list of all source files that contributed to this reflection.
|
|
141
|
-
*/
|
|
142
|
-
sources?: SourceReference[];
|
|
143
131
|
/**
|
|
144
132
|
* The url of this reflection in the generated documentation.
|
|
145
133
|
* TODO: Reflections shouldn't know urls exist. Move this to a serializer.
|
|
@@ -157,12 +145,6 @@ export declare abstract class Reflection {
|
|
|
157
145
|
* TODO: Reflections shouldn't know how they are rendered. Move this to the correct serializer.
|
|
158
146
|
*/
|
|
159
147
|
hasOwnDocument?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* A list of generated css classes that should be applied to representations of this
|
|
162
|
-
* reflection in the generated markup.
|
|
163
|
-
* TODO: Reflections shouldn't know about CSS. Move this property to the correct serializer.
|
|
164
|
-
*/
|
|
165
|
-
cssClasses?: string;
|
|
166
148
|
/**
|
|
167
149
|
* Url safe alias for this reflection.
|
|
168
150
|
*
|
|
@@ -216,19 +198,11 @@ export declare abstract class Reflection {
|
|
|
216
198
|
* Return whether this reflection is the root / project reflection.
|
|
217
199
|
*/
|
|
218
200
|
isProject(): this is ProjectReflection;
|
|
201
|
+
isDeclaration(): this is DeclarationReflection;
|
|
219
202
|
/**
|
|
220
|
-
* Check if this reflection
|
|
203
|
+
* Check if this reflection or any of its parents have been marked with the `@deprecated` tag.
|
|
221
204
|
*/
|
|
222
205
|
isDeprecated(): boolean;
|
|
223
|
-
/**
|
|
224
|
-
* Try to find a reflection by its name.
|
|
225
|
-
*
|
|
226
|
-
* @return The found reflection or null.
|
|
227
|
-
* @deprecated This method not be used, it naively splits the name by a `.` and searches recursively up
|
|
228
|
-
* the parent tree, which is not how any other name resolver works. If you are currently using this and
|
|
229
|
-
* need another method, please open an issue. For tests {@link getChildByName} should generally be sufficient.
|
|
230
|
-
*/
|
|
231
|
-
findReflectionByName(arg: string | string[]): Reflection | undefined;
|
|
232
206
|
/**
|
|
233
207
|
* Traverse all potential child reflections of this reflection.
|
|
234
208
|
*
|
|
@@ -249,4 +223,5 @@ export declare abstract class Reflection {
|
|
|
249
223
|
*/
|
|
250
224
|
toStringHierarchy(indent?: string): string;
|
|
251
225
|
toObject(serializer: Serializer): JSONOutput.Reflection;
|
|
226
|
+
fromObject(de: Deserializer, obj: JSONOutput.Reflection): void;
|
|
252
227
|
}
|
|
@@ -2,19 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Reflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.resetReflectionID = void 0;
|
|
4
4
|
const assert_1 = require("assert");
|
|
5
|
+
const comment_1 = require("../comments/comment");
|
|
5
6
|
const utils_1 = require("./utils");
|
|
6
7
|
const kind_1 = require("./kind");
|
|
7
|
-
/**
|
|
8
|
-
* Holds all data models used by TypeDoc.
|
|
9
|
-
*
|
|
10
|
-
* The {@link BaseReflection} is base class of all reflection models. The subclass {@link ProjectReflection}
|
|
11
|
-
* serves as the root container for the current project while {@link DeclarationReflection} instances
|
|
12
|
-
* form the structure of the project. Most of the other classes in this namespace are referenced by this
|
|
13
|
-
* two base classes.
|
|
14
|
-
*
|
|
15
|
-
* The models {@link NavigationItem} and {@link UrlMapping} are special as they are only used by the {@link Renderer}
|
|
16
|
-
* while creating the final output.
|
|
17
|
-
*/
|
|
18
8
|
/**
|
|
19
9
|
* Current reflection id.
|
|
20
10
|
*/
|
|
@@ -171,6 +161,14 @@ class ReflectionFlags extends Array {
|
|
|
171
161
|
.filter((flag) => this[flag])
|
|
172
162
|
.map((flag) => [flag, true]));
|
|
173
163
|
}
|
|
164
|
+
fromObject(obj) {
|
|
165
|
+
for (const key of Object.keys(obj)) {
|
|
166
|
+
const flagName = key.substring(2); // isPublic => Public
|
|
167
|
+
if (flagName in ReflectionFlag) {
|
|
168
|
+
this.setFlag(ReflectionFlag[flagName], true);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
exports.ReflectionFlags = ReflectionFlags;
|
|
176
174
|
ReflectionFlags.serializedFlags = [
|
|
@@ -220,7 +218,6 @@ class Reflection {
|
|
|
220
218
|
this.id = REFLECTION_ID++;
|
|
221
219
|
this.parent = parent;
|
|
222
220
|
this.name = name;
|
|
223
|
-
this.originalName = name;
|
|
224
221
|
this.kind = kind;
|
|
225
222
|
// If our parent is external, we are too.
|
|
226
223
|
if (parent?.flags.isExternal) {
|
|
@@ -349,8 +346,11 @@ class Reflection {
|
|
|
349
346
|
isProject() {
|
|
350
347
|
return false;
|
|
351
348
|
}
|
|
349
|
+
isDeclaration() {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
352
|
/**
|
|
353
|
-
* Check if this reflection
|
|
353
|
+
* Check if this reflection or any of its parents have been marked with the `@deprecated` tag.
|
|
354
354
|
*/
|
|
355
355
|
isDeprecated() {
|
|
356
356
|
if (this.comment?.getTag("@deprecated")) {
|
|
@@ -358,26 +358,6 @@ class Reflection {
|
|
|
358
358
|
}
|
|
359
359
|
return this.parent?.isDeprecated() ?? false;
|
|
360
360
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Try to find a reflection by its name.
|
|
363
|
-
*
|
|
364
|
-
* @return The found reflection or null.
|
|
365
|
-
* @deprecated This method not be used, it naively splits the name by a `.` and searches recursively up
|
|
366
|
-
* the parent tree, which is not how any other name resolver works. If you are currently using this and
|
|
367
|
-
* need another method, please open an issue. For tests {@link getChildByName} should generally be sufficient.
|
|
368
|
-
*/
|
|
369
|
-
findReflectionByName(arg) {
|
|
370
|
-
const names = Array.isArray(arg)
|
|
371
|
-
? arg
|
|
372
|
-
: (0, utils_1.splitUnquotedString)(arg, ".");
|
|
373
|
-
const reflection = this.getChildByName(names);
|
|
374
|
-
if (reflection) {
|
|
375
|
-
return reflection;
|
|
376
|
-
}
|
|
377
|
-
else if (this.parent) {
|
|
378
|
-
return this.parent.findReflectionByName(names);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
361
|
/**
|
|
382
362
|
* Traverse all potential child reflections of this reflection.
|
|
383
363
|
*
|
|
@@ -413,14 +393,26 @@ class Reflection {
|
|
|
413
393
|
return {
|
|
414
394
|
id: this.id,
|
|
415
395
|
name: this.name,
|
|
396
|
+
variant: this.variant,
|
|
416
397
|
kind: this.kind,
|
|
417
|
-
kindString: this.kindString,
|
|
418
398
|
flags: this.flags.toObject(),
|
|
419
399
|
comment: this.comment && !this.comment.isEmpty()
|
|
420
400
|
? serializer.toObject(this.comment)
|
|
421
401
|
: undefined,
|
|
422
|
-
originalName: this.originalName !== this.name ? this.originalName : undefined,
|
|
423
402
|
};
|
|
424
403
|
}
|
|
404
|
+
fromObject(de, obj) {
|
|
405
|
+
// DO NOT copy id from obj. When deserializing reflections
|
|
406
|
+
// they should be given new ids since they belong to a different project.
|
|
407
|
+
this.name = obj.name;
|
|
408
|
+
// Skip copying variant, we know it's already the correct value because the deserializer
|
|
409
|
+
// will construct the correct class type.
|
|
410
|
+
this.kind = obj.kind;
|
|
411
|
+
this.flags.fromObject(obj.flags);
|
|
412
|
+
// Parent is set during construction, so we don't need to do it here.
|
|
413
|
+
this.comment = de.revive(obj.comment, () => new comment_1.Comment());
|
|
414
|
+
// url, anchor, hasOwnDocument, _alias, _aliases are set during rendering and only relevant during render.
|
|
415
|
+
// It doesn't make sense to serialize them to json, or restore them.
|
|
416
|
+
}
|
|
425
417
|
}
|
|
426
418
|
exports.Reflection = Reflection;
|