typedoc 0.25.3 → 0.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/converter/comments/declarationReference.js +14 -14
- package/dist/lib/converter/comments/discovery.js +3 -1
- package/dist/lib/converter/comments/parser.js +56 -13
- package/dist/lib/converter/plugins/TypePlugin.js +4 -1
- package/dist/lib/converter/symbols.js +20 -13
- package/dist/lib/converter/utils/repository.js +4 -4
- package/dist/lib/converter/utils/symbols.js +5 -0
- package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +8 -0
- package/dist/lib/models/reflections/ReflectionSymbolId.js +13 -3
- package/dist/lib/models/types.js +21 -21
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +14 -3
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +10 -0
- package/dist/lib/output/themes/default/partials/comment.js +8 -3
- package/dist/lib/output/themes/default/partials/member.signatures.js +2 -1
- package/dist/lib/output/themes/default/partials/reflectionPreview.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +21 -0
- package/dist/lib/output/themes/default/partials/type.d.ts +3 -1
- package/dist/lib/output/themes/default/partials/type.js +27 -24
- package/dist/lib/output/themes/default/templates/reflection.js +2 -1
- package/dist/lib/utils/options/declaration.js +2 -2
- package/dist/lib/utils/options/options.js +6 -5
- package/package.json +6 -4
- package/static/style.css +11 -0
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.parseDeclarationReference = exports.parseMeaning = exports.parseComponentPath = exports.parseComponent = exports.parseSymbolReference = exports.parseModuleSource = exports.parseString = exports.MeaningKeywords = void 0;
|
|
11
11
|
exports.MeaningKeywords = [
|
|
12
|
-
"class",
|
|
13
|
-
"interface",
|
|
14
|
-
"type",
|
|
15
|
-
"enum",
|
|
16
|
-
"namespace",
|
|
17
|
-
"function",
|
|
18
|
-
"var",
|
|
19
|
-
"constructor",
|
|
20
|
-
"member",
|
|
21
|
-
"event",
|
|
22
|
-
"call",
|
|
23
|
-
"new",
|
|
24
|
-
"index",
|
|
25
|
-
"complex",
|
|
12
|
+
"class", // SymbolFlags.Class
|
|
13
|
+
"interface", // SymbolFlags.Interface
|
|
14
|
+
"type", // SymbolFlags.TypeAlias
|
|
15
|
+
"enum", // SymbolFlags.Enum
|
|
16
|
+
"namespace", // SymbolFlags.Module
|
|
17
|
+
"function", // SymbolFlags.Function
|
|
18
|
+
"var", // SymbolFlags.Variable
|
|
19
|
+
"constructor", // SymbolFlags.Constructor
|
|
20
|
+
"member", // SymbolFlags.ClassMember | SymbolFlags.EnumMember
|
|
21
|
+
"event", //
|
|
22
|
+
"call", // SymbolFlags.Signature (for __call)
|
|
23
|
+
"new", // SymbolFlags.Signature (for __new)
|
|
24
|
+
"index", // SymbolFlags.Signature (for __index)
|
|
25
|
+
"complex", // Any complex type
|
|
26
26
|
// TypeDoc specific
|
|
27
27
|
"getter",
|
|
28
28
|
"setter",
|
|
@@ -121,13 +121,15 @@ function discoverComment(symbol, kind, logger, commentStyle) {
|
|
|
121
121
|
// not the last one, since that will apply to the import or declaration.
|
|
122
122
|
const reverse = !symbol.declarations?.some(typescript_1.default.isSourceFile);
|
|
123
123
|
const discovered = [];
|
|
124
|
+
const seen = new Set();
|
|
124
125
|
for (const decl of symbol.declarations || []) {
|
|
125
126
|
const text = decl.getSourceFile().text;
|
|
126
127
|
if (wantedKinds[kind].includes(decl.kind)) {
|
|
127
128
|
const node = declarationToCommentNode(decl);
|
|
128
|
-
if (!node) {
|
|
129
|
+
if (!node || seen.has(node)) {
|
|
129
130
|
continue;
|
|
130
131
|
}
|
|
132
|
+
seen.add(node);
|
|
131
133
|
// Special behavior here! We temporarily put the implementation comment
|
|
132
134
|
// on the reflection which contains all the signatures. This lets us pull
|
|
133
135
|
// the comment on the implementation if some signature does not have a comment.
|
|
@@ -126,8 +126,8 @@ function blockTag(comment, lexer, config, warning) {
|
|
|
126
126
|
(0, assert_1.ok)(blockTag.kind === lexer_1.TokenSyntaxKind.Tag, "blockTag called not at the start of a block tag."); // blockContent is broken if this fails.
|
|
127
127
|
const tagName = aliasedTags.get(blockTag.text) || blockTag.text;
|
|
128
128
|
let content;
|
|
129
|
-
if (tagName === "@example"
|
|
130
|
-
|
|
129
|
+
if (tagName === "@example") {
|
|
130
|
+
return exampleBlock(comment, lexer, config, warning);
|
|
131
131
|
}
|
|
132
132
|
else if (["@default", "@defaultValue"].includes(tagName) &&
|
|
133
133
|
config.jsDocCompatibility.defaultTag) {
|
|
@@ -168,14 +168,59 @@ function defaultBlockContent(comment, lexer, config, warning) {
|
|
|
168
168
|
/**
|
|
169
169
|
* The `@example` tag gets a special case because otherwise we will produce many warnings
|
|
170
170
|
* about unescaped/mismatched/missing braces in legacy JSDoc comments.
|
|
171
|
+
*
|
|
172
|
+
* In TSDoc, we also want to treat the first line of the block as the example name.
|
|
171
173
|
*/
|
|
172
|
-
function
|
|
174
|
+
function exampleBlock(comment, lexer, config, warning) {
|
|
173
175
|
lexer.mark();
|
|
174
176
|
const content = blockContent(comment, lexer, config, () => { });
|
|
175
177
|
const end = lexer.done() || lexer.peek();
|
|
176
178
|
lexer.release();
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
+
if (!config.jsDocCompatibility.exampleTag ||
|
|
180
|
+
content.some((part) => part.kind === "code" && part.text.startsWith("```"))) {
|
|
181
|
+
let exampleName = "";
|
|
182
|
+
// First line of @example block is the example name.
|
|
183
|
+
let warnedAboutRichNameContent = false;
|
|
184
|
+
outer: while ((lexer.done() || lexer.peek()) !== end) {
|
|
185
|
+
const next = lexer.peek();
|
|
186
|
+
switch (next.kind) {
|
|
187
|
+
case lexer_1.TokenSyntaxKind.NewLine:
|
|
188
|
+
lexer.take();
|
|
189
|
+
break outer;
|
|
190
|
+
case lexer_1.TokenSyntaxKind.Text: {
|
|
191
|
+
const newline = next.text.indexOf("\n");
|
|
192
|
+
if (newline !== -1) {
|
|
193
|
+
exampleName += next.text.substring(0, newline);
|
|
194
|
+
next.pos += newline + 1;
|
|
195
|
+
break outer;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
exampleName += lexer.take().text;
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case lexer_1.TokenSyntaxKind.Code:
|
|
203
|
+
case lexer_1.TokenSyntaxKind.Tag:
|
|
204
|
+
case lexer_1.TokenSyntaxKind.TypeAnnotation:
|
|
205
|
+
case lexer_1.TokenSyntaxKind.CloseBrace:
|
|
206
|
+
case lexer_1.TokenSyntaxKind.OpenBrace:
|
|
207
|
+
if (!warnedAboutRichNameContent) {
|
|
208
|
+
warning("The first line of an example tag will be taken literally as" +
|
|
209
|
+
" the example name, and should only contain text.", lexer.peek());
|
|
210
|
+
warnedAboutRichNameContent = true;
|
|
211
|
+
}
|
|
212
|
+
exampleName += lexer.take().text;
|
|
213
|
+
break;
|
|
214
|
+
default:
|
|
215
|
+
(0, utils_1.assertNever)(next.kind);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const content = blockContent(comment, lexer, config, warning);
|
|
219
|
+
const tag = new models_1.CommentTag("@example", content);
|
|
220
|
+
if (exampleName.trim()) {
|
|
221
|
+
tag.name = exampleName.trim();
|
|
222
|
+
}
|
|
223
|
+
return tag;
|
|
179
224
|
}
|
|
180
225
|
const tokens = [];
|
|
181
226
|
while ((lexer.done() || lexer.peek()) !== end) {
|
|
@@ -187,24 +232,22 @@ function exampleBlockContent(comment, lexer, config, warning) {
|
|
|
187
232
|
.trim();
|
|
188
233
|
const caption = blockText.match(/^\s*<caption>(.*?)<\/caption>\s*(\n|$)/);
|
|
189
234
|
if (caption) {
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
kind: "text",
|
|
193
|
-
text: caption[1] + "\n",
|
|
194
|
-
},
|
|
235
|
+
const tag = new models_1.CommentTag("@example", [
|
|
195
236
|
{
|
|
196
237
|
kind: "code",
|
|
197
238
|
text: makeCodeBlock(blockText.slice(caption[0].length)),
|
|
198
239
|
},
|
|
199
|
-
];
|
|
240
|
+
]);
|
|
241
|
+
tag.name = caption[1];
|
|
242
|
+
return tag;
|
|
200
243
|
}
|
|
201
244
|
else {
|
|
202
|
-
return [
|
|
245
|
+
return new models_1.CommentTag("@example", [
|
|
203
246
|
{
|
|
204
247
|
kind: "code",
|
|
205
248
|
text: makeCodeBlock(blockText),
|
|
206
249
|
},
|
|
207
|
-
];
|
|
250
|
+
]);
|
|
208
251
|
}
|
|
209
252
|
}
|
|
210
253
|
function blockContent(comment, lexer, config, warning) {
|
|
@@ -156,7 +156,10 @@ let TypePlugin = (() => {
|
|
|
156
156
|
if (reflection.extendedBy) {
|
|
157
157
|
push(reflection.extendedBy);
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
// No point setting up a hierarchy if there is no hierarchy to display
|
|
160
|
+
if (root.next) {
|
|
161
|
+
reflection.typeHierarchy = root;
|
|
162
|
+
}
|
|
160
163
|
});
|
|
161
164
|
}
|
|
162
165
|
};
|
|
@@ -110,15 +110,6 @@ function convertSymbol(context, symbol, exportSymbol) {
|
|
|
110
110
|
// { methodProperty() {} }
|
|
111
111
|
flags = (0, enum_1.removeFlag)(flags, typescript_1.default.SymbolFlags.Property);
|
|
112
112
|
}
|
|
113
|
-
// A default exported function with no associated variable is a property, but
|
|
114
|
-
// we should really convert it as a variable for documentation purposes
|
|
115
|
-
// export default () => {}
|
|
116
|
-
// export default 123
|
|
117
|
-
if (flags === typescript_1.default.SymbolFlags.Property &&
|
|
118
|
-
symbol.name === "default" &&
|
|
119
|
-
context.scope.kindOf(models_1.ReflectionKind.Module | models_1.ReflectionKind.Project)) {
|
|
120
|
-
flags = typescript_1.default.SymbolFlags.BlockScopedVariable;
|
|
121
|
-
}
|
|
122
113
|
for (const flag of (0, enum_1.getEnumFlags)(flags ^ allConverterFlags)) {
|
|
123
114
|
if (!(flag & allConverterFlags)) {
|
|
124
115
|
context.logger.verbose(`Missing converter for symbol: ${symbol.name} with flag ${typescript_1.default.SymbolFlags[flag]}`);
|
|
@@ -359,8 +350,15 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
|
359
350
|
convertConstructSignatures(reflectionContext, symbol);
|
|
360
351
|
// And finally, index signatures
|
|
361
352
|
(0, index_signature_1.convertIndexSignature)(reflectionContext, symbol);
|
|
353
|
+
// Normally this shouldn't matter, unless someone did something with skipLibCheck off.
|
|
354
|
+
return typescript_1.default.SymbolFlags.Alias;
|
|
362
355
|
}
|
|
363
356
|
function convertProperty(context, symbol, exportSymbol) {
|
|
357
|
+
// This might happen if we're converting a function-module created with Object.assign
|
|
358
|
+
// or `export default () => {}`
|
|
359
|
+
if (context.scope.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
|
|
360
|
+
return convertVariable(context, symbol, exportSymbol);
|
|
361
|
+
}
|
|
364
362
|
const declarations = symbol.getDeclarations() ?? [];
|
|
365
363
|
// Don't do anything if we inherited this property and it is private.
|
|
366
364
|
if (isInherited(context, symbol) &&
|
|
@@ -466,9 +464,10 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
466
464
|
}
|
|
467
465
|
function convertVariable(context, symbol, exportSymbol) {
|
|
468
466
|
const declaration = symbol.getDeclarations()?.[0];
|
|
469
|
-
(0, assert_1.default)(declaration);
|
|
470
467
|
const comment = context.getComment(symbol, models_1.ReflectionKind.Variable);
|
|
471
|
-
const type =
|
|
468
|
+
const type = declaration
|
|
469
|
+
? context.checker.getTypeOfSymbolAtLocation(symbol, declaration)
|
|
470
|
+
: context.checker.getTypeOfSymbol(symbol);
|
|
472
471
|
if (isEnumLike(context.checker, type, declaration) &&
|
|
473
472
|
comment?.hasModifier("@enum")) {
|
|
474
473
|
return convertVariableAsEnum(context, symbol, exportSymbol);
|
|
@@ -481,7 +480,7 @@ function convertVariable(context, symbol, exportSymbol) {
|
|
|
481
480
|
}
|
|
482
481
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Variable, symbol, exportSymbol);
|
|
483
482
|
let typeNode;
|
|
484
|
-
if (typescript_1.default.isVariableDeclaration(declaration)) {
|
|
483
|
+
if (declaration && typescript_1.default.isVariableDeclaration(declaration)) {
|
|
485
484
|
// Otherwise we might have destructuring
|
|
486
485
|
typeNode = declaration.type;
|
|
487
486
|
}
|
|
@@ -492,7 +491,7 @@ function convertVariable(context, symbol, exportSymbol) {
|
|
|
492
491
|
return typescript_1.default.SymbolFlags.Property;
|
|
493
492
|
}
|
|
494
493
|
function isEnumLike(checker, type, location) {
|
|
495
|
-
if (!(0, enum_1.hasAllFlags)(type.flags, typescript_1.default.TypeFlags.Object)) {
|
|
494
|
+
if (!location || !(0, enum_1.hasAllFlags)(type.flags, typescript_1.default.TypeFlags.Object)) {
|
|
496
495
|
return false;
|
|
497
496
|
}
|
|
498
497
|
return type.getProperties().every((prop) => {
|
|
@@ -545,6 +544,14 @@ function convertVariableAsFunction(context, symbol, exportSymbol) {
|
|
|
545
544
|
for (const signature of type.getCallSignatures()) {
|
|
546
545
|
(0, signature_1.createSignature)(reflectionContext, models_1.ReflectionKind.CallSignature, signature, symbol);
|
|
547
546
|
}
|
|
547
|
+
// #2436: Functions created with Object.assign on a function won't have a namespace flag
|
|
548
|
+
// but likely have properties that we should put into a namespace.
|
|
549
|
+
if (type.getProperties().length &&
|
|
550
|
+
!(0, enum_1.hasAnyFlag)(symbol.flags, typescript_1.default.SymbolFlags.NamespaceModule | typescript_1.default.SymbolFlags.ValueModule)) {
|
|
551
|
+
const ns = context.createDeclarationReflection(models_1.ReflectionKind.Namespace, symbol, exportSymbol);
|
|
552
|
+
context.finalizeDeclarationReflection(ns);
|
|
553
|
+
convertSymbols(context.withScope(ns), type.getProperties());
|
|
554
|
+
}
|
|
548
555
|
return typescript_1.default.SymbolFlags.Property;
|
|
549
556
|
}
|
|
550
557
|
function convertAccessor(context, symbol, exportSymbol) {
|
|
@@ -29,7 +29,7 @@ class AssumedRepository {
|
|
|
29
29
|
path: fileName.substring(this.path.length + 1),
|
|
30
30
|
line,
|
|
31
31
|
};
|
|
32
|
-
return this.sourceLinkTemplate.replace(/\{(path|line)\}/g, (_, key) => replacements[key]);
|
|
32
|
+
return this.sourceLinkTemplate.replace(/\{(gitRevision|path|line)\}/g, (_, key) => replacements[key]);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.AssumedRepository = AssumedRepository;
|
|
@@ -117,9 +117,9 @@ exports.GitRepository = GitRepository;
|
|
|
117
117
|
// 3. project
|
|
118
118
|
const repoExpressions = [
|
|
119
119
|
/(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/,
|
|
120
|
-
/(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/,
|
|
121
|
-
/(\w+\.ghe.com)[:/]([^/]+)\/(.*)/,
|
|
122
|
-
/(\w+\.github.us)[:/]([^/]+)\/(.*)/,
|
|
120
|
+
/(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/, // GitHub enterprise
|
|
121
|
+
/(\w+\.ghe.com)[:/]([^/]+)\/(.*)/, // GitHub enterprise
|
|
122
|
+
/(\w+\.github.us)[:/]([^/]+)\/(.*)/, // GitHub enterprise
|
|
123
123
|
/(bitbucket.org)[:/]([^/]+)\/(.*)/,
|
|
124
124
|
/(gitlab.com)[:/]([^/]+)\/(.*)/,
|
|
125
125
|
];
|
|
@@ -6,8 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveAliasedSymbol = void 0;
|
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
|
8
8
|
function resolveAliasedSymbol(symbol, checker) {
|
|
9
|
+
const seen = new Set();
|
|
9
10
|
while (typescript_1.default.SymbolFlags.Alias & symbol.flags) {
|
|
10
11
|
symbol = checker.getAliasedSymbol(symbol);
|
|
12
|
+
// #2438, with declaration files, we might have an aliased symbol which eventually points to itself.
|
|
13
|
+
if (seen.has(symbol))
|
|
14
|
+
return symbol;
|
|
15
|
+
seen.add(symbol);
|
|
11
16
|
}
|
|
12
17
|
return symbol;
|
|
13
18
|
}
|
|
@@ -17,8 +17,16 @@ export declare class ReflectionSymbolId {
|
|
|
17
17
|
/**
|
|
18
18
|
* Note: This is **not** serialized. It exists for sorting by declaration order, but
|
|
19
19
|
* should not be needed when deserializing from JSON.
|
|
20
|
+
* Will be set to `Infinity` if the ID was deserialized from JSON.
|
|
20
21
|
*/
|
|
21
22
|
pos: number;
|
|
23
|
+
/**
|
|
24
|
+
* Note: This is **not** serialized. It exists to support detection of the differences between
|
|
25
|
+
* symbols which share declarations, but are instantiated with different type parameters.
|
|
26
|
+
* This will be `NaN` if the symbol reference is not transient.
|
|
27
|
+
* Note: This can only be non-NaN if {@link pos} is finite.
|
|
28
|
+
*/
|
|
29
|
+
transientId: number;
|
|
22
30
|
constructor(symbol: ts.Symbol, declaration?: ts.Declaration);
|
|
23
31
|
constructor(json: JSONOutput.ReflectionSymbolId);
|
|
24
32
|
getStableKey(): ReflectionSymbolIdString;
|
|
@@ -8,9 +8,11 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const typescript_1 = __importDefault(require("typescript"));
|
|
10
10
|
const fs_2 = require("../../utils/fs");
|
|
11
|
+
const paths_1 = require("../../utils/paths");
|
|
11
12
|
const tsutils_1 = require("../../utils/tsutils");
|
|
12
13
|
const validation_1 = require("../../utils/validation");
|
|
13
|
-
|
|
14
|
+
let transientCount = 0;
|
|
15
|
+
const transientIds = new WeakMap();
|
|
14
16
|
/**
|
|
15
17
|
* This exists so that TypeDoc can store a unique identifier for a `ts.Symbol` without
|
|
16
18
|
* keeping a reference to the `ts.Symbol` itself. This identifier should be stable across
|
|
@@ -28,16 +30,24 @@ class ReflectionSymbolId {
|
|
|
28
30
|
this.qualifiedName = (0, tsutils_1.getQualifiedName)(symbol, symbol.name);
|
|
29
31
|
}
|
|
30
32
|
this.pos = declaration?.pos ?? Infinity;
|
|
33
|
+
if (symbol.flags & typescript_1.default.SymbolFlags.Transient) {
|
|
34
|
+
this.transientId = transientIds.get(symbol) ?? ++transientCount;
|
|
35
|
+
transientIds.set(symbol, this.transientId);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.transientId = NaN;
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
else {
|
|
33
42
|
this.fileName = symbol.sourceFileName;
|
|
34
43
|
this.qualifiedName = symbol.qualifiedName;
|
|
35
44
|
this.pos = Infinity;
|
|
45
|
+
this.transientId = NaN;
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
getStableKey() {
|
|
39
49
|
if (Number.isFinite(this.pos)) {
|
|
40
|
-
return `${this.fileName}\0${this.qualifiedName}\0${this.pos}`;
|
|
50
|
+
return `${this.fileName}\0${this.qualifiedName}\0${this.pos}\0${this.transientId}`;
|
|
41
51
|
}
|
|
42
52
|
else {
|
|
43
53
|
return `${this.fileName}\0${this.qualifiedName}`;
|
|
@@ -95,7 +105,7 @@ function addInferredDeclarationMapPaths(opts, files) {
|
|
|
95
105
|
const rootDir = opts.rootDir || (0, fs_2.getCommonDirectory)(files);
|
|
96
106
|
const declDir = opts.declarationDir || opts.outDir || rootDir;
|
|
97
107
|
for (const file of files) {
|
|
98
|
-
const mapFile = (0, path_1.resolve)(declDir, (0, path_1.relative)(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1");
|
|
108
|
+
const mapFile = (0, paths_1.normalizePath)((0, path_1.resolve)(declDir, (0, path_1.relative)(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1"));
|
|
99
109
|
declarationMapCache.set(mapFile, file);
|
|
100
110
|
}
|
|
101
111
|
}
|
package/dist/lib/models/types.js
CHANGED
|
@@ -151,27 +151,27 @@ exports.makeRecursiveVisitor = makeRecursiveVisitor;
|
|
|
151
151
|
*/
|
|
152
152
|
exports.TypeContext = {
|
|
153
153
|
none: "none",
|
|
154
|
-
templateLiteralElement: "templateLiteralElement",
|
|
155
|
-
arrayElement: "arrayElement",
|
|
156
|
-
indexedAccessElement: "indexedAccessElement",
|
|
157
|
-
conditionalCheck: "conditionalCheck",
|
|
158
|
-
conditionalExtends: "conditionalExtends",
|
|
159
|
-
conditionalTrue: "conditionalTrue",
|
|
160
|
-
conditionalFalse: "conditionalFalse",
|
|
161
|
-
indexedIndex: "indexedIndex",
|
|
162
|
-
indexedObject: "indexedObject",
|
|
163
|
-
inferredConstraint: "inferredConstraint",
|
|
164
|
-
intersectionElement: "intersectionElement",
|
|
165
|
-
mappedName: "mappedName",
|
|
166
|
-
mappedParameter: "mappedParameter",
|
|
167
|
-
mappedTemplate: "mappedTemplate",
|
|
168
|
-
optionalElement: "optionalElement",
|
|
169
|
-
predicateTarget: "predicateTarget",
|
|
170
|
-
queryTypeTarget: "queryTypeTarget",
|
|
171
|
-
typeOperatorTarget: "typeOperatorTarget",
|
|
172
|
-
referenceTypeArgument: "referenceTypeArgument",
|
|
173
|
-
restElement: "restElement",
|
|
174
|
-
tupleElement: "tupleElement",
|
|
154
|
+
templateLiteralElement: "templateLiteralElement", // `${here}`
|
|
155
|
+
arrayElement: "arrayElement", // here[]
|
|
156
|
+
indexedAccessElement: "indexedAccessElement", // {}[here]
|
|
157
|
+
conditionalCheck: "conditionalCheck", // here extends 1 ? 2 : 3
|
|
158
|
+
conditionalExtends: "conditionalExtends", // 1 extends here ? 2 : 3
|
|
159
|
+
conditionalTrue: "conditionalTrue", // 1 extends 2 ? here : 3
|
|
160
|
+
conditionalFalse: "conditionalFalse", // 1 extends 2 ? 3 : here
|
|
161
|
+
indexedIndex: "indexedIndex", // {}[here]
|
|
162
|
+
indexedObject: "indexedObject", // here[1]
|
|
163
|
+
inferredConstraint: "inferredConstraint", // 1 extends infer X extends here ? 1 : 2
|
|
164
|
+
intersectionElement: "intersectionElement", // here & 1
|
|
165
|
+
mappedName: "mappedName", // { [k in string as here]: 1 }
|
|
166
|
+
mappedParameter: "mappedParameter", // { [k in here]: 1 }
|
|
167
|
+
mappedTemplate: "mappedTemplate", // { [k in string]: here }
|
|
168
|
+
optionalElement: "optionalElement", // [here?]
|
|
169
|
+
predicateTarget: "predicateTarget", // (): X is here
|
|
170
|
+
queryTypeTarget: "queryTypeTarget", // typeof here, can only ever be a ReferenceType
|
|
171
|
+
typeOperatorTarget: "typeOperatorTarget", // keyof here
|
|
172
|
+
referenceTypeArgument: "referenceTypeArgument", // X<here>
|
|
173
|
+
restElement: "restElement", // [...here]
|
|
174
|
+
tupleElement: "tupleElement", // [here]
|
|
175
175
|
unionElement: "unionElement", // here | 1
|
|
176
176
|
};
|
|
177
177
|
/**
|
|
@@ -23,6 +23,15 @@ export declare class DefaultThemeRenderContext {
|
|
|
23
23
|
reflectionTemplate: (props: PageEvent<import("../../../models").ContainerReflection>) => JSX.Element;
|
|
24
24
|
indexTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => JSX.Element;
|
|
25
25
|
defaultLayout: (template: import("../..").RenderTemplate<PageEvent<Reflection>>, props: PageEvent<Reflection>) => JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Rendered just after the description for a reflection.
|
|
28
|
+
* This can be used to render a shortened type display of a reflection that the
|
|
29
|
+
* rest of the page expands on.
|
|
30
|
+
*
|
|
31
|
+
* Note: Will not be called for variables/type aliases, as they are summarized
|
|
32
|
+
* by their type declaration, which is already rendered by {@link DefaultThemeRenderContext.memberDeclaration}
|
|
33
|
+
*/
|
|
34
|
+
reflectionPreview: (props: Reflection) => JSX.Element | undefined;
|
|
26
35
|
analytics: () => JSX.Element | undefined;
|
|
27
36
|
breadcrumb: (props: Reflection) => JSX.Element | undefined;
|
|
28
37
|
commentSummary: (props: Reflection) => JSX.Element | undefined;
|
|
@@ -36,10 +45,10 @@ export declare class DefaultThemeRenderContext {
|
|
|
36
45
|
memberDeclaration: (props: DeclarationReflection) => JSX.Element;
|
|
37
46
|
memberGetterSetter: (props: DeclarationReflection) => JSX.Element;
|
|
38
47
|
memberReference: (props: import("../../../models").ReferenceReflection) => JSX.Element;
|
|
39
|
-
memberSignatureBody: (
|
|
48
|
+
memberSignatureBody: (props: import("../../../models").SignatureReflection, r_1?: {
|
|
40
49
|
hideSources?: boolean | undefined;
|
|
41
50
|
} | undefined) => JSX.Element;
|
|
42
|
-
memberSignatureTitle: (
|
|
51
|
+
memberSignatureTitle: (props: import("../../../models").SignatureReflection, r_1?: {
|
|
43
52
|
hideName?: boolean | undefined;
|
|
44
53
|
arrowStyle?: boolean | undefined;
|
|
45
54
|
} | undefined) => JSX.Element;
|
|
@@ -55,7 +64,9 @@ export declare class DefaultThemeRenderContext {
|
|
|
55
64
|
pageNavigation: (props: PageEvent<Reflection>) => JSX.Element;
|
|
56
65
|
parameter: (props: DeclarationReflection) => JSX.Element;
|
|
57
66
|
toolbar: (props: PageEvent<Reflection>) => JSX.Element;
|
|
58
|
-
type: (type: import("../../../models").Type | undefined
|
|
67
|
+
type: (type: import("../../../models").Type | undefined, options?: {
|
|
68
|
+
topLevelLinks: boolean;
|
|
69
|
+
} | undefined) => JSX.Element;
|
|
59
70
|
typeAndParent: (props: import("../../../models").Type) => JSX.Element;
|
|
60
71
|
typeParameters: (typeParameters: import("../../../models").TypeParameterReflection[]) => JSX.Element;
|
|
61
72
|
}
|
|
@@ -23,6 +23,7 @@ const members_1 = require("./partials/members");
|
|
|
23
23
|
const members_group_1 = require("./partials/members.group");
|
|
24
24
|
const navigation_1 = require("./partials/navigation");
|
|
25
25
|
const parameter_1 = require("./partials/parameter");
|
|
26
|
+
const reflectionPreview_1 = require("./partials/reflectionPreview");
|
|
26
27
|
const toolbar_1 = require("./partials/toolbar");
|
|
27
28
|
const type_1 = require("./partials/type");
|
|
28
29
|
const typeAndParent_1 = require("./partials/typeAndParent");
|
|
@@ -59,6 +60,15 @@ class DefaultThemeRenderContext {
|
|
|
59
60
|
this.reflectionTemplate = bind(reflection_1.reflectionTemplate, this);
|
|
60
61
|
this.indexTemplate = bind(templates_1.indexTemplate, this);
|
|
61
62
|
this.defaultLayout = bind(default_1.defaultLayout, this);
|
|
63
|
+
/**
|
|
64
|
+
* Rendered just after the description for a reflection.
|
|
65
|
+
* This can be used to render a shortened type display of a reflection that the
|
|
66
|
+
* rest of the page expands on.
|
|
67
|
+
*
|
|
68
|
+
* Note: Will not be called for variables/type aliases, as they are summarized
|
|
69
|
+
* by their type declaration, which is already rendered by {@link DefaultThemeRenderContext.memberDeclaration}
|
|
70
|
+
*/
|
|
71
|
+
this.reflectionPreview = bind(reflectionPreview_1.reflectionPreview, this);
|
|
62
72
|
this.analytics = bind(analytics_1.analytics, this);
|
|
63
73
|
this.breadcrumb = bind(breadcrumb_1.breadcrumb, this);
|
|
64
74
|
this.commentSummary = bind(comment_1.commentSummary, this);
|
|
@@ -18,9 +18,14 @@ function commentTags({ markdown }, props) {
|
|
|
18
18
|
const tags = props.kindOf(models_1.ReflectionKind.SomeSignature)
|
|
19
19
|
? props.comment.blockTags.filter((tag) => tag.tag !== "@returns")
|
|
20
20
|
: props.comment.blockTags;
|
|
21
|
-
return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" }, tags.map((item) =>
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return (utils_1.JSX.createElement("div", { class: "tsd-comment tsd-typography" }, tags.map((item) => {
|
|
22
|
+
const name = item.name
|
|
23
|
+
? `${(0, lib_1.camelToTitleCase)(item.tag.substring(1))}: ${item.name}`
|
|
24
|
+
: (0, lib_1.camelToTitleCase)(item.tag.substring(1));
|
|
25
|
+
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
26
|
+
utils_1.JSX.createElement("h4", null, name),
|
|
27
|
+
utils_1.JSX.createElement(utils_1.Raw, { html: markdown(item.content) })));
|
|
28
|
+
})));
|
|
24
29
|
}
|
|
25
30
|
exports.commentTags = commentTags;
|
|
26
31
|
const flagsNotRendered = ["@showCategories", "@showGroups", "@hideCategories", "@hideGroups"];
|
|
@@ -6,7 +6,8 @@ const anchor_icon_1 = require("./anchor-icon");
|
|
|
6
6
|
const lib_1 = require("../../lib");
|
|
7
7
|
const memberSignatures = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
8
8
|
utils_1.JSX.createElement("ul", { class: (0, lib_1.classNames)({ "tsd-signatures": true }, context.getReflectionClasses(props)) }, props.signatures?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
9
|
-
utils_1.JSX.createElement("li", { class: "tsd-signature tsd-anchor-link"
|
|
9
|
+
utils_1.JSX.createElement("li", { class: "tsd-signature tsd-anchor-link" },
|
|
10
|
+
utils_1.JSX.createElement("a", { id: item.anchor, class: "tsd-anchor" }),
|
|
10
11
|
context.memberSignatureTitle(item),
|
|
11
12
|
(0, anchor_icon_1.anchorIcon)(context, item.anchor)),
|
|
12
13
|
utils_1.JSX.createElement("li", { class: "tsd-description" }, context.memberSignatureBody(item))))))));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Reflection } from "../../../../models";
|
|
2
|
+
import { JSX } from "../../../../utils";
|
|
3
|
+
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
|
|
4
|
+
export declare function reflectionPreview(context: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reflectionPreview = void 0;
|
|
4
|
+
const models_1 = require("../../../../models");
|
|
5
|
+
const utils_1 = require("../../../../utils");
|
|
6
|
+
const lib_1 = require("../../lib");
|
|
7
|
+
function reflectionPreview(context, props) {
|
|
8
|
+
if (!(props instanceof models_1.DeclarationReflection))
|
|
9
|
+
return;
|
|
10
|
+
// Each property of the interface will have a member rendered later on the page describing it, so generate
|
|
11
|
+
// a type-like object with links to each member.
|
|
12
|
+
if (props.kindOf(models_1.ReflectionKind.Interface)) {
|
|
13
|
+
return (utils_1.JSX.createElement("div", { class: "tsd-signature" },
|
|
14
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "interface "),
|
|
15
|
+
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) },
|
|
16
|
+
props.name,
|
|
17
|
+
" "),
|
|
18
|
+
context.type(new models_1.ReflectionType(props), { topLevelLinks: true })));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.reflectionPreview = reflectionPreview;
|
|
@@ -2,4 +2,6 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
|
|
|
2
2
|
import { Type } from "../../../../models";
|
|
3
3
|
import { JSX } from "../../../../utils";
|
|
4
4
|
export declare function validateStateIsClean(page: string): void;
|
|
5
|
-
export declare function type(context: DefaultThemeRenderContext, type: Type | undefined
|
|
5
|
+
export declare function type(context: DefaultThemeRenderContext, type: Type | undefined, options?: {
|
|
6
|
+
topLevelLinks: boolean;
|
|
7
|
+
}): JSX.Element;
|
|
@@ -74,7 +74,7 @@ const typeRenderers = {
|
|
|
74
74
|
indentationDepth++;
|
|
75
75
|
const parts = [
|
|
76
76
|
renderType(context, type.checkType, models_1.TypeContext.conditionalCheck),
|
|
77
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
77
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " extends "),
|
|
78
78
|
renderType(context, type.extendsType, models_1.TypeContext.conditionalExtends),
|
|
79
79
|
utils_1.JSX.createElement("br", null),
|
|
80
80
|
includeIndentation(),
|
|
@@ -107,11 +107,11 @@ const typeRenderers = {
|
|
|
107
107
|
},
|
|
108
108
|
inferred(context, type) {
|
|
109
109
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
110
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
110
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "infer "),
|
|
111
111
|
" ",
|
|
112
112
|
utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.name),
|
|
113
113
|
type.constraint && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
114
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
114
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " extends "),
|
|
115
115
|
renderType(context, type.constraint, models_1.TypeContext.inferredConstraint)))));
|
|
116
116
|
},
|
|
117
117
|
intersection(context, type) {
|
|
@@ -128,15 +128,17 @@ const typeRenderers = {
|
|
|
128
128
|
const parts = [utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "{"), utils_1.JSX.createElement("br", null), includeIndentation()];
|
|
129
129
|
switch (type.readonlyModifier) {
|
|
130
130
|
case "+":
|
|
131
|
-
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
131
|
+
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "readonly "));
|
|
132
132
|
break;
|
|
133
133
|
case "-":
|
|
134
|
-
parts.push(utils_1.JSX.createElement(
|
|
134
|
+
parts.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
135
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "-"),
|
|
136
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "readonly ")));
|
|
135
137
|
break;
|
|
136
138
|
}
|
|
137
|
-
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.parameter), utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
139
|
+
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "["), utils_1.JSX.createElement("span", { class: "tsd-kind-type-parameter" }, type.parameter), utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " in "), renderType(context, type.parameterType, models_1.TypeContext.mappedParameter));
|
|
138
140
|
if (type.nameType) {
|
|
139
|
-
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
141
|
+
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " as "), renderType(context, type.nameType, models_1.TypeContext.mappedName));
|
|
140
142
|
}
|
|
141
143
|
parts.push(utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "]"));
|
|
142
144
|
switch (type.optionalModifier) {
|
|
@@ -170,15 +172,15 @@ const typeRenderers = {
|
|
|
170
172
|
},
|
|
171
173
|
predicate(context, type) {
|
|
172
174
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
173
|
-
!!type.asserts && utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
175
|
+
!!type.asserts && utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "asserts "),
|
|
174
176
|
utils_1.JSX.createElement("span", { class: "tsd-kind-parameter" }, type.name),
|
|
175
177
|
!!type.targetType && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
176
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
178
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, " is "),
|
|
177
179
|
renderType(context, type.targetType, models_1.TypeContext.predicateTarget)))));
|
|
178
180
|
},
|
|
179
181
|
query(context, type) {
|
|
180
182
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
181
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
183
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "typeof "),
|
|
182
184
|
renderType(context, type.queryType, models_1.TypeContext.queryTypeTarget)));
|
|
183
185
|
},
|
|
184
186
|
reference(context, type) {
|
|
@@ -211,30 +213,31 @@ const typeRenderers = {
|
|
|
211
213
|
}
|
|
212
214
|
return name;
|
|
213
215
|
},
|
|
214
|
-
reflection(context, type) {
|
|
216
|
+
reflection(context, type, { topLevelLinks }) {
|
|
215
217
|
const members = [];
|
|
216
218
|
const children = type.declaration.children || [];
|
|
217
219
|
indentationDepth++;
|
|
220
|
+
const renderName = (named) => topLevelLinks ? (utils_1.JSX.createElement("a", { class: (0, lib_1.getKindClass)(named), href: context.urlTo(named) }, named.name)) : (utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(named) }, named.name));
|
|
218
221
|
for (const item of children) {
|
|
219
222
|
if (item.getSignature && item.setSignature) {
|
|
220
223
|
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
221
|
-
|
|
224
|
+
renderName(item),
|
|
222
225
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, ": "),
|
|
223
226
|
renderType(context, item.getSignature.type, models_1.TypeContext.none)));
|
|
224
227
|
continue;
|
|
225
228
|
}
|
|
226
229
|
if (item.getSignature) {
|
|
227
230
|
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
228
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
229
|
-
|
|
231
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "get "),
|
|
232
|
+
renderName(item.getSignature),
|
|
230
233
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "(): "),
|
|
231
234
|
renderType(context, item.getSignature.type, models_1.TypeContext.none)));
|
|
232
235
|
continue;
|
|
233
236
|
}
|
|
234
237
|
if (item.setSignature) {
|
|
235
238
|
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
236
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
237
|
-
|
|
239
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "set "),
|
|
240
|
+
renderName(item.setSignature),
|
|
238
241
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("),
|
|
239
242
|
item.setSignature.parameters?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
240
243
|
item.name,
|
|
@@ -246,17 +249,17 @@ const typeRenderers = {
|
|
|
246
249
|
if (item.signatures) {
|
|
247
250
|
for (const sig of item.signatures) {
|
|
248
251
|
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
249
|
-
|
|
252
|
+
renderName(sig),
|
|
250
253
|
item.flags.isOptional && utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "?"),
|
|
251
254
|
context.memberSignatureTitle(sig, {
|
|
252
255
|
hideName: true,
|
|
253
|
-
arrowStyle:
|
|
256
|
+
arrowStyle: false,
|
|
254
257
|
})));
|
|
255
258
|
}
|
|
256
259
|
continue;
|
|
257
260
|
}
|
|
258
261
|
members.push(utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
259
|
-
|
|
262
|
+
renderName(item),
|
|
260
263
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, item.flags.isOptional ? "?: " : ": "),
|
|
261
264
|
renderType(context, item.type, models_1.TypeContext.none)));
|
|
262
265
|
}
|
|
@@ -331,7 +334,7 @@ const typeRenderers = {
|
|
|
331
334
|
},
|
|
332
335
|
typeOperator(context, type) {
|
|
333
336
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
334
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
337
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" },
|
|
335
338
|
type.operator,
|
|
336
339
|
" "),
|
|
337
340
|
renderType(context, type.target, models_1.TypeContext.typeOperatorTarget)));
|
|
@@ -343,12 +346,12 @@ const typeRenderers = {
|
|
|
343
346
|
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null, type.name);
|
|
344
347
|
},
|
|
345
348
|
};
|
|
346
|
-
function renderType(context, type, where) {
|
|
349
|
+
function renderType(context, type, where, options = { topLevelLinks: false }) {
|
|
347
350
|
if (!type) {
|
|
348
351
|
return utils_1.JSX.createElement("span", { class: "tsd-signature-type" }, "any");
|
|
349
352
|
}
|
|
350
353
|
const renderFn = typeRenderers[type.type];
|
|
351
|
-
const rendered = renderFn(context, type);
|
|
354
|
+
const rendered = renderFn(context, type, options);
|
|
352
355
|
if (type.needsParenthesis(where)) {
|
|
353
356
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
354
357
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("),
|
|
@@ -357,7 +360,7 @@ function renderType(context, type, where) {
|
|
|
357
360
|
}
|
|
358
361
|
return rendered;
|
|
359
362
|
}
|
|
360
|
-
function type(context, type) {
|
|
361
|
-
return renderType(context, type, models_1.TypeContext.none);
|
|
363
|
+
function type(context, type, options = { topLevelLinks: false }) {
|
|
364
|
+
return renderType(context, type, models_1.TypeContext.none, options);
|
|
362
365
|
}
|
|
363
366
|
exports.type = type;
|
|
@@ -5,7 +5,7 @@ const lib_1 = require("../../lib");
|
|
|
5
5
|
const models_1 = require("../../../../models");
|
|
6
6
|
const utils_1 = require("../../../../utils");
|
|
7
7
|
function reflectionTemplate(context, props) {
|
|
8
|
-
if (
|
|
8
|
+
if (props.model.kindOf(models_1.ReflectionKind.TypeAlias | models_1.ReflectionKind.Variable) &&
|
|
9
9
|
props.model instanceof models_1.DeclarationReflection) {
|
|
10
10
|
return context.memberDeclaration(props.model);
|
|
11
11
|
}
|
|
@@ -17,6 +17,7 @@ function reflectionTemplate(context, props) {
|
|
|
17
17
|
props.model.kind === models_1.ReflectionKind.Module &&
|
|
18
18
|
props.model.readme?.length && (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-typography" },
|
|
19
19
|
utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown(props.model.readme) }))),
|
|
20
|
+
context.reflectionPreview(props.model),
|
|
20
21
|
(0, lib_1.hasTypeParameters)(props.model) && utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
21
22
|
" ",
|
|
22
23
|
context.typeParameters(props.model.typeParameters),
|
|
@@ -4,8 +4,8 @@ exports.getDefaultValue = exports.convert = exports.ParameterType = exports.Para
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
/** @enum */
|
|
6
6
|
exports.EmitStrategy = {
|
|
7
|
-
both: "both",
|
|
8
|
-
docs: "docs",
|
|
7
|
+
both: "both", // Emit both documentation and JS
|
|
8
|
+
docs: "docs", // Emit documentation, but not JS (default)
|
|
9
9
|
none: "none", // Emit nothing, just convert and run validation
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -46,6 +46,7 @@ class Options {
|
|
|
46
46
|
options.packageDir = packageDir;
|
|
47
47
|
options._readers = this._readers.filter((reader) => reader.supportsPackages);
|
|
48
48
|
options._declarations = new Map(this._declarations);
|
|
49
|
+
options.reset();
|
|
49
50
|
return options;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
@@ -85,7 +86,7 @@ class Options {
|
|
|
85
86
|
if (name != null) {
|
|
86
87
|
const declaration = this.getDeclaration(name);
|
|
87
88
|
if (!declaration) {
|
|
88
|
-
throw new Error(
|
|
89
|
+
throw new Error(`Cannot reset an option (${name}) which has not been declared.`);
|
|
89
90
|
}
|
|
90
91
|
this._values[declaration.name] = (0, declaration_2.getDefaultValue)(declaration);
|
|
91
92
|
this._setOptions.delete(declaration.name);
|
|
@@ -137,7 +138,7 @@ class Options {
|
|
|
137
138
|
}
|
|
138
139
|
isSet(name) {
|
|
139
140
|
if (!this._declarations.has(name)) {
|
|
140
|
-
throw new Error(
|
|
141
|
+
throw new Error(`Tried to check if an undefined option (${name}) was set`);
|
|
141
142
|
}
|
|
142
143
|
return this._setOptions.has(name);
|
|
143
144
|
}
|
|
@@ -157,7 +158,7 @@ class Options {
|
|
|
157
158
|
}
|
|
158
159
|
setValue(name, value, configPath) {
|
|
159
160
|
if (this.isFrozen()) {
|
|
160
|
-
throw new Error(
|
|
161
|
+
throw new Error(`Tried to modify an option (${name}) value after options have been frozen.`);
|
|
161
162
|
}
|
|
162
163
|
const declaration = this.getDeclaration(name);
|
|
163
164
|
if (!declaration) {
|
|
@@ -212,7 +213,7 @@ class Options {
|
|
|
212
213
|
*/
|
|
213
214
|
setCompilerOptions(fileNames, options, projectReferences) {
|
|
214
215
|
if (this.isFrozen()) {
|
|
215
|
-
throw new Error("Tried to modify
|
|
216
|
+
throw new Error("Tried to modify compiler options after options have been frozen.");
|
|
216
217
|
}
|
|
217
218
|
// We do this here instead of in the tsconfig reader so that API consumers which
|
|
218
219
|
// supply a program to `Converter.convert` instead of letting TypeDoc create one
|
|
@@ -264,7 +265,7 @@ function Option(name) {
|
|
|
264
265
|
return value;
|
|
265
266
|
},
|
|
266
267
|
set(_value) {
|
|
267
|
-
throw new Error(
|
|
268
|
+
throw new Error(`Options may not be set via the Option decorator when setting ${name}`);
|
|
268
269
|
},
|
|
269
270
|
};
|
|
270
271
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typedoc",
|
|
3
3
|
"description": "Create api documentation for TypeScript projects.",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.4",
|
|
5
5
|
"homepage": "https://typedoc.org",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"shiki": "^0.14.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x"
|
|
33
|
+
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/lunr": "^2.3.5",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"prettier": "3.0.3",
|
|
48
48
|
"puppeteer": "^13.5.2",
|
|
49
49
|
"ts-node": "^10.9.1",
|
|
50
|
-
"typescript": "5.
|
|
50
|
+
"typescript": "5.3.2"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
53
53
|
"/bin",
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
"test": "mocha --config .config/mocha.fast.json",
|
|
65
65
|
"test:cov": "c8 mocha --config .config/mocha.fast.json",
|
|
66
66
|
"doc:c": "node bin/typedoc --tsconfig src/test/converter/tsconfig.json",
|
|
67
|
-
"doc:c2": "node
|
|
67
|
+
"doc:c2": "node bin/typedoc --tsconfig src/test/converter2/tsconfig.json",
|
|
68
|
+
"doc:c2d": "node --inspect-brk bin/typedoc --tsconfig src/test/converter2/tsconfig.json",
|
|
69
|
+
"example": "cd example && node ../bin/typedoc",
|
|
68
70
|
"test:full": "c8 mocha --config .config/mocha.full.json",
|
|
69
71
|
"test:visual": "ts-node ./src/test/capture-screenshots.ts && ./scripts/compare_screenshots.sh",
|
|
70
72
|
"test:visual:accept": "node scripts/accept_visual_regression.js",
|
package/static/style.css
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
--light-color-text-aside: #6e6e6e;
|
|
12
12
|
--light-color-link: #1f70c2;
|
|
13
13
|
|
|
14
|
+
--light-color-ts-keyword: #056bd6;
|
|
14
15
|
--light-color-ts-project: #b111c9;
|
|
15
16
|
--light-color-ts-module: var(--light-color-ts-project);
|
|
16
17
|
--light-color-ts-namespace: var(--light-color-ts-project);
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
--dark-color-text-aside: #dddddd;
|
|
51
52
|
--dark-color-link: #00aff4;
|
|
52
53
|
|
|
54
|
+
--dark-color-ts-keyword: #3399ff;
|
|
53
55
|
--dark-color-ts-project: #e358ff;
|
|
54
56
|
--dark-color-ts-module: var(--dark-color-ts-project);
|
|
55
57
|
--dark-color-ts-namespace: var(--dark-color-ts-project);
|
|
@@ -91,6 +93,7 @@
|
|
|
91
93
|
--color-text-aside: var(--light-color-text-aside);
|
|
92
94
|
--color-link: var(--light-color-link);
|
|
93
95
|
|
|
96
|
+
--color-ts-keyword: var(--light-color-ts-keyword);
|
|
94
97
|
--color-ts-module: var(--light-color-ts-module);
|
|
95
98
|
--color-ts-namespace: var(--light-color-ts-namespace);
|
|
96
99
|
--color-ts-enum: var(--light-color-ts-enum);
|
|
@@ -132,6 +135,7 @@
|
|
|
132
135
|
--color-text-aside: var(--dark-color-text-aside);
|
|
133
136
|
--color-link: var(--dark-color-link);
|
|
134
137
|
|
|
138
|
+
--color-ts-keyword: var(--dark-color-ts-keyword);
|
|
135
139
|
--color-ts-module: var(--dark-color-ts-module);
|
|
136
140
|
--color-ts-namespace: var(--dark-color-ts-namespace);
|
|
137
141
|
--color-ts-enum: var(--dark-color-ts-enum);
|
|
@@ -180,6 +184,7 @@ body {
|
|
|
180
184
|
--color-text-aside: var(--light-color-text-aside);
|
|
181
185
|
--color-link: var(--light-color-link);
|
|
182
186
|
|
|
187
|
+
--color-ts-keyword: var(--light-color-ts-keyword);
|
|
183
188
|
--color-ts-module: var(--light-color-ts-module);
|
|
184
189
|
--color-ts-namespace: var(--light-color-ts-namespace);
|
|
185
190
|
--color-ts-enum: var(--light-color-ts-enum);
|
|
@@ -219,6 +224,7 @@ body {
|
|
|
219
224
|
--color-text-aside: var(--dark-color-text-aside);
|
|
220
225
|
--color-link: var(--dark-color-link);
|
|
221
226
|
|
|
227
|
+
--color-ts-keyword: var(--dark-color-ts-keyword);
|
|
222
228
|
--color-ts-module: var(--dark-color-ts-module);
|
|
223
229
|
--color-ts-namespace: var(--dark-color-ts-namespace);
|
|
224
230
|
--color-ts-enum: var(--dark-color-ts-enum);
|
|
@@ -984,6 +990,11 @@ a.tsd-index-link {
|
|
|
984
990
|
overflow-x: auto;
|
|
985
991
|
}
|
|
986
992
|
|
|
993
|
+
.tsd-signature-keyword {
|
|
994
|
+
color: var(--color-ts-keyword);
|
|
995
|
+
font-weight: normal;
|
|
996
|
+
}
|
|
997
|
+
|
|
987
998
|
.tsd-signature-symbol {
|
|
988
999
|
color: var(--color-text-aside);
|
|
989
1000
|
font-weight: normal;
|