typedoc 0.27.4 → 0.27.6
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 +0 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/lib/application.js +0 -4
- package/dist/lib/converter/comments/blockLexer.js +28 -10
- package/dist/lib/converter/comments/declarationReference.d.ts +2 -1
- package/dist/lib/converter/comments/declarationReference.js +9 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.js +12 -6
- package/dist/lib/converter/comments/lineLexer.js +23 -7
- package/dist/lib/converter/comments/linkResolver.js +24 -4
- package/dist/lib/converter/comments/rawLexer.js +28 -16
- package/dist/lib/converter/comments/textParser.js +1 -0
- package/dist/lib/converter/converter.d.ts +3 -0
- package/dist/lib/converter/converter.js +3 -1
- package/dist/lib/converter/plugins/IncludePlugin.d.ts +2 -1
- package/dist/lib/converter/plugins/PackagePlugin.js +3 -0
- package/dist/lib/converter/symbols.js +1 -1
- package/dist/lib/converter/types.js +16 -3
- package/dist/lib/converter/utils/nodes.d.ts +1 -0
- package/dist/lib/converter/utils/nodes.js +4 -0
- package/dist/lib/debug/debugReflectionLifetimes.d.ts +2 -0
- package/dist/lib/debug/debugReflectionLifetimes.js +19 -0
- package/dist/lib/debug/debugRendererUrls.d.ts +5 -0
- package/dist/lib/debug/debugRendererUrls.js +59 -0
- package/dist/lib/debug/index.d.ts +2 -0
- package/dist/lib/debug/index.js +2 -0
- package/dist/lib/internationalization/internationalization.d.ts +1 -2
- package/dist/lib/internationalization/locales/en.cjs +2 -0
- package/dist/lib/internationalization/locales/en.d.cts +2 -0
- package/dist/lib/models/ReflectionCategory.js +1 -1
- package/dist/lib/models/ReflectionGroup.js +1 -1
- package/dist/lib/models/reflections/project.js +1 -0
- package/dist/lib/models/types.js +9 -2
- package/dist/lib/output/components.d.ts +1 -1
- package/dist/lib/output/renderer.d.ts +1 -0
- package/dist/lib/output/renderer.js +10 -2
- package/dist/lib/output/themes/MarkedPlugin.d.ts +2 -0
- package/dist/lib/output/themes/MarkedPlugin.js +33 -7
- package/dist/lib/output/themes/default/DefaultTheme.js +14 -1
- package/dist/lib/output/themes/default/partials/member.signatures.js +1 -1
- package/dist/lib/output/themes/default/partials/typeDetails.js +14 -4
- package/dist/lib/serialization/serializer.d.ts +1 -0
- package/dist/lib/serialization/serializer.js +4 -1
- package/dist/lib/utils/array.d.ts +1 -0
- package/dist/lib/utils/array.js +15 -0
- package/dist/lib/utils/highlighter.d.ts +1 -1
- package/dist/lib/utils/highlighter.js +6 -4
- package/dist/lib/utils/jsx.d.ts +2 -2
- package/dist/lib/utils/jsx.elements.d.ts +11 -0
- package/dist/lib/utils/options/declaration.d.ts +5 -0
- package/dist/lib/utils/options/defaults.d.ts +1 -0
- package/dist/lib/utils/options/defaults.js +1 -0
- package/dist/lib/utils/options/options.d.ts +0 -8
- package/dist/lib/utils/options/options.js +0 -18
- package/dist/lib/utils/options/readers/typedoc.d.ts +0 -3
- package/dist/lib/utils/options/readers/typedoc.js +2 -3
- package/dist/lib/utils/options/sources/typedoc.js +7 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Documentation generator for TypeScript projects.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/TypeStrong/typedoc/actions)
|
|
6
|
-
[](https://www.npmjs.com/package/typedoc)
|
|
7
|
-
|
|
8
5
|
## Documentation
|
|
9
6
|
|
|
10
7
|
For more detailed documentation, the changelog, and TypeDoc documentation rendered with TypeDoc, see https://typedoc.org.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module TypeDoc API
|
|
3
|
+
*
|
|
4
|
+
* In addition to the members documented here, TypeDoc exports a `typedoc/debug`
|
|
5
|
+
* entry point which exports some functions which may be useful during plugin
|
|
6
|
+
* development or debugging. Exports from that entry point are **not stable**
|
|
7
|
+
* and may change or be removed at any time.
|
|
3
8
|
*/
|
|
4
9
|
export { Application, type ApplicationEvents } from "./lib/application.js";
|
|
5
10
|
export { EventDispatcher } from "./lib/utils/events.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module TypeDoc API
|
|
3
|
+
*
|
|
4
|
+
* In addition to the members documented here, TypeDoc exports a `typedoc/debug`
|
|
5
|
+
* entry point which exports some functions which may be useful during plugin
|
|
6
|
+
* development or debugging. Exports from that entry point are **not stable**
|
|
7
|
+
* and may change or be removed at any time.
|
|
3
8
|
*/
|
|
4
9
|
export { Application } from "./lib/application.js";
|
|
5
10
|
export { EventDispatcher } from "./lib/utils/events.js";
|
package/dist/lib/application.js
CHANGED
|
@@ -317,9 +317,6 @@ let Application = (() => {
|
|
|
317
317
|
*/
|
|
318
318
|
async convert() {
|
|
319
319
|
const start = Date.now();
|
|
320
|
-
// We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
|
|
321
|
-
// with a few different settings.
|
|
322
|
-
this.options.freeze();
|
|
323
320
|
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
324
321
|
if (this.entryPointStrategy === EntryPointStrategy.Merge) {
|
|
325
322
|
return this._merge();
|
|
@@ -356,7 +353,6 @@ let Application = (() => {
|
|
|
356
353
|
return project;
|
|
357
354
|
}
|
|
358
355
|
convertAndWatch(success) {
|
|
359
|
-
this.options.freeze();
|
|
360
356
|
if (!this.options.getValue("preserveWatchOutput") &&
|
|
361
357
|
this.logger instanceof ConsoleLogger) {
|
|
362
358
|
ts.sys.clearScreen?.();
|
|
@@ -107,17 +107,29 @@ function* lexBlockComment2(file, pos, end, linkTags, checker) {
|
|
|
107
107
|
break;
|
|
108
108
|
case "`": {
|
|
109
109
|
// Markdown's code rules are a royal pain. This could be one of several things.
|
|
110
|
-
// 1. Inline code: <1-n ticks><text><same number of ticks>
|
|
111
|
-
// 2. Code block: <3 ticks><language, no ticks>\n<text>\n<3 ticks>\n
|
|
110
|
+
// 1. Inline code: <1-n ticks><text without multiple consecutive newlines or ticks at start of line><same number of ticks>
|
|
111
|
+
// 2. Code block: <newline><3+ ticks><language, no ticks>\n<text>\n<3 ticks>\n
|
|
112
112
|
// 3. Unmatched tick(s), not code, but part of some text.
|
|
113
113
|
// We don't quite handle #2 correctly yet. PR welcome!
|
|
114
114
|
braceStartsType = false;
|
|
115
115
|
let tickCount = 1;
|
|
116
|
-
let lookahead = pos;
|
|
116
|
+
let lookahead = pos - 1;
|
|
117
|
+
let atNewline = true;
|
|
118
|
+
while (lookahead > 0 && file[lookahead] !== "\n") {
|
|
119
|
+
if (/\S/.test(file[lookahead])) {
|
|
120
|
+
if (!commentHasStars || file[lookahead] !== "*") {
|
|
121
|
+
atNewline = false;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
--lookahead;
|
|
126
|
+
}
|
|
127
|
+
lookahead = pos;
|
|
117
128
|
while (lookahead + 1 < end && file[lookahead + 1] === "`") {
|
|
118
129
|
tickCount++;
|
|
119
130
|
lookahead++;
|
|
120
131
|
}
|
|
132
|
+
const isCodeBlock = atNewline && tickCount >= 3;
|
|
121
133
|
let lookaheadStart = pos;
|
|
122
134
|
const codeText = [];
|
|
123
135
|
lookahead++;
|
|
@@ -125,12 +137,18 @@ function* lexBlockComment2(file, pos, end, linkTags, checker) {
|
|
|
125
137
|
if (lookaheadExactlyNTicks(lookahead, tickCount)) {
|
|
126
138
|
lookahead += tickCount;
|
|
127
139
|
codeText.push(file.substring(lookaheadStart, lookahead));
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
const codeTextStr = codeText.join("");
|
|
141
|
+
if (isCodeBlock || !/\n\s*\n/.test(codeTextStr)) {
|
|
142
|
+
yield {
|
|
143
|
+
kind: TokenSyntaxKind.Code,
|
|
144
|
+
text: codeTextStr,
|
|
145
|
+
pos,
|
|
146
|
+
};
|
|
147
|
+
pos = lookahead;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
yield makeToken(TokenSyntaxKind.Text, tickCount);
|
|
151
|
+
}
|
|
134
152
|
break;
|
|
135
153
|
}
|
|
136
154
|
else if (file[lookahead] === "`") {
|
|
@@ -167,7 +185,7 @@ function* lexBlockComment2(file, pos, end, linkTags, checker) {
|
|
|
167
185
|
}
|
|
168
186
|
}
|
|
169
187
|
if (lookahead >= end && pos !== lookahead) {
|
|
170
|
-
if (
|
|
188
|
+
if (isCodeBlock &&
|
|
171
189
|
file.substring(pos, end).includes("\n")) {
|
|
172
190
|
codeText.push(file.substring(lookaheadStart, end));
|
|
173
191
|
yield {
|
|
@@ -27,7 +27,8 @@ export interface ComponentPath {
|
|
|
27
27
|
* How to resolve the `path`
|
|
28
28
|
* - `.` - Navigate via `exports` of symbol
|
|
29
29
|
* - `#` - Navigate via `members` of symbol
|
|
30
|
-
* - `~` - Navigate via `locals` of symbol
|
|
30
|
+
* - `~` - Navigate via `locals` of symbol (note: TypeDoc does not support
|
|
31
|
+
* locals, see the declaration reference docs)
|
|
31
32
|
*/
|
|
32
33
|
navigation: "." | "#" | "~";
|
|
33
34
|
path: string;
|
|
@@ -300,6 +300,7 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
300
300
|
let moduleSource;
|
|
301
301
|
let symbolReference;
|
|
302
302
|
let resolutionStart = "local";
|
|
303
|
+
let topLevelLocalReference = false;
|
|
303
304
|
const moduleSourceOrSymbolRef = parseModuleSource(source, pos, end);
|
|
304
305
|
if (moduleSourceOrSymbolRef) {
|
|
305
306
|
if (moduleSourceOrSymbolRef[1] < end &&
|
|
@@ -308,6 +309,11 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
308
309
|
pos = moduleSourceOrSymbolRef[1] + 1;
|
|
309
310
|
resolutionStart = "global";
|
|
310
311
|
moduleSource = moduleSourceOrSymbolRef[0];
|
|
312
|
+
// We might be referencing a local of a module
|
|
313
|
+
if (source[pos] === "~") {
|
|
314
|
+
topLevelLocalReference = true;
|
|
315
|
+
pos++;
|
|
316
|
+
}
|
|
311
317
|
}
|
|
312
318
|
}
|
|
313
319
|
else if (source[pos] === "!") {
|
|
@@ -317,6 +323,9 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
317
323
|
const ref = parseSymbolReference(source, pos, end);
|
|
318
324
|
if (ref) {
|
|
319
325
|
symbolReference = ref[0];
|
|
326
|
+
if (topLevelLocalReference && symbolReference.path?.length) {
|
|
327
|
+
symbolReference.path[0].navigation = "~";
|
|
328
|
+
}
|
|
320
329
|
pos = ref[1];
|
|
321
330
|
}
|
|
322
331
|
if (!moduleSource && !symbolReference)
|
|
@@ -174,8 +174,14 @@ function resolveKeyword(refl, kw) {
|
|
|
174
174
|
function resolveSymbolReferencePart(refl, path) {
|
|
175
175
|
let high = [];
|
|
176
176
|
let low = [];
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
let children;
|
|
178
|
+
if (refl instanceof ContainerReflection) {
|
|
179
|
+
children = refl.childrenIncludingDocuments;
|
|
180
|
+
}
|
|
181
|
+
if (!children && refl.isDeclaration() && refl.type?.type === "reflection") {
|
|
182
|
+
children = refl.type.declaration.childrenIncludingDocuments;
|
|
183
|
+
}
|
|
184
|
+
if (!children) {
|
|
179
185
|
return { high, low };
|
|
180
186
|
}
|
|
181
187
|
switch (path.navigation) {
|
|
@@ -184,16 +190,16 @@ function resolveSymbolReferencePart(refl, path) {
|
|
|
184
190
|
// so that resolution doesn't behave very poorly with projects using JSDoc style resolution.
|
|
185
191
|
// Also is more consistent with how TypeScript resolves link tags.
|
|
186
192
|
case ".":
|
|
187
|
-
high =
|
|
193
|
+
high = children.filter((r) => r.name === path.path &&
|
|
188
194
|
(r.kindOf(ReflectionKind.SomeExport) || r.flags.isStatic));
|
|
189
|
-
low =
|
|
195
|
+
low = children.filter((r) => r.name === path.path &&
|
|
190
196
|
(!r.kindOf(ReflectionKind.SomeExport) || !r.flags.isStatic));
|
|
191
197
|
break;
|
|
192
198
|
// Resolve via "members", interface children, class instance properties/accessors/methods,
|
|
193
199
|
// enum members, type literal properties
|
|
194
200
|
case "#":
|
|
195
201
|
high =
|
|
196
|
-
|
|
202
|
+
children?.filter((r) => {
|
|
197
203
|
return (r.name === path.path &&
|
|
198
204
|
r.kindOf(ReflectionKind.SomeMember) &&
|
|
199
205
|
!r.flags.isStatic);
|
|
@@ -203,7 +209,7 @@ function resolveSymbolReferencePart(refl, path) {
|
|
|
203
209
|
// module/namespace exports since TypeDoc doesn't support documenting locals.
|
|
204
210
|
case "~":
|
|
205
211
|
if (refl.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
|
|
206
|
-
high =
|
|
212
|
+
high = children?.filter((r) => r.name === path.path) || [];
|
|
207
213
|
}
|
|
208
214
|
break;
|
|
209
215
|
}
|
|
@@ -65,11 +65,21 @@ function* lexLineComments2(file, pos, end) {
|
|
|
65
65
|
// We don't quite handle #2 correctly yet. PR welcome!
|
|
66
66
|
braceStartsType = false;
|
|
67
67
|
let tickCount = 1;
|
|
68
|
-
let lookahead = pos;
|
|
68
|
+
let lookahead = pos - 1;
|
|
69
|
+
let atNewline = true;
|
|
70
|
+
while (lookahead > 0 && file[lookahead] !== "\n") {
|
|
71
|
+
if (/\S/.test(file[lookahead])) {
|
|
72
|
+
atNewline = false;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
--lookahead;
|
|
76
|
+
}
|
|
77
|
+
lookahead = pos;
|
|
69
78
|
while (lookahead + 1 < end && file[lookahead + 1] === "`") {
|
|
70
79
|
tickCount++;
|
|
71
80
|
lookahead++;
|
|
72
81
|
}
|
|
82
|
+
const isCodeBlock = atNewline && tickCount >= 3;
|
|
73
83
|
let lookaheadStart = pos;
|
|
74
84
|
const codeText = [];
|
|
75
85
|
lookahead++;
|
|
@@ -77,12 +87,18 @@ function* lexLineComments2(file, pos, end) {
|
|
|
77
87
|
if (lookaheadExactlyNTicks(lookahead, tickCount)) {
|
|
78
88
|
lookahead += tickCount;
|
|
79
89
|
codeText.push(file.substring(lookaheadStart, lookahead));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
const codeTextStr = codeText.join("");
|
|
91
|
+
if (isCodeBlock || !/\n\s*\n/.test(codeTextStr)) {
|
|
92
|
+
yield {
|
|
93
|
+
kind: TokenSyntaxKind.Code,
|
|
94
|
+
text: codeTextStr,
|
|
95
|
+
pos,
|
|
96
|
+
};
|
|
97
|
+
pos = lookahead;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
yield makeToken(TokenSyntaxKind.Text, tickCount);
|
|
101
|
+
}
|
|
86
102
|
break;
|
|
87
103
|
}
|
|
88
104
|
else if (file[lookahead] === "`") {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { DeclarationReflection, Reflection, ReflectionSymbolId, } from "../../models/index.js";
|
|
2
|
+
import { DeclarationReflection, Reflection, ReflectionKind, ReflectionSymbolId, } from "../../models/index.js";
|
|
3
3
|
import { parseDeclarationReference, } from "./declarationReference.js";
|
|
4
4
|
import { resolveDeclarationReference } from "./declarationReferenceResolver.js";
|
|
5
|
+
import { maxElementByScore } from "../../utils/array.js";
|
|
5
6
|
const urlPrefix = /^(http|ftp)s?:\/\//;
|
|
6
7
|
export function resolveLinks(comment, reflection, externalResolver, options) {
|
|
7
8
|
comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver, options);
|
|
@@ -45,9 +46,28 @@ function resolveLinkTag(reflection, part, externalResolver, options) {
|
|
|
45
46
|
const declRef = parseDeclarationReference(part.text, pos, end);
|
|
46
47
|
// Might already know where it should go if useTsLinkResolution is turned on
|
|
47
48
|
if (part.target instanceof ReflectionSymbolId) {
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
target
|
|
49
|
+
const tsTargets = reflection.project.getReflectionsFromSymbolId(part.target);
|
|
50
|
+
if (tsTargets.length) {
|
|
51
|
+
// Find the target most likely to have a real url in the generated documentation
|
|
52
|
+
// 1. A direct export (class, interface, variable)
|
|
53
|
+
// 2. A property of a direct export (class/interface property)
|
|
54
|
+
// 3. A property of a type of an export (property on type alias)
|
|
55
|
+
// 4. Whatever the first symbol found was
|
|
56
|
+
target = maxElementByScore(tsTargets, (r) => {
|
|
57
|
+
if (r.kindOf(ReflectionKind.SomeExport)) {
|
|
58
|
+
return 4;
|
|
59
|
+
}
|
|
60
|
+
if (r.kindOf(ReflectionKind.SomeMember) &&
|
|
61
|
+
r.parent?.kindOf(ReflectionKind.SomeExport)) {
|
|
62
|
+
return 3;
|
|
63
|
+
}
|
|
64
|
+
if (r.kindOf(ReflectionKind.SomeMember) &&
|
|
65
|
+
r.parent?.kindOf(ReflectionKind.TypeLiteral) &&
|
|
66
|
+
r.parent.parent?.kindOf(ReflectionKind.TypeAlias | ReflectionKind.Variable)) {
|
|
67
|
+
return 2;
|
|
68
|
+
}
|
|
69
|
+
return 1;
|
|
70
|
+
});
|
|
51
71
|
pos = end;
|
|
52
72
|
defaultDisplayText =
|
|
53
73
|
part.tsLinkText ||
|
|
@@ -43,19 +43,14 @@ function* lexCommentString2(file) {
|
|
|
43
43
|
while (pos < end && /\s/.test(file[end - 1])) {
|
|
44
44
|
end--;
|
|
45
45
|
}
|
|
46
|
-
let lineStart = true;
|
|
47
46
|
let expectingTag = false;
|
|
48
47
|
for (;;) {
|
|
49
48
|
if (pos >= end) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
|
-
if (lineStart) {
|
|
53
|
-
lineStart = false;
|
|
54
|
-
}
|
|
55
51
|
switch (file[pos]) {
|
|
56
52
|
case "\n":
|
|
57
53
|
yield makeToken(TokenSyntaxKind.NewLine, 1);
|
|
58
|
-
lineStart = true;
|
|
59
54
|
expectingTag = false;
|
|
60
55
|
break;
|
|
61
56
|
case "{":
|
|
@@ -68,16 +63,26 @@ function* lexCommentString2(file) {
|
|
|
68
63
|
break;
|
|
69
64
|
case "`": {
|
|
70
65
|
// Markdown's code rules are a royal pain. This could be one of several things.
|
|
71
|
-
// 1. Inline code: <1-n ticks><text><same number of ticks>
|
|
72
|
-
// 2. Code block: <3 ticks><language, no ticks>\n<text>\n<3 ticks>\n
|
|
66
|
+
// 1. Inline code: <1-n ticks><text without multiple consecutive newlines or ticks at start of line><same number of ticks>
|
|
67
|
+
// 2. Code block: <newline><3+ ticks><language, no ticks>\n<text>\n<3 ticks>\n
|
|
73
68
|
// 3. Unmatched tick(s), not code, but part of some text.
|
|
74
69
|
// We don't quite handle #2 correctly yet. PR welcome!
|
|
75
70
|
let tickCount = 1;
|
|
76
|
-
let lookahead = pos;
|
|
71
|
+
let lookahead = pos - 1;
|
|
72
|
+
let atNewline = true;
|
|
73
|
+
while (lookahead > 0 && file[lookahead] !== "\n") {
|
|
74
|
+
if (/\S/.test(file[lookahead])) {
|
|
75
|
+
atNewline = false;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
--lookahead;
|
|
79
|
+
}
|
|
80
|
+
lookahead = pos;
|
|
77
81
|
while (lookahead + 1 < end && file[lookahead + 1] === "`") {
|
|
78
82
|
tickCount++;
|
|
79
83
|
lookahead++;
|
|
80
84
|
}
|
|
85
|
+
const isCodeBlock = atNewline && tickCount >= 3;
|
|
81
86
|
let lookaheadStart = pos;
|
|
82
87
|
const codeText = [];
|
|
83
88
|
lookahead++;
|
|
@@ -85,13 +90,20 @@ function* lexCommentString2(file) {
|
|
|
85
90
|
if (lookaheadExactlyNTicks(lookahead, tickCount)) {
|
|
86
91
|
lookahead += tickCount;
|
|
87
92
|
codeText.push(file.substring(lookaheadStart, lookahead));
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
const codeTextStr = codeText.join("");
|
|
94
|
+
if (isCodeBlock || !/\n\s*\n/.test(codeTextStr)) {
|
|
95
|
+
yield {
|
|
96
|
+
kind: TokenSyntaxKind.Code,
|
|
97
|
+
text: codeTextStr,
|
|
98
|
+
pos,
|
|
99
|
+
};
|
|
100
|
+
expectingTag = false;
|
|
101
|
+
pos = lookahead;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
yield makeToken(TokenSyntaxKind.Text, tickCount);
|
|
105
|
+
expectingTag = false;
|
|
106
|
+
}
|
|
95
107
|
break;
|
|
96
108
|
}
|
|
97
109
|
else if (file[lookahead] === "`") {
|
|
@@ -114,7 +126,7 @@ function* lexCommentString2(file) {
|
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
if (lookahead >= end && pos !== lookahead) {
|
|
117
|
-
if (
|
|
129
|
+
if (isCodeBlock &&
|
|
118
130
|
file.substring(pos, end).includes("\n")) {
|
|
119
131
|
codeText.push(file.substring(lookaheadStart, end));
|
|
120
132
|
yield {
|
|
@@ -10,6 +10,7 @@ import type { CommentStyle, ValidationOptions } from "../utils/options/declarati
|
|
|
10
10
|
import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver.js";
|
|
11
11
|
import { type DeclarationReference } from "./comments/declarationReference.js";
|
|
12
12
|
import type { FileRegistry } from "../models/FileRegistry.js";
|
|
13
|
+
import { IncludePlugin } from "./plugins/IncludePlugin.js";
|
|
13
14
|
export interface ConverterEvents {
|
|
14
15
|
begin: [Context];
|
|
15
16
|
end: [Context];
|
|
@@ -144,6 +145,8 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
|
|
|
144
145
|
* @event
|
|
145
146
|
*/
|
|
146
147
|
static readonly EVENT_RESOLVE_END: "resolveEnd";
|
|
148
|
+
/** @internal @hidden */
|
|
149
|
+
includePlugin: IncludePlugin;
|
|
147
150
|
constructor(owner: Application);
|
|
148
151
|
/**
|
|
149
152
|
* Compile the given source files and create a project reflection for them.
|
|
@@ -255,6 +255,8 @@ let Converter = (() => {
|
|
|
255
255
|
* @event
|
|
256
256
|
*/
|
|
257
257
|
static EVENT_RESOLVE_END = ConverterEvents.RESOLVE_END;
|
|
258
|
+
/** @internal @hidden */
|
|
259
|
+
includePlugin;
|
|
258
260
|
constructor(owner) {
|
|
259
261
|
super(owner);
|
|
260
262
|
const userConfiguredSymbolResolver = (ref, refl, _part, symbolId) => {
|
|
@@ -294,7 +296,7 @@ let Converter = (() => {
|
|
|
294
296
|
new PackagePlugin(this);
|
|
295
297
|
new SourcePlugin(this);
|
|
296
298
|
new TypePlugin(this);
|
|
297
|
-
new IncludePlugin(this);
|
|
299
|
+
this.includePlugin = new IncludePlugin(this);
|
|
298
300
|
new MergeModuleWithPlugin(this);
|
|
299
301
|
}
|
|
300
302
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConverterComponent } from "../components.js";
|
|
2
|
+
import type { CommentDisplayPart, Reflection } from "../../models/index.js";
|
|
2
3
|
import type { Converter } from "../converter.js";
|
|
3
4
|
/**
|
|
4
5
|
* Handles `@include` and `@includeCode` within comments/documents.
|
|
@@ -7,5 +8,5 @@ export declare class IncludePlugin extends ConverterComponent {
|
|
|
7
8
|
get logger(): import("../../utils/loggers.js").Logger;
|
|
8
9
|
constructor(owner: Converter);
|
|
9
10
|
private onCreate;
|
|
10
|
-
|
|
11
|
+
checkIncludeTagsParts(refl: Reflection, relative: string, parts: CommentDisplayPart[], included?: string[]): void;
|
|
11
12
|
}
|
|
@@ -155,6 +155,9 @@ let PackagePlugin = (() => {
|
|
|
155
155
|
if (this.readmeFile && this.readmeContents) {
|
|
156
156
|
const { content } = this.application.converter.parseRawComment(new MinimalSourceFile(this.readmeContents, this.readmeFile), project.files);
|
|
157
157
|
project.readme = content;
|
|
158
|
+
// This isn't ideal, but seems better than figuring out the readme
|
|
159
|
+
// path over in the include plugin...
|
|
160
|
+
this.owner.includePlugin.checkIncludeTagsParts(project, Path.dirname(this.readmeFile), content);
|
|
158
161
|
}
|
|
159
162
|
if (this.packageJson) {
|
|
160
163
|
project.packageName = this.packageJson.name;
|
|
@@ -501,7 +501,7 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
501
501
|
if (context.converter.excludeReferences)
|
|
502
502
|
return;
|
|
503
503
|
// We already have this. Create a reference.
|
|
504
|
-
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
|
|
504
|
+
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target.isReference() ? target.getTargetReflection() : target, context.scope);
|
|
505
505
|
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
506
506
|
context.finalizeDeclarationReflection(ref);
|
|
507
507
|
}
|
|
@@ -7,7 +7,7 @@ import { ConverterEvents } from "./converter-events.js";
|
|
|
7
7
|
import { convertIndexSignatures } from "./factories/index-signature.js";
|
|
8
8
|
import { convertParameterNodes, convertTypeParameterNodes, createSignature, } from "./factories/signature.js";
|
|
9
9
|
import { convertSymbol } from "./symbols.js";
|
|
10
|
-
import { isObjectType } from "./utils/nodes.js";
|
|
10
|
+
import { isObjectType, isTypeReference } from "./utils/nodes.js";
|
|
11
11
|
import { removeUndefined } from "./utils/reflections.js";
|
|
12
12
|
const converters = new Map();
|
|
13
13
|
export function loadConverters() {
|
|
@@ -490,9 +490,22 @@ const referenceConverter = {
|
|
|
490
490
|
];
|
|
491
491
|
}
|
|
492
492
|
else {
|
|
493
|
-
|
|
493
|
+
// Default type arguments are filled with a reference to the default
|
|
494
|
+
// type. As TS doesn't support specifying earlier defaults, we know
|
|
495
|
+
// that this will only filter out type arguments which aren't specified
|
|
496
|
+
// by the user.
|
|
497
|
+
let ignoredArgs;
|
|
498
|
+
if (isTypeReference(type)) {
|
|
499
|
+
ignoredArgs = type.target.typeParameters
|
|
500
|
+
?.map((p) => p.getDefault())
|
|
501
|
+
.filter((x) => !!x);
|
|
502
|
+
}
|
|
503
|
+
const args = type.aliasSymbol
|
|
494
504
|
? type.aliasTypeArguments
|
|
495
|
-
: type.typeArguments
|
|
505
|
+
: type.typeArguments;
|
|
506
|
+
ref.typeArguments = args
|
|
507
|
+
?.filter((ref) => !ignoredArgs?.includes(ref))
|
|
508
|
+
.map((ref) => convertType(context, ref));
|
|
496
509
|
}
|
|
497
510
|
return ref;
|
|
498
511
|
},
|
|
@@ -4,3 +4,4 @@ export declare function isNamedNode(node: unknown): node is {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function getHeritageTypes(declarations: readonly (ts.ClassDeclaration | ts.InterfaceDeclaration)[], kind: ts.SyntaxKind.ImplementsKeyword | ts.SyntaxKind.ExtendsKeyword): ts.ExpressionWithTypeArguments[];
|
|
6
6
|
export declare function isObjectType(type: ts.Type): type is ts.ObjectType;
|
|
7
|
+
export declare function isTypeReference(type: ts.Type): type is ts.TypeReference;
|
|
@@ -20,3 +20,7 @@ export function getHeritageTypes(declarations, kind) {
|
|
|
20
20
|
export function isObjectType(type) {
|
|
21
21
|
return typeof type.objectFlags === "number";
|
|
22
22
|
}
|
|
23
|
+
export function isTypeReference(type) {
|
|
24
|
+
return (isObjectType(type) &&
|
|
25
|
+
(type.objectFlags & ts.ObjectFlags.Reference) !== 0);
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConverterEvents } from "../converter/converter-events.js";
|
|
2
|
+
export function debugReflectionLifetimes(app) {
|
|
3
|
+
app.converter.on(ConverterEvents.CREATE_PROJECT, logCreate);
|
|
4
|
+
app.converter.on(ConverterEvents.CREATE_SIGNATURE, logCreate);
|
|
5
|
+
app.converter.on(ConverterEvents.CREATE_TYPE_PARAMETER, logCreate);
|
|
6
|
+
app.converter.on(ConverterEvents.CREATE_DECLARATION, logCreate);
|
|
7
|
+
app.converter.on(ConverterEvents.CREATE_DOCUMENT, logCreate);
|
|
8
|
+
app.converter.on(ConverterEvents.CREATE_PARAMETER, logCreate);
|
|
9
|
+
app.converter.on(ConverterEvents.CREATE_PROJECT, (_context, project) => {
|
|
10
|
+
const oldRemove = project["_removeReflection"];
|
|
11
|
+
project["_removeReflection"] = function (reflection) {
|
|
12
|
+
console.log("Remove", reflection.id, reflection.getFullName());
|
|
13
|
+
return oldRemove.call(this, reflection);
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function logCreate(_context, refl) {
|
|
18
|
+
console.log("Create", refl.variant, refl.id, refl.getFullName());
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { Reflection, ReflectionKind, } from "../models/index.js";
|
|
4
|
+
const serializer = {
|
|
5
|
+
priority: 0,
|
|
6
|
+
supports(x) {
|
|
7
|
+
return x instanceof Reflection;
|
|
8
|
+
},
|
|
9
|
+
toObject(item, obj) {
|
|
10
|
+
obj.url = item.url;
|
|
11
|
+
obj.hasOwnDocument = item.hasOwnDocument;
|
|
12
|
+
// obj.anchor = item.anchor;
|
|
13
|
+
delete obj.sources;
|
|
14
|
+
delete obj.groups;
|
|
15
|
+
delete obj.categories;
|
|
16
|
+
delete obj.readme;
|
|
17
|
+
delete obj.content;
|
|
18
|
+
obj.kind = ReflectionKind[obj.kind];
|
|
19
|
+
delete obj.flags;
|
|
20
|
+
delete obj.defaultValue;
|
|
21
|
+
delete obj.symbolIdMap;
|
|
22
|
+
delete obj.files;
|
|
23
|
+
delete obj.packageName;
|
|
24
|
+
delete obj.variant;
|
|
25
|
+
delete obj.extendedTypes;
|
|
26
|
+
delete obj.inheritedFrom;
|
|
27
|
+
if (!["reflection", "reference"].includes(obj.type?.type)) {
|
|
28
|
+
delete obj.type;
|
|
29
|
+
}
|
|
30
|
+
if (obj.comment) {
|
|
31
|
+
obj.comment.summary = obj.comment.summary.filter((part) => part.kind === "inline-tag");
|
|
32
|
+
obj.comment.blockTags = obj.comment.blockTags?.filter((tag) => {
|
|
33
|
+
tag.content = tag.content.filter((part) => part.kind === "inline-tag");
|
|
34
|
+
return tag.content.length;
|
|
35
|
+
});
|
|
36
|
+
if (!obj.comment.summary.length &&
|
|
37
|
+
!obj.comment.blockTags?.length &&
|
|
38
|
+
!obj.comment.modifierTags) {
|
|
39
|
+
delete obj.comment;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export function debugRendererUrls(app, { json = false, logs = false } = { logs: true }) {
|
|
46
|
+
app.renderer.postRenderAsyncJobs.push(async (evt) => {
|
|
47
|
+
if (json) {
|
|
48
|
+
app.serializer.addSerializer(serializer);
|
|
49
|
+
await app.generateJson(evt.project, join(evt.outputDirectory, "url_debug.json"));
|
|
50
|
+
app.serializer.removeSerializer(serializer);
|
|
51
|
+
}
|
|
52
|
+
if (logs) {
|
|
53
|
+
for (const id in evt.project.reflections) {
|
|
54
|
+
const refl = evt.project.reflections[id];
|
|
55
|
+
console.log(refl.id, refl.getFullName(), refl.url, refl.hasOwnDocument);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -2,7 +2,6 @@ import type { Application } from "../application.js";
|
|
|
2
2
|
import { ReflectionKind } from "../models/reflections/kind.js";
|
|
3
3
|
import { ReflectionFlag } from "../models/index.js";
|
|
4
4
|
import { type BuiltinTranslatableStringArgs } from "./translatable.js";
|
|
5
|
-
import translatable from "./locales/en.cjs";
|
|
6
5
|
/**
|
|
7
6
|
* ### What is translatable?
|
|
8
7
|
* TypeDoc includes a lot of literal strings. By convention, messages which are displayed
|
|
@@ -75,7 +74,7 @@ export declare class Internationalization {
|
|
|
75
74
|
* Get the translation of the specified key, replacing placeholders
|
|
76
75
|
* with the arguments specified.
|
|
77
76
|
*/
|
|
78
|
-
translate<T extends keyof
|
|
77
|
+
translate<T extends keyof TranslatableStrings>(key: T, ...args: TranslatableStrings[T]): TranslatedString;
|
|
79
78
|
kindSingularString(kind: ReflectionKind): TranslatedString;
|
|
80
79
|
kindPluralString(kind: ReflectionKind): TranslatedString;
|
|
81
80
|
flagString(flag: ReflectionFlag): TranslatedString;
|