typedoc 0.28.0-beta.1 → 0.28.0
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/index.d.ts +2 -2
- package/dist/lib/converter/context.d.ts +16 -6
- package/dist/lib/converter/context.js +39 -3
- package/dist/lib/converter/factories/signature.js +1 -1
- package/dist/lib/converter/factories/symbol-id.js +1 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +1 -1
- package/dist/lib/converter/plugins/SourcePlugin.js +1 -1
- package/dist/lib/converter/symbols.js +14 -4
- package/dist/lib/converter/types.js +16 -21
- package/dist/lib/models/ContainerReflection.d.ts +2 -2
- package/dist/lib/models/ContainerReflection.js +28 -4
- package/dist/lib/models/ProjectReflection.d.ts +1 -1
- package/dist/lib/models/ProjectReflection.js +1 -1
- package/dist/lib/models/ReflectionSymbolId.d.ts +10 -0
- package/dist/lib/models/ReflectionSymbolId.js +10 -0
- package/dist/lib/models/types.d.ts +1 -1
- package/dist/lib/models/types.js +7 -1
- package/dist/lib/output/components.d.ts +3 -3
- package/dist/lib/output/events.d.ts +4 -3
- package/dist/lib/output/events.js +4 -0
- package/dist/lib/output/formatter.d.ts +1 -0
- package/dist/lib/output/formatter.js +3 -0
- package/dist/lib/output/index.d.ts +1 -1
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +8 -2
- package/dist/lib/output/renderer.d.ts +2 -7
- package/dist/lib/output/renderer.js +6 -43
- package/dist/lib/output/router.d.ts +49 -37
- package/dist/lib/output/router.js +73 -47
- package/dist/lib/output/theme.d.ts +10 -3
- package/dist/lib/output/theme.js +8 -0
- package/dist/lib/output/themes/MarkedPlugin.js +21 -6
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +12 -6
- package/dist/lib/output/themes/default/DefaultTheme.js +281 -207
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +47 -40
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +9 -0
- package/dist/lib/output/themes/default/layouts/default.js +1 -1
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +1 -2
- package/dist/lib/output/themes/default/partials/anchor-icon.js +2 -9
- package/dist/lib/output/themes/default/partials/breadcrumb.js +2 -2
- package/dist/lib/output/themes/default/partials/comment.js +2 -3
- package/dist/lib/output/themes/default/partials/index.js +4 -6
- package/dist/lib/output/themes/default/partials/member.declaration.js +1 -1
- package/dist/lib/output/themes/default/partials/member.js +3 -5
- package/dist/lib/output/themes/default/partials/member.signature.body.js +2 -2
- package/dist/lib/output/themes/default/partials/member.signatures.js +2 -3
- package/dist/lib/output/themes/default/partials/members.js +2 -4
- package/dist/lib/output/themes/default/partials/moduleReflection.js +6 -10
- package/dist/lib/output/themes/default/partials/navigation.js +5 -7
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +8 -0
- package/dist/lib/output/themes/default/partials/typeDetails.d.ts +5 -5
- package/dist/lib/output/themes/default/partials/typeDetails.js +99 -53
- package/dist/lib/output/themes/default/partials/typeParameters.js +2 -3
- package/dist/lib/output/themes/default/templates/hierarchy.js +3 -5
- package/dist/lib/output/themes/default/templates/reflection.js +7 -3
- package/dist/lib/output/themes/lib.js +8 -4
- package/dist/lib/utils/highlighter.d.ts +1 -0
- package/dist/lib/utils/highlighter.js +16 -2
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.js +1 -0
- package/dist/lib/utils/options/defaults.js +2 -0
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
- package/dist/lib/utils/options/tsdoc-defaults.js +4 -0
- package/dist/lib/utils-common/jsx.elements.d.ts +16 -0
- package/dist/lib/utils-common/path.js +4 -1
- package/package.json +8 -8
- package/static/main.js +4 -4
- package/static/style.css +24 -18
- package/tsdoc.json +16 -0
- package/dist/lib/converter/factories/types.d.ts +0 -4
- package/dist/lib/converter/factories/types.js +0 -13
package/dist/index.d.ts
CHANGED
|
@@ -37,11 +37,11 @@ export * from "./lib/models/index.js";
|
|
|
37
37
|
/** @primaryExport */
|
|
38
38
|
export * as Configuration from "./lib/utils/options/index.js";
|
|
39
39
|
export { BaseRouter, CategoryRouter, DefaultTheme, DefaultThemeRenderContext, GroupRouter, IndexEvent, KindDirRouter, KindRouter, MarkdownEvent, PageEvent, PageKind, Renderer, RendererEvent, Slugger, StructureDirRouter, StructureRouter, Theme, } from "./lib/output/index.js";
|
|
40
|
-
export type { Icons, NavigationElement, PageDefinition, PageHeading, RendererEvents, RendererHooks, RenderTemplate, Router, } from "./lib/output/index.js";
|
|
40
|
+
export type { Icons, NavigationElement, PageDefinition, PageHeading, RendererEvents, RendererHooks, RenderTemplate, Router, RouterTarget, } from "./lib/output/index.js";
|
|
41
41
|
export { Outputs } from "./lib/output/output.js";
|
|
42
42
|
export { ArgumentsReader, CommentStyle, EntryPointStrategy, normalizePath, Option, OptionDefaults, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, ValidatingFileRegistry, } from "./lib/utils/index.js";
|
|
43
43
|
export type { ArrayDeclarationOption, BooleanDeclarationOption, DeclarationOption, DeclarationOptionBase, DeclarationOptionToOptionType, DocumentationEntryPoint, FancyConsoleLogger, FlagsDeclarationOption, JsDocCompatibility, KeyToDeclaration, ManuallyValidatedOption, MapDeclarationOption, MixedDeclarationOption, NumberDeclarationOption, ObjectDeclarationOption, OptionsReader, OutputSpecification, ParameterTypeToOptionTypeMap, SortStrategy, StringDeclarationOption, TypeDocOptionMap, TypeDocOptions, TypeDocOptionValues, ValidationOptions, } from "./lib/utils/index.js";
|
|
44
|
-
export { type ComponentPath, ConsoleLogger, type DeclarationReference, type EnumKeys, EventDispatcher, EventHooks, type GlobString, i18n, JSX, Logger, LogLevel, type Meaning, type MeaningKeyword, type MinimalNode, MinimalSourceFile, type NormalizedPath, type NormalizedPathOrModule, type SymbolReference, translateTagName, } from "#utils";
|
|
44
|
+
export { type ComponentPath, ConsoleLogger, type DeclarationReference, type EnumKeys, EventDispatcher, EventHooks, type GlobString, i18n, JSX, Logger, LogLevel, type Meaning, type MeaningKeyword, type MinimalNode, MinimalSourceFile, type NormalizedPath, type NormalizedPathOrModule, type SymbolReference, type TranslatedString, translateTagName, } from "#utils";
|
|
45
45
|
export { type Deserializable, Deserializer, type DeserializerComponent, JSONOutput, SerializeEvent, Serializer, type SerializerComponent, type SerializerEvents, } from "./lib/serialization/index.js";
|
|
46
46
|
export * as Internationalization from "./lib/internationalization/index.js";
|
|
47
47
|
export type { TranslatableStrings } from "./lib/internationalization/internationalization.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { DeclarationReflection, type DocumentReflection, type ProjectReflection, type Reflection, ReflectionKind } from "../models/index.js";
|
|
2
|
+
import { Comment, DeclarationReflection, type DocumentReflection, type ProjectReflection, ReferenceType, type Reflection, ReflectionKind } from "../models/index.js";
|
|
3
3
|
import type { Converter } from "./converter.js";
|
|
4
4
|
import { type NormalizedPath } from "#utils";
|
|
5
5
|
/**
|
|
@@ -35,6 +35,8 @@ export declare class Context {
|
|
|
35
35
|
convertingTypeNode: boolean;
|
|
36
36
|
convertingClassOrInterface: boolean;
|
|
37
37
|
shouldBeStatic: boolean;
|
|
38
|
+
inlineType: Set<string>;
|
|
39
|
+
preventInline: Set<string>;
|
|
38
40
|
private reflectionIdToSymbolMap;
|
|
39
41
|
/**
|
|
40
42
|
* Create a new Context instance.
|
|
@@ -58,6 +60,13 @@ export declare class Context {
|
|
|
58
60
|
createDeclarationReflection(kind: ReflectionKind, symbol: ts.Symbol | undefined, exportSymbol: ts.Symbol | undefined, nameOverride?: string): DeclarationReflection;
|
|
59
61
|
postReflectionCreation(reflection: Reflection, symbol: ts.Symbol | undefined, exportSymbol: ts.Symbol | undefined): void;
|
|
60
62
|
finalizeDeclarationReflection(reflection: DeclarationReflection): void;
|
|
63
|
+
/**
|
|
64
|
+
* Create a {@link ReferenceType} which points to the provided symbol.
|
|
65
|
+
*
|
|
66
|
+
* @privateRemarks
|
|
67
|
+
* This is available on Context so that it can be monkey-patched by typedoc-plugin-missing-exports
|
|
68
|
+
*/
|
|
69
|
+
createSymbolReference(symbol: ts.Symbol, context: Context, name?: string): ReferenceType;
|
|
61
70
|
addChild(reflection: DeclarationReflection | DocumentReflection): void;
|
|
62
71
|
shouldIgnore(symbol: ts.Symbol): boolean;
|
|
63
72
|
/**
|
|
@@ -72,10 +81,11 @@ export declare class Context {
|
|
|
72
81
|
getSymbolFromReflection(reflection: Reflection): ts.Symbol | undefined;
|
|
73
82
|
/** @internal */
|
|
74
83
|
setActiveProgram(program: ts.Program | undefined): void;
|
|
75
|
-
getComment(symbol: ts.Symbol, kind: ReflectionKind):
|
|
76
|
-
getNodeComment(node: ts.Node, moduleComment: boolean):
|
|
77
|
-
getFileComment(node: ts.SourceFile):
|
|
78
|
-
getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag):
|
|
79
|
-
getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature):
|
|
84
|
+
getComment(symbol: ts.Symbol, kind: ReflectionKind): Comment | undefined;
|
|
85
|
+
getNodeComment(node: ts.Node, moduleComment: boolean): Comment | undefined;
|
|
86
|
+
getFileComment(node: ts.SourceFile): Comment | undefined;
|
|
87
|
+
getJsDocComment(declaration: ts.JSDocPropertyLikeTag | ts.JSDocCallbackTag | ts.JSDocTypedefTag | ts.JSDocTemplateTag | ts.JSDocEnumTag): Comment | undefined;
|
|
88
|
+
getSignatureComment(declaration: ts.SignatureDeclaration | ts.JSDocSignature): Comment | undefined;
|
|
89
|
+
shouldInline(symbol: ts.Symbol, name: string): boolean;
|
|
80
90
|
withScope(scope: Reflection): Context;
|
|
81
91
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ok as assert } from "assert";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind, } from "../models/index.js";
|
|
3
|
+
import { Comment, ContainerReflection, DeclarationReflection, ReferenceType, ReflectionFlag, ReflectionKind, } from "../models/index.js";
|
|
4
4
|
import { isNamedNode } from "./utils/nodes.js";
|
|
5
5
|
import { ConverterEvents } from "./converter-events.js";
|
|
6
6
|
import { resolveAliasedSymbol } from "./utils/symbols.js";
|
|
7
7
|
import { getComment, getFileComment, getJsDocComment, getNodeComment, getSignatureComment } from "./comments/index.js";
|
|
8
|
-
import { getHumanName } from "../utils/tsutils.js";
|
|
9
|
-
import { normalizePath } from "#node-utils";
|
|
8
|
+
import { getHumanName, getQualifiedName } from "../utils/tsutils.js";
|
|
9
|
+
import { findPackageForPath, normalizePath } from "#node-utils";
|
|
10
10
|
import { createSymbolId } from "./factories/symbol-id.js";
|
|
11
11
|
import { removeIf } from "#utils";
|
|
12
12
|
/**
|
|
@@ -47,6 +47,8 @@ export class Context {
|
|
|
47
47
|
convertingTypeNode = false; // Inherited by withScope
|
|
48
48
|
convertingClassOrInterface = false; // Not inherited
|
|
49
49
|
shouldBeStatic = false; // Not inherited
|
|
50
|
+
inlineType = new Set(); // Inherited by withScope
|
|
51
|
+
preventInline = new Set(); // Inherited by withScope
|
|
50
52
|
reflectionIdToSymbolMap = new Map();
|
|
51
53
|
/**
|
|
52
54
|
* Create a new Context instance.
|
|
@@ -165,6 +167,21 @@ export class Context {
|
|
|
165
167
|
this.converter.processDocumentTags(reflection, reflection);
|
|
166
168
|
}
|
|
167
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Create a {@link ReferenceType} which points to the provided symbol.
|
|
172
|
+
*
|
|
173
|
+
* @privateRemarks
|
|
174
|
+
* This is available on Context so that it can be monkey-patched by typedoc-plugin-missing-exports
|
|
175
|
+
*/
|
|
176
|
+
createSymbolReference(symbol, context, name) {
|
|
177
|
+
const ref = ReferenceType.createUnresolvedReference(name ?? symbol.name, createSymbolId(symbol), context.project, getQualifiedName(symbol, name ?? symbol.name));
|
|
178
|
+
ref.refersToTypeParameter = !!(symbol.flags & ts.SymbolFlags.TypeParameter);
|
|
179
|
+
const symbolPath = symbol.declarations?.[0]?.getSourceFile().fileName;
|
|
180
|
+
if (!symbolPath)
|
|
181
|
+
return ref;
|
|
182
|
+
ref.package = findPackageForPath(symbolPath)?.[0];
|
|
183
|
+
return ref;
|
|
184
|
+
}
|
|
168
185
|
addChild(reflection) {
|
|
169
186
|
if (this.scope instanceof ContainerReflection) {
|
|
170
187
|
this.scope.addChild(reflection);
|
|
@@ -233,12 +250,31 @@ export class Context {
|
|
|
233
250
|
getSignatureComment(declaration) {
|
|
234
251
|
return getSignatureComment(declaration, this.converter.config, this.logger, this.checker, this.project.files);
|
|
235
252
|
}
|
|
253
|
+
shouldInline(symbol, name) {
|
|
254
|
+
if (this.preventInline.has(name))
|
|
255
|
+
return false;
|
|
256
|
+
if (this.inlineType.has(name))
|
|
257
|
+
return true;
|
|
258
|
+
return this
|
|
259
|
+
.getComment(symbol, ReflectionKind.Interface)
|
|
260
|
+
?.hasModifier("@inline") ?? false;
|
|
261
|
+
}
|
|
236
262
|
withScope(scope) {
|
|
237
263
|
assert(scope.parent === this.scope || scope === this.scope, "Incorrect context used for withScope");
|
|
238
264
|
const context = new Context(this.converter, this.programs, this.project, scope);
|
|
239
265
|
context.convertingTypeNode = this.convertingTypeNode;
|
|
240
266
|
context.setActiveProgram(this._program);
|
|
241
267
|
context.reflectionIdToSymbolMap = this.reflectionIdToSymbolMap;
|
|
268
|
+
context.preventInline = new Set(this.preventInline);
|
|
269
|
+
context.inlineType = new Set(this.inlineType);
|
|
270
|
+
for (const tag of scope.comment?.blockTags || []) {
|
|
271
|
+
if (tag.tag === "@preventInline") {
|
|
272
|
+
context.preventInline.add(Comment.combineDisplayParts(tag.content));
|
|
273
|
+
}
|
|
274
|
+
else if (tag.tag === "@inlineType") {
|
|
275
|
+
context.inlineType.add(Comment.combineDisplayParts(tag.content));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
242
278
|
return context;
|
|
243
279
|
}
|
|
244
280
|
}
|
|
@@ -16,7 +16,6 @@ export function createSignature(context, kind, signature, symbol, declaration) {
|
|
|
16
16
|
if (context.shouldBeStatic) {
|
|
17
17
|
sigRef.setFlag(ReflectionFlag.Static);
|
|
18
18
|
}
|
|
19
|
-
const sigRefCtx = context.withScope(sigRef);
|
|
20
19
|
if (symbol && declaration) {
|
|
21
20
|
context.project.registerSymbolId(sigRef, createSymbolId(symbol, declaration));
|
|
22
21
|
}
|
|
@@ -34,6 +33,7 @@ export function createSignature(context, kind, signature, symbol, declaration) {
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
}
|
|
36
|
+
const sigRefCtx = context.withScope(sigRef);
|
|
37
37
|
sigRef.typeParameters = convertTypeParameters(sigRefCtx, sigRef, signature.typeParameters);
|
|
38
38
|
const parameterSymbols = signature.thisParameter
|
|
39
39
|
? [signature.thisParameter, ...signature.parameters]
|
|
@@ -45,6 +45,6 @@ export class MergeModuleWithPlugin extends ConverterComponent {
|
|
|
45
45
|
tempRefl = tempRefl.parent;
|
|
46
46
|
}
|
|
47
47
|
this.application.logger.verbose(`Merging ${refl.getFullName()} into ${target.getFullName()}`);
|
|
48
|
-
project.
|
|
48
|
+
project.mergeReflections(refl, target);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -113,8 +113,8 @@ let SourcePlugin = (() => {
|
|
|
113
113
|
this.owner.on(ConverterEvents.RESOLVE_BEGIN, this.onBeginResolve.bind(this));
|
|
114
114
|
}
|
|
115
115
|
onEnd() {
|
|
116
|
-
// Should probably clear repositories/ignoredPaths here, but these aren't likely to change between runs...
|
|
117
116
|
this.fileNames.clear();
|
|
117
|
+
delete this.repositories;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Triggered when the converter has created a declaration reflection.
|
|
@@ -116,7 +116,8 @@ function _convertSymbolNow(context, symbol, exportSymbol) {
|
|
|
116
116
|
export function convertSymbol(context, symbol, exportSymbol) {
|
|
117
117
|
// #1795, defer conversion of symbols named `default` so that if a function
|
|
118
118
|
// is default exported and also exported with a name, the name takes precedence
|
|
119
|
-
if ((exportSymbol?.name ?? symbol.name) === "default"
|
|
119
|
+
if ((exportSymbol?.name ?? symbol.name) === "default" &&
|
|
120
|
+
context.scope.kindOf(ReflectionKind.ExportContainer)) {
|
|
120
121
|
context.converter.deferConversion(() => {
|
|
121
122
|
_convertSymbolNow(context, symbol, exportSymbol);
|
|
122
123
|
});
|
|
@@ -204,6 +205,7 @@ function convertTypeAlias(context, symbol, exportSymbol) {
|
|
|
204
205
|
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
|
|
205
206
|
}
|
|
206
207
|
const reflection = context.createDeclarationReflection(ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
208
|
+
context.finalizeDeclarationReflection(reflection);
|
|
207
209
|
if (reflection.comment?.hasModifier("@useDeclaredType")) {
|
|
208
210
|
reflection.comment.removeModifier("@useDeclaredType");
|
|
209
211
|
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getDeclaredTypeOfSymbol(symbol));
|
|
@@ -214,9 +216,17 @@ function convertTypeAlias(context, symbol, exportSymbol) {
|
|
|
214
216
|
if (reflection.type.type === "union") {
|
|
215
217
|
attachUnionComments(context, declaration, reflection.type);
|
|
216
218
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
else if (reflection.type.type === "reflection" && reflection.type.declaration.children) {
|
|
220
|
+
// #2817 lift properties of object literal types up to the reflection level.
|
|
221
|
+
const typeDecl = reflection.type.declaration;
|
|
222
|
+
reflection.project.mergeReflections(typeDecl, reflection);
|
|
223
|
+
delete reflection.type;
|
|
224
|
+
// When created any signatures will be created with __type as their
|
|
225
|
+
// name, rename them so that they have the alias's name as their name
|
|
226
|
+
for (const sig of reflection.signatures || []) {
|
|
227
|
+
sig.name = reflection.name;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
220
230
|
reflection.typeParameters = declaration.typeParameters?.map((param) => createTypeParamReflection(param, context.withScope(reflection)));
|
|
221
231
|
}
|
|
222
232
|
else if (ts.isJSDocTypedefTag(declaration) ||
|
|
@@ -8,7 +8,6 @@ import { convertParameterNodes, convertTypeParameterNodes, createSignature } fro
|
|
|
8
8
|
import { convertSymbol } from "./symbols.js";
|
|
9
9
|
import { isObjectType, isTypeReference } from "./utils/nodes.js";
|
|
10
10
|
import { removeUndefined } from "./utils/reflections.js";
|
|
11
|
-
import { createSymbolReference } from "./factories/types.js";
|
|
12
11
|
import { createSymbolId } from "./factories/symbol-id.js";
|
|
13
12
|
const converters = new Map();
|
|
14
13
|
export function loadConverters() {
|
|
@@ -189,7 +188,7 @@ const exprWithTypeArgsConverter = {
|
|
|
189
188
|
return convertType(context, context.checker.getTypeAtLocation(node));
|
|
190
189
|
}
|
|
191
190
|
const parameters = node.typeArguments?.map((type) => convertType(context, type)) ?? [];
|
|
192
|
-
const ref = createSymbolReference(context.resolveAliasedSymbol(targetSymbol), context);
|
|
191
|
+
const ref = context.createSymbolReference(context.resolveAliasedSymbol(targetSymbol), context);
|
|
193
192
|
ref.typeArguments = parameters;
|
|
194
193
|
return ref;
|
|
195
194
|
},
|
|
@@ -239,12 +238,12 @@ const importType = {
|
|
|
239
238
|
if (!symbol) {
|
|
240
239
|
return new IntrinsicType("any");
|
|
241
240
|
}
|
|
242
|
-
return createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
241
|
+
return context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
243
242
|
},
|
|
244
243
|
convertType(context, type) {
|
|
245
244
|
const symbol = type.getSymbol();
|
|
246
245
|
assert(symbol, "Missing symbol when converting import type"); // Should be a compiler error
|
|
247
|
-
return createSymbolReference(context.resolveAliasedSymbol(symbol), context, "__module");
|
|
246
|
+
return context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, "__module");
|
|
248
247
|
},
|
|
249
248
|
};
|
|
250
249
|
const indexedAccessConverter = {
|
|
@@ -413,7 +412,7 @@ const queryConverter = {
|
|
|
413
412
|
// on a variable typed as `any` with a name that doesn't exist.
|
|
414
413
|
return new QueryType(ReferenceType.createBrokenReference(node.exprName.getText(), context.project));
|
|
415
414
|
}
|
|
416
|
-
const ref = createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText());
|
|
415
|
+
const ref = context.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText());
|
|
417
416
|
ref.preferValues = true;
|
|
418
417
|
return new QueryType(ref);
|
|
419
418
|
},
|
|
@@ -422,7 +421,7 @@ const queryConverter = {
|
|
|
422
421
|
// an instantiation expression we get the user's exprName.
|
|
423
422
|
const symbol = context.getSymbolAtLocation(node.exprName) || type.getSymbol();
|
|
424
423
|
assert(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`);
|
|
425
|
-
const ref = createSymbolReference(context.resolveAliasedSymbol(symbol), context);
|
|
424
|
+
const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context);
|
|
426
425
|
ref.preferValues = true;
|
|
427
426
|
return new QueryType(ref);
|
|
428
427
|
},
|
|
@@ -436,20 +435,18 @@ const referenceConverter = {
|
|
|
436
435
|
return new ArrayType(convertType(context, node.typeArguments?.[0]));
|
|
437
436
|
}
|
|
438
437
|
const symbol = context.expectSymbolAtLocation(node.typeName);
|
|
438
|
+
const name = node.typeName.getText();
|
|
439
439
|
// Ignore @inline if there are type arguments, as they won't be resolved
|
|
440
440
|
// in the type we just retrieved from node.typeName.
|
|
441
441
|
if (!node.typeArguments &&
|
|
442
|
-
context
|
|
443
|
-
.getComment(symbol, ReflectionKind.Interface)
|
|
444
|
-
?.hasModifier("@inline")) {
|
|
442
|
+
context.shouldInline(symbol, name)) {
|
|
445
443
|
// typeLiteralConverter doesn't use the node, so we can get away with lying here.
|
|
446
444
|
// This might not actually be safe, it appears that it is in the relatively small
|
|
447
445
|
// amount of testing I've done with it, but I wouldn't be surprised if someone manages
|
|
448
446
|
// to find a crash.
|
|
449
447
|
return typeLiteralConverter.convertType(context, type, null, undefined);
|
|
450
448
|
}
|
|
451
|
-
const
|
|
452
|
-
const ref = createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
449
|
+
const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
453
450
|
ref.typeArguments = node.typeArguments?.map((type) => convertType(context, type));
|
|
454
451
|
return ref;
|
|
455
452
|
},
|
|
@@ -465,15 +462,6 @@ const referenceConverter = {
|
|
|
465
462
|
ref.refersToTypeParameter = true;
|
|
466
463
|
return ref;
|
|
467
464
|
}
|
|
468
|
-
if (context
|
|
469
|
-
.getComment(symbol, ReflectionKind.Interface)
|
|
470
|
-
?.hasModifier("@inline")) {
|
|
471
|
-
// typeLiteralConverter doesn't use the node, so we can get away with lying here.
|
|
472
|
-
// This might not actually be safe, it appears that it is in the relatively small
|
|
473
|
-
// amount of testing I've done with it, but I wouldn't be surprised if someone manages
|
|
474
|
-
// to find a crash.
|
|
475
|
-
return typeLiteralConverter.convertType(context, type, null, undefined);
|
|
476
|
-
}
|
|
477
465
|
let name;
|
|
478
466
|
if (ts.isIdentifier(node.typeName)) {
|
|
479
467
|
name = node.typeName.text;
|
|
@@ -481,7 +469,14 @@ const referenceConverter = {
|
|
|
481
469
|
else {
|
|
482
470
|
name = node.typeName.right.text;
|
|
483
471
|
}
|
|
484
|
-
|
|
472
|
+
if (context.shouldInline(symbol, name)) {
|
|
473
|
+
// typeLiteralConverter doesn't use the node, so we can get away with lying here.
|
|
474
|
+
// This might not actually be safe, it appears that it is in the relatively small
|
|
475
|
+
// amount of testing I've done with it, but I wouldn't be surprised if someone manages
|
|
476
|
+
// to find a crash.
|
|
477
|
+
return typeLiteralConverter.convertType(context, type, null, undefined);
|
|
478
|
+
}
|
|
479
|
+
const ref = context.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
485
480
|
if (type.flags & ts.TypeFlags.Substitution) {
|
|
486
481
|
// NoInfer<T>
|
|
487
482
|
ref.typeArguments = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Reflection, type TraverseCallback } from "./Reflection.js";
|
|
2
2
|
import { ReflectionCategory } from "./ReflectionCategory.js";
|
|
3
3
|
import { ReflectionGroup } from "./ReflectionGroup.js";
|
|
4
|
-
import
|
|
4
|
+
import { ReflectionKind } from "./kind.js";
|
|
5
5
|
import type { Deserializer, JSONOutput, Serializer } from "#serialization";
|
|
6
6
|
import type { DocumentReflection } from "./DocumentReflection.js";
|
|
7
7
|
import type { DeclarationReflection } from "./DeclarationReflection.js";
|
|
@@ -47,7 +47,7 @@ export declare abstract class ContainerReflection extends Reflection {
|
|
|
47
47
|
* @returns An array containing all children with the desired kind.
|
|
48
48
|
*/
|
|
49
49
|
getChildrenByKind(kind: ReflectionKind): DeclarationReflection[];
|
|
50
|
-
addChild(child:
|
|
50
|
+
addChild(child: Reflection): void;
|
|
51
51
|
removeChild(child: DeclarationReflection | DocumentReflection): void;
|
|
52
52
|
traverse(callback: TraverseCallback): void;
|
|
53
53
|
toObject(serializer: Serializer): JSONOutput.ContainerReflection;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Reflection, TraverseProperty } from "./Reflection.js";
|
|
2
2
|
import { ReflectionCategory } from "./ReflectionCategory.js";
|
|
3
3
|
import { ReflectionGroup } from "./ReflectionGroup.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ReflectionKind } from "./kind.js";
|
|
5
|
+
import { assertNever, removeIfPresent } from "#utils";
|
|
5
6
|
/**
|
|
6
7
|
* @category Reflections
|
|
7
8
|
*/
|
|
@@ -50,13 +51,36 @@ export class ContainerReflection extends Reflection {
|
|
|
50
51
|
if (child.isDeclaration()) {
|
|
51
52
|
this.children ||= [];
|
|
52
53
|
this.children.push(child);
|
|
54
|
+
this.childrenIncludingDocuments ||= [];
|
|
55
|
+
this.childrenIncludingDocuments.push(child);
|
|
53
56
|
}
|
|
54
|
-
else {
|
|
57
|
+
else if (child.isDocument()) {
|
|
55
58
|
this.documents ||= [];
|
|
56
59
|
this.documents.push(child);
|
|
60
|
+
this.childrenIncludingDocuments ||= [];
|
|
61
|
+
this.childrenIncludingDocuments.push(child);
|
|
62
|
+
}
|
|
63
|
+
else if (this.isDeclaration() && child.isSignature()) {
|
|
64
|
+
switch (child.kind) {
|
|
65
|
+
case ReflectionKind.CallSignature:
|
|
66
|
+
case ReflectionKind.ConstructorSignature:
|
|
67
|
+
this.signatures ||= [];
|
|
68
|
+
this.signatures.push(child);
|
|
69
|
+
break;
|
|
70
|
+
case ReflectionKind.IndexSignature:
|
|
71
|
+
this.indexSignatures ||= [];
|
|
72
|
+
this.indexSignatures.push(child);
|
|
73
|
+
break;
|
|
74
|
+
case ReflectionKind.GetSignature:
|
|
75
|
+
case ReflectionKind.SetSignature:
|
|
76
|
+
throw new Error("Unsupported child type: " + ReflectionKind[child.kind]);
|
|
77
|
+
default:
|
|
78
|
+
assertNever(child.kind);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error("Unsupported child type: " + ReflectionKind[child.kind]);
|
|
57
83
|
}
|
|
58
|
-
this.childrenIncludingDocuments ||= [];
|
|
59
|
-
this.childrenIncludingDocuments.push(child);
|
|
60
84
|
}
|
|
61
85
|
removeChild(child) {
|
|
62
86
|
if (child.isDeclaration()) {
|
|
@@ -82,7 +82,7 @@ export declare class ProjectReflection extends ContainerReflection {
|
|
|
82
82
|
*/
|
|
83
83
|
removeReflection(reflection: Reflection): void;
|
|
84
84
|
/** @internal */
|
|
85
|
-
|
|
85
|
+
mergeReflections(source: DeclarationReflection, target: DeclarationReflection | ProjectReflection): void;
|
|
86
86
|
/**
|
|
87
87
|
* Remove a reflection without updating the parent reflection to remove references to the removed reflection.
|
|
88
88
|
*/
|
|
@@ -168,7 +168,7 @@ export class ProjectReflection extends ContainerReflection {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
/** @internal */
|
|
171
|
-
|
|
171
|
+
mergeReflections(source, target) {
|
|
172
172
|
// First, tell the children about their new parent
|
|
173
173
|
delete this.referenceGraph;
|
|
174
174
|
const oldChildrenIds = this.reflectionChildren.getNoInsert(source.id) || [];
|
|
@@ -46,6 +46,16 @@ export declare class ReflectionSymbolId {
|
|
|
46
46
|
* Note: This can only be non-NaN if {@link pos} is finite.
|
|
47
47
|
*/
|
|
48
48
|
transientId: number;
|
|
49
|
+
/**
|
|
50
|
+
* Note: This is **not** serialized, only {@link packageName} and {@link packagePath} path
|
|
51
|
+
* information is preserved when serializing. This is set so that it is available to plugins
|
|
52
|
+
* when initially converting a project.
|
|
53
|
+
*
|
|
54
|
+
* @privateRemarks
|
|
55
|
+
* This is used by typedoc-plugin-dt-links to determine the path to read to get the source
|
|
56
|
+
* code of a definitely typed package.
|
|
57
|
+
*/
|
|
58
|
+
fileName?: NormalizedPath;
|
|
49
59
|
constructor(json: JSONOutput.ReflectionSymbolId);
|
|
50
60
|
getStableKey(): ReflectionSymbolIdString;
|
|
51
61
|
toDeclarationReference(): DeclarationReference;
|
|
@@ -40,6 +40,16 @@ export class ReflectionSymbolId {
|
|
|
40
40
|
* Note: This can only be non-NaN if {@link pos} is finite.
|
|
41
41
|
*/
|
|
42
42
|
transientId = NaN;
|
|
43
|
+
/**
|
|
44
|
+
* Note: This is **not** serialized, only {@link packageName} and {@link packagePath} path
|
|
45
|
+
* information is preserved when serializing. This is set so that it is available to plugins
|
|
46
|
+
* when initially converting a project.
|
|
47
|
+
*
|
|
48
|
+
* @privateRemarks
|
|
49
|
+
* This is used by typedoc-plugin-dt-links to determine the path to read to get the source
|
|
50
|
+
* code of a definitely typed package.
|
|
51
|
+
*/
|
|
52
|
+
fileName;
|
|
43
53
|
constructor(json) {
|
|
44
54
|
this.packageName = json.packageName;
|
|
45
55
|
this.packagePath = json.packagePath;
|
|
@@ -415,7 +415,7 @@ export declare class ReflectionType extends Type {
|
|
|
415
415
|
readonly type = "reflection";
|
|
416
416
|
constructor(declaration: DeclarationReflection);
|
|
417
417
|
protected getTypeString(): string;
|
|
418
|
-
needsParenthesis(): boolean;
|
|
418
|
+
needsParenthesis(where: TypeContext): boolean;
|
|
419
419
|
toObject(serializer: Serializer): JSONOutput.ReflectionType;
|
|
420
420
|
}
|
|
421
421
|
/**
|
package/dist/lib/models/types.js
CHANGED
|
@@ -917,7 +917,13 @@ export class ReflectionType extends Type {
|
|
|
917
917
|
}
|
|
918
918
|
return `{ ${parts.join("; ")} }`;
|
|
919
919
|
}
|
|
920
|
-
needsParenthesis() {
|
|
920
|
+
needsParenthesis(where) {
|
|
921
|
+
if (this.declaration.children || this.declaration.indexSignatures) {
|
|
922
|
+
return false;
|
|
923
|
+
}
|
|
924
|
+
if (this.declaration.signatures?.length === 1) {
|
|
925
|
+
return where === TypeContext.arrayElement || where === TypeContext.unionElement;
|
|
926
|
+
}
|
|
921
927
|
return false;
|
|
922
928
|
}
|
|
923
929
|
toObject(serializer) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractComponent } from "../utils/component.js";
|
|
2
|
-
import type { ProjectReflection
|
|
2
|
+
import type { ProjectReflection } from "../models/index.js";
|
|
3
3
|
import type { Renderer } from "./renderer.js";
|
|
4
4
|
import { PageEvent, RendererEvent } from "./events.js";
|
|
5
5
|
export declare abstract class RendererComponent extends AbstractComponent<Renderer, {}> {
|
|
@@ -15,7 +15,7 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
|
|
|
15
15
|
/**
|
|
16
16
|
* The reflection that is currently processed.
|
|
17
17
|
*/
|
|
18
|
-
protected page?: PageEvent
|
|
18
|
+
protected page?: PageEvent;
|
|
19
19
|
/**
|
|
20
20
|
* The url of the document that is being currently generated.
|
|
21
21
|
* Set when a page begins rendering.
|
|
@@ -49,5 +49,5 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
|
|
|
49
49
|
*
|
|
50
50
|
* @param page An event object describing the current render operation.
|
|
51
51
|
*/
|
|
52
|
-
protected onBeginPage(page: PageEvent
|
|
52
|
+
protected onBeginPage(page: PageEvent): void;
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProjectReflection } from "../models/ProjectReflection.js";
|
|
2
|
-
import type
|
|
3
|
-
import type { PageDefinition, PageKind } from "./router.js";
|
|
2
|
+
import { type DeclarationReflection, type DocumentReflection, Reflection, type ReflectionKind } from "../models/index.js";
|
|
3
|
+
import type { PageDefinition, PageKind, RouterTarget } from "./router.js";
|
|
4
4
|
/**
|
|
5
5
|
* An event emitted by the {@link Renderer} class at the very beginning and
|
|
6
6
|
* ending of the entire rendering process.
|
|
@@ -47,7 +47,7 @@ export interface PageHeading {
|
|
|
47
47
|
* @see {@link Renderer.EVENT_BEGIN_PAGE}
|
|
48
48
|
* @see {@link Renderer.EVENT_END_PAGE}
|
|
49
49
|
*/
|
|
50
|
-
export declare class PageEvent<out Model =
|
|
50
|
+
export declare class PageEvent<out Model extends RouterTarget = RouterTarget> {
|
|
51
51
|
/**
|
|
52
52
|
* The project the renderer is currently processing.
|
|
53
53
|
*/
|
|
@@ -102,6 +102,7 @@ export declare class PageEvent<out Model = unknown> {
|
|
|
102
102
|
*/
|
|
103
103
|
static readonly END = "endPage";
|
|
104
104
|
constructor(model: Model);
|
|
105
|
+
isReflectionEvent(): this is PageEvent<Reflection>;
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Reflection, } from "../models/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* An event emitted by the {@link Renderer} class at the very beginning and
|
|
3
4
|
* ending of the entire rendering process.
|
|
@@ -106,6 +107,9 @@ export class PageEvent {
|
|
|
106
107
|
constructor(model) {
|
|
107
108
|
this.model = model;
|
|
108
109
|
}
|
|
110
|
+
isReflectionEvent() {
|
|
111
|
+
return this.model instanceof Reflection;
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
/**
|
|
111
115
|
* An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
|
|
@@ -70,6 +70,7 @@ export declare class FormattedCodeBuilder {
|
|
|
70
70
|
reflection(reflection: DeclarationReflection, options: {
|
|
71
71
|
topLevelLinks: boolean;
|
|
72
72
|
}): FormatterNode;
|
|
73
|
+
typeAlias(item: DeclarationReflection): FormatterNode;
|
|
73
74
|
interface(item: DeclarationReflection): FormatterNode;
|
|
74
75
|
member(members: FormatterNode[], item: DeclarationReflection, options: {
|
|
75
76
|
topLevelLinks: boolean;
|
|
@@ -515,6 +515,9 @@ export class FormattedCodeBuilder {
|
|
|
515
515
|
}
|
|
516
516
|
return simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, "{}"));
|
|
517
517
|
}
|
|
518
|
+
typeAlias(item) {
|
|
519
|
+
return nodes(simpleElement(JSX.createElement("span", { class: "tsd-signature-keyword" }, "type")), space(), simpleElement(JSX.createElement("span", { class: getKindClass(item) }, item.name)), this.typeParameters(item), space(), simpleElement(JSX.createElement("span", { class: "tsd-signature-symbol" }, "=")), space(), this.reflection(item, { topLevelLinks: true }));
|
|
520
|
+
}
|
|
518
521
|
interface(item) {
|
|
519
522
|
return nodes(simpleElement(JSX.createElement("span", { class: "tsd-signature-keyword" }, "interface")), space(), simpleElement(JSX.createElement("span", { class: getKindClass(item) }, item.name)), this.typeParameters(item), space(), this.reflection(item, { topLevelLinks: true }));
|
|
520
523
|
}
|
|
@@ -6,4 +6,4 @@ export { DefaultTheme, type NavigationElement, type RenderTemplate } from "./the
|
|
|
6
6
|
export { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext.js";
|
|
7
7
|
export type { Icons } from "./themes/default/partials/icon.js";
|
|
8
8
|
export { Slugger } from "./themes/default/Slugger.js";
|
|
9
|
-
export { BaseRouter, CategoryRouter, GroupRouter, KindDirRouter, KindRouter, type PageDefinition, PageKind, type Router, StructureDirRouter, StructureRouter, } from "./router.js";
|
|
9
|
+
export { BaseRouter, CategoryRouter, GroupRouter, KindDirRouter, KindRouter, type PageDefinition, PageKind, type Router, type RouterTarget, StructureDirRouter, StructureRouter, } from "./router.js";
|
|
@@ -34,6 +34,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
34
34
|
};
|
|
35
35
|
import * as Path from "path";
|
|
36
36
|
import lunr from "lunr";
|
|
37
|
+
import { Reflection } from "../../models/index.js";
|
|
37
38
|
import { RendererComponent } from "../components.js";
|
|
38
39
|
import { IndexEvent, RendererEvent } from "../events.js";
|
|
39
40
|
import { Option, writeFile } from "../../utils/index.js";
|
|
@@ -112,8 +113,9 @@ let JavascriptIndexPlugin = (() => {
|
|
|
112
113
|
const theme = this.owner.theme;
|
|
113
114
|
const rows = [];
|
|
114
115
|
const initialSearchResults = this.owner
|
|
115
|
-
.router.
|
|
116
|
-
.filter((refl) =>
|
|
116
|
+
.router.getLinkTargets()
|
|
117
|
+
.filter((refl) => refl instanceof Reflection &&
|
|
118
|
+
(refl.isDeclaration() || refl.isDocument()) &&
|
|
117
119
|
refl.name &&
|
|
118
120
|
!refl.flags.isExternal);
|
|
119
121
|
const indexEvent = new IndexEvent(initialSearchResults);
|
|
@@ -139,6 +141,10 @@ let JavascriptIndexPlugin = (() => {
|
|
|
139
141
|
url: theme.router.getFullUrl(reflection),
|
|
140
142
|
classes: theme.getReflectionClasses(reflection),
|
|
141
143
|
};
|
|
144
|
+
const icon = theme.getReflectionIcon(reflection);
|
|
145
|
+
if (icon !== reflection.kind) {
|
|
146
|
+
row.icon = icon;
|
|
147
|
+
}
|
|
142
148
|
if (parent) {
|
|
143
149
|
row.parent = parent.getFullName();
|
|
144
150
|
}
|
|
@@ -79,8 +79,8 @@ export interface RendererHooks {
|
|
|
79
79
|
}
|
|
80
80
|
export interface RendererEvents {
|
|
81
81
|
beginRender: [RendererEvent];
|
|
82
|
-
beginPage: [PageEvent
|
|
83
|
-
endPage: [PageEvent
|
|
82
|
+
beginPage: [PageEvent];
|
|
83
|
+
endPage: [PageEvent];
|
|
84
84
|
endRender: [RendererEvent];
|
|
85
85
|
parseMarkdown: [MarkdownEvent];
|
|
86
86
|
prepareIndex: [IndexEvent];
|
|
@@ -177,10 +177,6 @@ export declare class Renderer extends AbstractComponent<Application, RendererEve
|
|
|
177
177
|
private accessor githubPages;
|
|
178
178
|
/** @internal */
|
|
179
179
|
accessor cacheBust: boolean;
|
|
180
|
-
private accessor lightTheme;
|
|
181
|
-
private accessor darkTheme;
|
|
182
|
-
private accessor highlightLanguages;
|
|
183
|
-
private accessor ignoredHighlightLanguages;
|
|
184
180
|
private accessor pretty;
|
|
185
181
|
renderStartTime: number;
|
|
186
182
|
markedPlugin: MarkedPlugin;
|
|
@@ -207,7 +203,6 @@ export declare class Renderer extends AbstractComponent<Application, RendererEve
|
|
|
207
203
|
*/
|
|
208
204
|
render(project: ProjectReflection, outputDirectory: string): Promise<void>;
|
|
209
205
|
private runPreRenderJobs;
|
|
210
|
-
private loadHighlighter;
|
|
211
206
|
/**
|
|
212
207
|
* Render a single page.
|
|
213
208
|
*
|