typedoc 0.26.0-beta.1 → 0.26.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/lib/application.d.ts +2 -0
- package/dist/lib/application.js +7 -3
- package/dist/lib/converter/comments/declarationReference.d.ts +1 -0
- package/dist/lib/converter/comments/declarationReference.js +14 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.js +4 -2
- package/dist/lib/converter/comments/discovery.js +10 -2
- package/dist/lib/converter/comments/index.d.ts +6 -5
- package/dist/lib/converter/comments/index.js +21 -21
- package/dist/lib/converter/comments/parser.d.ts +3 -2
- package/dist/lib/converter/comments/parser.js +26 -17
- package/dist/lib/converter/comments/textParser.d.ts +19 -0
- package/dist/lib/converter/comments/textParser.js +154 -0
- package/dist/lib/converter/context.js +14 -7
- package/dist/lib/converter/converter.d.ts +3 -2
- package/dist/lib/converter/converter.js +11 -10
- package/dist/lib/converter/plugins/CategoryPlugin.js +3 -5
- package/dist/lib/converter/plugins/CommentPlugin.js +20 -0
- package/dist/lib/converter/plugins/PackagePlugin.js +1 -1
- package/dist/lib/converter/symbols.js +5 -7
- package/dist/lib/converter/types.js +11 -3
- package/dist/lib/internationalization/internationalization.js +2 -2
- package/dist/lib/internationalization/locales/ko.cjs +79 -0
- package/dist/lib/internationalization/locales/ko.d.cts +78 -0
- package/dist/lib/internationalization/translatable.d.ts +6 -1
- package/dist/lib/internationalization/translatable.js +6 -1
- package/dist/lib/models/FileRegistry.d.ts +26 -0
- package/dist/lib/models/FileRegistry.js +136 -0
- package/dist/lib/models/comments/comment.d.ts +30 -8
- package/dist/lib/models/comments/comment.js +26 -71
- package/dist/lib/models/comments/index.d.ts +1 -1
- package/dist/lib/models/index.d.ts +1 -0
- package/dist/lib/models/index.js +1 -0
- package/dist/lib/models/reflections/ReflectionSymbolId.js +1 -1
- package/dist/lib/models/reflections/abstract.js +1 -1
- package/dist/lib/models/reflections/project.d.ts +7 -2
- package/dist/lib/models/reflections/project.js +51 -40
- package/dist/lib/models/reflections/signature.js +2 -0
- package/dist/lib/models/types.js +2 -2
- package/dist/lib/output/plugins/AssetsPlugin.js +5 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +2 -2
- package/dist/lib/output/plugins/NavigationPlugin.js +1 -1
- package/dist/lib/output/plugins/SitemapPlugin.js +1 -1
- package/dist/lib/output/renderer.d.ts +8 -14
- package/dist/lib/output/renderer.js +17 -12
- package/dist/lib/output/theme.d.ts +0 -7
- package/dist/lib/output/theme.js +0 -8
- package/dist/lib/output/themes/MarkedPlugin.d.ts +1 -0
- package/dist/lib/output/themes/MarkedPlugin.js +83 -1
- package/dist/lib/output/themes/default/DefaultTheme.js +2 -2
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +1 -0
- package/dist/lib/output/themes/default/partials/footer.js +1 -1
- package/dist/lib/output/themes/default/partials/typeAndParent.js +2 -4
- package/dist/lib/output/themes/default/partials/typeParameters.js +1 -1
- package/dist/lib/serialization/deserializer.d.ts +8 -2
- package/dist/lib/serialization/deserializer.js +17 -8
- package/dist/lib/serialization/schema.d.ts +27 -3
- package/dist/lib/utils/array.js +1 -1
- package/dist/lib/utils/component.js +3 -0
- package/dist/lib/utils/entry-point.js +1 -1
- package/dist/lib/utils/events.d.ts +1 -1
- package/dist/lib/utils/events.js +2 -1
- package/dist/lib/utils/highlighter.d.ts +4 -2
- package/dist/lib/utils/highlighter.js +16 -5
- package/dist/lib/utils/html.js +1 -0
- package/dist/lib/utils/loggers.d.ts +0 -4
- package/dist/lib/utils/loggers.js +1 -7
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/help.js +2 -1
- package/dist/lib/utils/options/options.js +8 -6
- package/dist/lib/utils/options/readers/typedoc.js +0 -1
- package/dist/lib/utils/options/sources/typedoc.js +24 -0
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +2 -2
- package/dist/lib/utils/options/tsdoc-defaults.js +2 -0
- package/dist/lib/utils/plugins.js +0 -1
- package/dist/lib/utils/set.d.ts +2 -1
- package/dist/lib/utils/set.js +8 -0
- package/package.json +8 -9
- package/tsdoc.json +8 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidatingFileRegistry = exports.FileRegistry = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
class FileRegistry {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.nextId = 1;
|
|
10
|
+
// The combination of thest two make up the registry
|
|
11
|
+
this.mediaToReflection = new Map();
|
|
12
|
+
this.mediaToPath = new Map();
|
|
13
|
+
this.reflectionToPath = new Map();
|
|
14
|
+
this.pathToMedia = new Map();
|
|
15
|
+
// Lazily created as we get names for rendering
|
|
16
|
+
this.names = new Map();
|
|
17
|
+
this.nameUsage = new Map();
|
|
18
|
+
}
|
|
19
|
+
registerAbsolute(absolute) {
|
|
20
|
+
absolute = (0, utils_1.normalizePath)(absolute);
|
|
21
|
+
const existing = this.pathToMedia.get(absolute);
|
|
22
|
+
if (existing) {
|
|
23
|
+
return existing;
|
|
24
|
+
}
|
|
25
|
+
this.mediaToPath.set(this.nextId, absolute);
|
|
26
|
+
this.pathToMedia.set(absolute, this.nextId);
|
|
27
|
+
return this.nextId++;
|
|
28
|
+
}
|
|
29
|
+
/** Called by {@link ProjectReflection.registerReflection} @internal*/
|
|
30
|
+
registerReflection(absolute, reflection) {
|
|
31
|
+
absolute = (0, utils_1.normalizePath)(absolute);
|
|
32
|
+
const id = this.registerAbsolute(absolute);
|
|
33
|
+
this.reflectionToPath.set(reflection, absolute);
|
|
34
|
+
this.mediaToReflection.set(id, reflection);
|
|
35
|
+
}
|
|
36
|
+
register(sourcePath, relativePath) {
|
|
37
|
+
return this.registerAbsolute((0, path_1.resolve)((0, path_1.dirname)(sourcePath), relativePath));
|
|
38
|
+
}
|
|
39
|
+
removeReflection(reflection) {
|
|
40
|
+
const absolute = this.reflectionToPath.get(reflection);
|
|
41
|
+
if (absolute) {
|
|
42
|
+
const media = this.pathToMedia.get(absolute);
|
|
43
|
+
this.mediaToReflection.delete(media);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
resolve(id) {
|
|
47
|
+
return this.mediaToReflection.get(id) ?? this.mediaToPath.get(id);
|
|
48
|
+
}
|
|
49
|
+
getName(id) {
|
|
50
|
+
const absolute = this.mediaToPath.get(id);
|
|
51
|
+
if (!absolute)
|
|
52
|
+
return;
|
|
53
|
+
const file = (0, path_1.basename)(absolute);
|
|
54
|
+
if (!this.nameUsage.has(file)) {
|
|
55
|
+
this.nameUsage.set(file, 1);
|
|
56
|
+
this.names.set(id, file);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const { name, ext } = (0, path_1.parse)(file);
|
|
60
|
+
let counter = this.nameUsage.get(file);
|
|
61
|
+
while (this.nameUsage.has(`${name}-${counter}${ext}`)) {
|
|
62
|
+
++counter;
|
|
63
|
+
}
|
|
64
|
+
this.nameUsage.set(file, counter + 1);
|
|
65
|
+
this.nameUsage.set(`${name}-${counter}${ext}`, counter + 1);
|
|
66
|
+
this.names.set(id, `${name}-${counter}${ext}`);
|
|
67
|
+
}
|
|
68
|
+
return this.names.get(id);
|
|
69
|
+
}
|
|
70
|
+
getNameToAbsoluteMap() {
|
|
71
|
+
const result = new Map();
|
|
72
|
+
for (const [id, name] of this.names.entries()) {
|
|
73
|
+
result.set(name, this.mediaToPath.get(id));
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
toObject(ser) {
|
|
78
|
+
const result = {
|
|
79
|
+
entries: {},
|
|
80
|
+
reflections: {},
|
|
81
|
+
};
|
|
82
|
+
for (const [key, val] of this.mediaToPath.entries()) {
|
|
83
|
+
result.entries[key] = (0, utils_1.normalizePath)((0, path_1.relative)(ser.projectRoot, val));
|
|
84
|
+
}
|
|
85
|
+
for (const [key, val] of this.mediaToReflection.entries()) {
|
|
86
|
+
result.reflections[key] = val.id;
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
fromObject(de, obj) {
|
|
91
|
+
for (const [key, val] of Object.entries(obj.entries)) {
|
|
92
|
+
const absolute = (0, utils_1.normalizePath)((0, path_1.resolve)(de.projectRoot, val));
|
|
93
|
+
de.oldFileIdToNewFileId[+key] = this.registerAbsolute(absolute);
|
|
94
|
+
}
|
|
95
|
+
de.defer((project) => {
|
|
96
|
+
for (const [media, reflId] of Object.entries(obj.reflections)) {
|
|
97
|
+
const refl = project.getReflectionById(de.oldIdToNewId[reflId]);
|
|
98
|
+
if (refl) {
|
|
99
|
+
this.mediaToReflection.set(de.oldFileIdToNewFileId[+media], refl);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.FileRegistry = FileRegistry;
|
|
106
|
+
class ValidatingFileRegistry extends FileRegistry {
|
|
107
|
+
register(sourcePath, relativePath) {
|
|
108
|
+
const absolute = (0, path_1.resolve)((0, path_1.dirname)(sourcePath), relativePath);
|
|
109
|
+
if (!(0, fs_1.existsSync)(absolute)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
return this.registerAbsolute(absolute);
|
|
113
|
+
}
|
|
114
|
+
fromObject(de, obj) {
|
|
115
|
+
for (const [key, val] of Object.entries(obj.entries)) {
|
|
116
|
+
const absolute = (0, utils_1.normalizePath)((0, path_1.resolve)(de.projectRoot, val));
|
|
117
|
+
if (!(0, fs_1.existsSync)(absolute)) {
|
|
118
|
+
de.logger.warn(de.logger.i18n.saved_relative_path_0_resolved_from_1_does_not_exist(val, de.projectRoot));
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
de.oldFileIdToNewFileId[+key] = this.registerAbsolute(absolute);
|
|
122
|
+
}
|
|
123
|
+
de.defer((project) => {
|
|
124
|
+
for (const [media, reflId] of Object.entries(obj.reflections)) {
|
|
125
|
+
const refl = project.getReflectionById(de.oldIdToNewId[reflId]);
|
|
126
|
+
if (refl) {
|
|
127
|
+
this.mediaToReflection.set(de.oldFileIdToNewFileId[+media], refl);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
de.logger.warn(de.logger.i18n.serialized_project_referenced_0_not_part_of_project(reflId.toString()));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.ValidatingFileRegistry = ValidatingFileRegistry;
|
|
@@ -11,7 +11,7 @@ export type CommentDisplayPart = {
|
|
|
11
11
|
} | {
|
|
12
12
|
kind: "code";
|
|
13
13
|
text: string;
|
|
14
|
-
} | InlineTagDisplayPart;
|
|
14
|
+
} | InlineTagDisplayPart | RelativeLinkDisplayPart;
|
|
15
15
|
/**
|
|
16
16
|
* The `@link`, `@linkcode`, and `@linkplain` tags may have a `target`
|
|
17
17
|
* property set indicating which reflection/url they link to. They may also
|
|
@@ -26,6 +26,23 @@ export interface InlineTagDisplayPart {
|
|
|
26
26
|
target?: Reflection | string | ReflectionSymbolId;
|
|
27
27
|
tsLinkText?: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* This is used for relative links within comments/documents.
|
|
31
|
+
* It is used to mark pieces of text which need to be replaced
|
|
32
|
+
* to make links work properly.
|
|
33
|
+
*/
|
|
34
|
+
export interface RelativeLinkDisplayPart {
|
|
35
|
+
kind: "relative-link";
|
|
36
|
+
/**
|
|
37
|
+
* The original relative text from the parsed comment.
|
|
38
|
+
*/
|
|
39
|
+
text: string;
|
|
40
|
+
/**
|
|
41
|
+
* A link to either some document outside of the project or a reflection.
|
|
42
|
+
* This may be `undefined` if the relative path does not exist.
|
|
43
|
+
*/
|
|
44
|
+
target: number | undefined;
|
|
45
|
+
}
|
|
29
46
|
/**
|
|
30
47
|
* A model that represents a single TypeDoc comment tag.
|
|
31
48
|
*
|
|
@@ -67,13 +84,6 @@ export declare class Comment {
|
|
|
67
84
|
* rendering, but can be useful in tests.
|
|
68
85
|
*/
|
|
69
86
|
static combineDisplayParts(parts: readonly CommentDisplayPart[] | undefined): string;
|
|
70
|
-
/**
|
|
71
|
-
* Helper function to convert an array of comment display parts into markdown suitable for
|
|
72
|
-
* passing into markdown-it.
|
|
73
|
-
* @param urlTo - Used to resolve urls to any reflections linked to with `@link` tags..
|
|
74
|
-
* @param useHtml - If set, will produce `<a>` links which can be colored according to the reflection type they are pointed at.
|
|
75
|
-
*/
|
|
76
|
-
static displayPartsToMarkdown(parts: readonly CommentDisplayPart[], urlTo: (ref: Reflection) => string, useHtml: boolean): string;
|
|
77
87
|
/**
|
|
78
88
|
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
|
|
79
89
|
*/
|
|
@@ -89,6 +99,17 @@ export declare class Comment {
|
|
|
89
99
|
text: string;
|
|
90
100
|
target?: string | Reflection | ReflectionSymbolId | undefined;
|
|
91
101
|
tsLinkText?: string | undefined;
|
|
102
|
+
} | {
|
|
103
|
+
kind: "relative-link";
|
|
104
|
+
/**
|
|
105
|
+
* The original relative text from the parsed comment.
|
|
106
|
+
*/
|
|
107
|
+
text: string;
|
|
108
|
+
/**
|
|
109
|
+
* A link to either some document outside of the project or a reflection.
|
|
110
|
+
* This may be `undefined` if the relative path does not exist.
|
|
111
|
+
*/
|
|
112
|
+
target: number | undefined;
|
|
92
113
|
})[];
|
|
93
114
|
static serializeDisplayParts(serializer: Serializer, parts: CommentDisplayPart[]): JSONOutput.CommentDisplayPart[];
|
|
94
115
|
/** @hidden no point in showing this signature in api docs */
|
|
@@ -129,6 +150,7 @@ export declare class Comment {
|
|
|
129
150
|
/**
|
|
130
151
|
* Internal discovery ID used to prevent symbol comments from
|
|
131
152
|
* being duplicated on signatures. Only set when the comment was created
|
|
153
|
+
* from a `ts.CommentRange`.
|
|
132
154
|
* @internal
|
|
133
155
|
*/
|
|
134
156
|
discoveryId?: number;
|
|
@@ -36,7 +36,6 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.Comment = exports.CommentTag = void 0;
|
|
38
38
|
const utils_1 = require("../../utils");
|
|
39
|
-
const kind_1 = require("../reflections/kind");
|
|
40
39
|
const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
|
|
41
40
|
const general_1 = require("../../utils/general");
|
|
42
41
|
/**
|
|
@@ -100,6 +99,7 @@ let Comment = (() => {
|
|
|
100
99
|
switch (item.kind) {
|
|
101
100
|
case "text":
|
|
102
101
|
case "code":
|
|
102
|
+
case "relative-link":
|
|
103
103
|
result += item.text;
|
|
104
104
|
break;
|
|
105
105
|
case "inline-tag":
|
|
@@ -111,75 +111,6 @@ let Comment = (() => {
|
|
|
111
111
|
}
|
|
112
112
|
return result;
|
|
113
113
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Helper function to convert an array of comment display parts into markdown suitable for
|
|
116
|
-
* passing into markdown-it.
|
|
117
|
-
* @param urlTo - Used to resolve urls to any reflections linked to with `@link` tags..
|
|
118
|
-
* @param useHtml - If set, will produce `<a>` links which can be colored according to the reflection type they are pointed at.
|
|
119
|
-
*/
|
|
120
|
-
static displayPartsToMarkdown(parts, urlTo, useHtml) {
|
|
121
|
-
const result = [];
|
|
122
|
-
for (const part of parts) {
|
|
123
|
-
switch (part.kind) {
|
|
124
|
-
case "text":
|
|
125
|
-
case "code":
|
|
126
|
-
result.push(part.text);
|
|
127
|
-
break;
|
|
128
|
-
case "inline-tag":
|
|
129
|
-
switch (part.tag) {
|
|
130
|
-
case "@label":
|
|
131
|
-
case "@inheritdoc": // Shouldn't happen
|
|
132
|
-
break; // Not rendered.
|
|
133
|
-
case "@link":
|
|
134
|
-
case "@linkcode":
|
|
135
|
-
case "@linkplain": {
|
|
136
|
-
if (part.target) {
|
|
137
|
-
let url;
|
|
138
|
-
let kindClass;
|
|
139
|
-
if (typeof part.target === "string") {
|
|
140
|
-
url = part.target;
|
|
141
|
-
}
|
|
142
|
-
else if (part.target && "id" in part.target) {
|
|
143
|
-
// No point in trying to resolve a ReflectionSymbolId at this point, we've already
|
|
144
|
-
// tried and failed during the resolution step.
|
|
145
|
-
url = urlTo(part.target);
|
|
146
|
-
kindClass = kind_1.ReflectionKind.classString(part.target.kind);
|
|
147
|
-
}
|
|
148
|
-
if (useHtml) {
|
|
149
|
-
const text = part.tag === "@linkcode"
|
|
150
|
-
? `<code>${part.text}</code>`
|
|
151
|
-
: part.text;
|
|
152
|
-
result.push(url
|
|
153
|
-
? `<a href="${url}"${kindClass
|
|
154
|
-
? ` class="${kindClass}"`
|
|
155
|
-
: ""}>${text}</a>`
|
|
156
|
-
: part.text);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
const text = part.tag === "@linkcode"
|
|
160
|
-
? "`" + part.text + "`"
|
|
161
|
-
: part.text;
|
|
162
|
-
result.push(url ? `[${text}](${url})` : text);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
result.push(part.text);
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
default:
|
|
171
|
-
// Hmm... probably want to be able to render these somehow, so custom inline tags can be given
|
|
172
|
-
// special rendering rules. Future capability. For now, just render their text.
|
|
173
|
-
result.push(`{${part.tag} ${part.text}}`);
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
break;
|
|
177
|
-
default:
|
|
178
|
-
(0, utils_1.assertNever)(part);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return result.join("");
|
|
182
|
-
}
|
|
183
114
|
/**
|
|
184
115
|
* Helper utility to clone {@link Comment.summary} or {@link CommentTag.content}
|
|
185
116
|
*/
|
|
@@ -210,12 +141,18 @@ let Comment = (() => {
|
|
|
210
141
|
target,
|
|
211
142
|
};
|
|
212
143
|
}
|
|
144
|
+
case "relative-link": {
|
|
145
|
+
return {
|
|
146
|
+
...part,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
213
149
|
}
|
|
214
150
|
});
|
|
215
151
|
}
|
|
216
152
|
//Since display parts are plain objects, this lives here
|
|
217
153
|
static deserializeDisplayParts(de, parts) {
|
|
218
154
|
const links = [];
|
|
155
|
+
const files = [];
|
|
219
156
|
const result = parts.map((part) => {
|
|
220
157
|
switch (part.kind) {
|
|
221
158
|
case "text":
|
|
@@ -255,11 +192,27 @@ let Comment = (() => {
|
|
|
255
192
|
else {
|
|
256
193
|
(0, utils_1.assertNever)(part.target);
|
|
257
194
|
}
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
case "relative-link": {
|
|
198
|
+
if (part.target) {
|
|
199
|
+
const part2 = {
|
|
200
|
+
kind: "relative-link",
|
|
201
|
+
text: part.text,
|
|
202
|
+
target: null,
|
|
203
|
+
};
|
|
204
|
+
files.push([part.target, part2]);
|
|
205
|
+
return part2;
|
|
206
|
+
}
|
|
207
|
+
return { ...part, target: undefined };
|
|
258
208
|
}
|
|
259
209
|
}
|
|
260
210
|
});
|
|
261
|
-
if (links.length) {
|
|
211
|
+
if (links.length || files.length) {
|
|
262
212
|
de.defer((project) => {
|
|
213
|
+
for (const [oldFileId, part] of files) {
|
|
214
|
+
part.target = de.oldFileIdToNewFileId[oldFileId];
|
|
215
|
+
}
|
|
263
216
|
for (const [oldId, part] of links) {
|
|
264
217
|
part.target = project.getReflectionById(de.oldIdToNewId[oldId] ?? -1);
|
|
265
218
|
if (!part.target) {
|
|
@@ -282,6 +235,7 @@ let Comment = (() => {
|
|
|
282
235
|
case "code":
|
|
283
236
|
return part.text.includes("\n");
|
|
284
237
|
case "inline-tag":
|
|
238
|
+
case "relative-link":
|
|
285
239
|
return false;
|
|
286
240
|
}
|
|
287
241
|
});
|
|
@@ -337,6 +291,7 @@ let Comment = (() => {
|
|
|
337
291
|
/**
|
|
338
292
|
* Internal discovery ID used to prevent symbol comments from
|
|
339
293
|
* being duplicated on signatures. Only set when the comment was created
|
|
294
|
+
* from a `ts.CommentRange`.
|
|
340
295
|
* @internal
|
|
341
296
|
*/
|
|
342
297
|
this.discoveryId = (__runInitializers(this, _sourcePath_extraInitializers), __runInitializers(this, _discoveryId_initializers, void 0));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Comment, CommentTag } from "./comment";
|
|
2
|
-
export type { CommentDisplayPart, InlineTagDisplayPart } from "./comment";
|
|
2
|
+
export type { CommentDisplayPart, InlineTagDisplayPart, RelativeLinkDisplayPart, } from "./comment";
|
package/dist/lib/models/index.js
CHANGED
|
@@ -20,3 +20,4 @@ __exportStar(require("./comments/index"), exports);
|
|
|
20
20
|
__exportStar(require("./sources/index"), exports);
|
|
21
21
|
__exportStar(require("./ReflectionGroup"), exports);
|
|
22
22
|
__exportStar(require("./ReflectionCategory"), exports);
|
|
23
|
+
__exportStar(require("./FileRegistry"), exports);
|
|
@@ -22,7 +22,7 @@ const transientIds = new WeakMap();
|
|
|
22
22
|
class ReflectionSymbolId {
|
|
23
23
|
constructor(symbol, declaration) {
|
|
24
24
|
if ("name" in symbol) {
|
|
25
|
-
declaration ??= symbol
|
|
25
|
+
declaration ??= symbol.declarations?.[0];
|
|
26
26
|
this.fileName = (0, paths_1.normalizePath)(declaration?.getSourceFile().fileName ?? "");
|
|
27
27
|
if (symbol.declarations?.some(typescript_1.default.isSourceFile)) {
|
|
28
28
|
this.qualifiedName = "";
|
|
@@ -329,7 +329,7 @@ let Reflection = (() => {
|
|
|
329
329
|
if (!this._alias) {
|
|
330
330
|
let alias = this.name.replace(/\W/g, "_");
|
|
331
331
|
if (alias === "") {
|
|
332
|
-
alias =
|
|
332
|
+
alias = `reflection-${this.id}`;
|
|
333
333
|
}
|
|
334
334
|
// NTFS/ExFAT use uppercase, so we will too. It probably won't matter
|
|
335
335
|
// in this case since names will generally be valid identifiers, but to be safe...
|
|
@@ -6,6 +6,7 @@ import { type CommentDisplayPart } from "../comments";
|
|
|
6
6
|
import { ReflectionSymbolId } from "./ReflectionSymbolId";
|
|
7
7
|
import type { Serializer } from "../../serialization/serializer";
|
|
8
8
|
import type { Deserializer, JSONOutput } from "../../serialization/index";
|
|
9
|
+
import type { FileRegistry } from "../FileRegistry";
|
|
9
10
|
/**
|
|
10
11
|
* A reflection that represents the root of the project.
|
|
11
12
|
*
|
|
@@ -42,7 +43,11 @@ export declare class ProjectReflection extends ContainerReflection {
|
|
|
42
43
|
* The contents of the readme.md file of the project when found.
|
|
43
44
|
*/
|
|
44
45
|
readme?: CommentDisplayPart[];
|
|
45
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Object which describes where to find content for relative links.
|
|
48
|
+
*/
|
|
49
|
+
readonly files: FileRegistry;
|
|
50
|
+
constructor(name: string, registry: FileRegistry);
|
|
46
51
|
/**
|
|
47
52
|
* Return whether this reflection is the root / project reflection.
|
|
48
53
|
*/
|
|
@@ -58,7 +63,7 @@ export declare class ProjectReflection extends ContainerReflection {
|
|
|
58
63
|
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
59
64
|
* Should be called for *every* reflection added to the project.
|
|
60
65
|
*/
|
|
61
|
-
registerReflection(reflection: Reflection, symbol
|
|
66
|
+
registerReflection(reflection: Reflection, symbol: ts.Symbol | undefined, filePath: string | undefined): void;
|
|
62
67
|
/**
|
|
63
68
|
* Removes a reflection from the documentation. Can be used by plugins to filter reflections
|
|
64
69
|
* out of the generated documentation. Has no effect if the reflection is not present in the
|
|
@@ -18,7 +18,7 @@ const map_1 = require("../../utils/map");
|
|
|
18
18
|
* @category Reflections
|
|
19
19
|
*/
|
|
20
20
|
class ProjectReflection extends container_1.ContainerReflection {
|
|
21
|
-
constructor(name) {
|
|
21
|
+
constructor(name, registry) {
|
|
22
22
|
super(name, kind_1.ReflectionKind.Project);
|
|
23
23
|
this.variant = "project";
|
|
24
24
|
// Used to resolve references.
|
|
@@ -36,6 +36,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
36
36
|
*/
|
|
37
37
|
this.reflections = {};
|
|
38
38
|
this.reflections[this.id] = this;
|
|
39
|
+
this.files = registry;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Return whether this reflection is the root / project reflection.
|
|
@@ -56,7 +57,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
56
57
|
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
57
58
|
* Should be called for *every* reflection added to the project.
|
|
58
59
|
*/
|
|
59
|
-
registerReflection(reflection, symbol) {
|
|
60
|
+
registerReflection(reflection, symbol, filePath) {
|
|
60
61
|
this.referenceGraph = undefined;
|
|
61
62
|
if (reflection.parent) {
|
|
62
63
|
this.reflectionChildren
|
|
@@ -87,6 +88,9 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
if (filePath) {
|
|
92
|
+
this.files.registerReflection(filePath, reflection);
|
|
93
|
+
}
|
|
90
94
|
}
|
|
91
95
|
/**
|
|
92
96
|
* Removes a reflection from the documentation. Can be used by plugins to filter reflections
|
|
@@ -106,44 +110,48 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
106
110
|
if (child !== reflection) {
|
|
107
111
|
return true; // Continue iteration
|
|
108
112
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
113
|
+
switch (property) {
|
|
114
|
+
case abstract_1.TraverseProperty.Children:
|
|
115
|
+
case abstract_1.TraverseProperty.Documents:
|
|
116
|
+
parent.removeChild(reflection);
|
|
117
|
+
break;
|
|
118
|
+
case abstract_1.TraverseProperty.GetSignature:
|
|
119
|
+
delete parent.getSignature;
|
|
120
|
+
break;
|
|
121
|
+
case abstract_1.TraverseProperty.IndexSignature:
|
|
122
|
+
(0, utils_1.removeIfPresent)(parent.indexSignatures, reflection);
|
|
123
|
+
if (!parent.indexSignatures?.length) {
|
|
124
|
+
delete parent.indexSignatures;
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case abstract_1.TraverseProperty.Parameters:
|
|
128
|
+
(0, utils_1.removeIfPresent)(reflection.parent.parameters, reflection);
|
|
129
|
+
if (!reflection.parent.parameters
|
|
130
|
+
?.length) {
|
|
131
|
+
delete reflection.parent
|
|
132
|
+
.parameters;
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case abstract_1.TraverseProperty.SetSignature:
|
|
136
|
+
delete parent.setSignature;
|
|
137
|
+
break;
|
|
138
|
+
case abstract_1.TraverseProperty.Signatures:
|
|
139
|
+
(0, utils_1.removeIfPresent)(parent.signatures, reflection);
|
|
140
|
+
if (!parent.signatures?.length) {
|
|
141
|
+
delete parent.signatures;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case abstract_1.TraverseProperty.TypeLiteral:
|
|
145
|
+
parent.type = new types_1.IntrinsicType("Object");
|
|
146
|
+
break;
|
|
147
|
+
case abstract_1.TraverseProperty.TypeParameter:
|
|
148
|
+
(0, utils_1.removeIfPresent)(parent.typeParameters, reflection);
|
|
149
|
+
if (!parent.typeParameters?.length) {
|
|
150
|
+
delete parent.typeParameters;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
(0, utils_1.assertNever)(property);
|
|
147
155
|
}
|
|
148
156
|
return false; // Stop iteration
|
|
149
157
|
});
|
|
@@ -152,6 +160,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
152
160
|
* Remove a reflection without updating the parent reflection to remove references to the removed reflection.
|
|
153
161
|
*/
|
|
154
162
|
_removeReflection(reflection) {
|
|
163
|
+
this.files.removeReflection(reflection);
|
|
155
164
|
// Remove references pointing to this reflection
|
|
156
165
|
const graph = this.getReferenceGraph();
|
|
157
166
|
for (const id of graph.get(reflection.id) ?? []) {
|
|
@@ -276,6 +285,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
276
285
|
packageVersion: this.packageVersion,
|
|
277
286
|
readme: comments_1.Comment.serializeDisplayParts(serializer, this.readme),
|
|
278
287
|
symbolIdMap,
|
|
288
|
+
files: serializer.toObject(this.files),
|
|
279
289
|
};
|
|
280
290
|
}
|
|
281
291
|
fromObject(de, obj) {
|
|
@@ -286,6 +296,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
286
296
|
if (obj.readme) {
|
|
287
297
|
this.readme = comments_1.Comment.deserializeDisplayParts(de, obj.readme);
|
|
288
298
|
}
|
|
299
|
+
this.files.fromObject(de, obj.files);
|
|
289
300
|
de.defer(() => {
|
|
290
301
|
for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
|
|
291
302
|
const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
|
|
@@ -8,6 +8,8 @@ const file_1 = require("../sources/file");
|
|
|
8
8
|
* @category Reflections
|
|
9
9
|
*/
|
|
10
10
|
class SignatureReflection extends abstract_1.Reflection {
|
|
11
|
+
// ESLint is wrong, we're restricting types to be more narrow.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
11
13
|
constructor(name, kind, parent) {
|
|
12
14
|
super(name, kind, parent);
|
|
13
15
|
this.variant = "signature";
|
package/dist/lib/models/types.js
CHANGED
|
@@ -748,7 +748,7 @@ class ReferenceType extends Type {
|
|
|
748
748
|
static createSymbolReference(symbol, context, name) {
|
|
749
749
|
const ref = new ReferenceType(name ?? symbol.name, new ReflectionSymbolId_1.ReflectionSymbolId(symbol), context.project, (0, tsutils_1.getQualifiedName)(symbol, name ?? symbol.name));
|
|
750
750
|
ref.refersToTypeParameter = !!(symbol.flags & ts.SymbolFlags.TypeParameter);
|
|
751
|
-
const symbolPath = symbol
|
|
751
|
+
const symbolPath = symbol.declarations?.[0]
|
|
752
752
|
?.getSourceFile()
|
|
753
753
|
.fileName.replace(/\\/g, "/");
|
|
754
754
|
if (!symbolPath)
|
|
@@ -826,7 +826,7 @@ class ReferenceType extends Type {
|
|
|
826
826
|
this._target = target.id;
|
|
827
827
|
}
|
|
828
828
|
else {
|
|
829
|
-
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(obj.target
|
|
829
|
+
de.logger.warn(de.application.i18n.serialized_project_referenced_0_not_part_of_project(JSON.stringify(obj.target)));
|
|
830
830
|
}
|
|
831
831
|
});
|
|
832
832
|
}
|
|
@@ -107,6 +107,11 @@ let AssetsPlugin = (() => {
|
|
|
107
107
|
const dest = (0, path_1.join)(event.outputDirectory, "assets");
|
|
108
108
|
(0, fs_1.copySync)(src, dest);
|
|
109
109
|
(0, fs_1.writeFileSync)((0, path_1.join)(dest, "highlight.css"), (0, highlighter_1.getStyles)());
|
|
110
|
+
const media = (0, path_1.join)(event.outputDirectory, "media");
|
|
111
|
+
const toCopy = event.project.files.getNameToAbsoluteMap();
|
|
112
|
+
for (const [fileName, absolute] of toCopy.entries()) {
|
|
113
|
+
(0, fs_1.copySync)(absolute, (0, path_1.join)(media, fileName));
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
constructor() {
|
|
@@ -121,7 +121,7 @@ let JavascriptIndexPlugin = (() => {
|
|
|
121
121
|
if (!(this.owner.theme instanceof DefaultTheme_1.DefaultTheme)) {
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
if (event.isDefaultPrevented) {
|
|
124
|
+
if (event.isDefaultPrevented()) {
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
this.owner.preRenderAsyncJobs.push((event) => this.buildSearchIndex(event));
|
|
@@ -138,7 +138,7 @@ let JavascriptIndexPlugin = (() => {
|
|
|
138
138
|
});
|
|
139
139
|
const indexEvent = new events_1.IndexEvent(events_1.IndexEvent.PREPARE_INDEX, initialSearchResults);
|
|
140
140
|
this.owner.trigger(indexEvent);
|
|
141
|
-
if (indexEvent.isDefaultPrevented) {
|
|
141
|
+
if (indexEvent.isDefaultPrevented()) {
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
const builder = new lunr_1.Builder();
|
|
@@ -84,7 +84,7 @@ let NavigationPlugin = (() => {
|
|
|
84
84
|
if (!(this.owner.theme instanceof DefaultTheme_1.DefaultTheme)) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
if (event.isDefaultPrevented) {
|
|
87
|
+
if (event.isDefaultPrevented()) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
this.owner.preRenderAsyncJobs.push((event) => this.buildNavigationIndex(event));
|
|
@@ -67,7 +67,7 @@ let SitemapPlugin = (() => {
|
|
|
67
67
|
if (!(this.owner.theme instanceof DefaultTheme_1.DefaultTheme)) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
if (event.isDefaultPrevented || !this.hostedBaseUrl) {
|
|
70
|
+
if (event.isDefaultPrevented() || !this.hostedBaseUrl) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
this.owner.hooks.on("head.begin", (context) => {
|