typedoc 0.23.14 → 0.23.15
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/converter.d.ts +1 -1
- package/dist/lib/converter/converter.js +2 -2
- package/dist/lib/converter/factories/signature.js +6 -1
- package/dist/lib/converter/jsdoc.js +41 -0
- package/dist/lib/converter/symbols.js +1 -0
- package/dist/lib/converter/types.js +3 -5
- package/dist/lib/converter/utils/nodes.d.ts +1 -0
- package/dist/lib/converter/utils/nodes.js +5 -1
- package/dist/lib/models/reflections/declaration.d.ts +12 -0
- package/dist/lib/models/reflections/declaration.js +17 -1
- package/dist/lib/models/reflections/index.d.ts +1 -1
- package/dist/lib/models/reflections/index.js +2 -1
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/hierarchy.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/hierarchy.js +12 -5
- package/dist/lib/output/themes/default/partials/member.declaration.js +1 -3
- package/dist/lib/output/themes/default/partials/member.signature.body.js +1 -3
- package/package.json +1 -1
- package/static/widgets.png +0 -0
- package/static/widgets@2x.png +0 -0
|
@@ -104,7 +104,7 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
104
104
|
*/
|
|
105
105
|
convert(entryPoints: readonly DocumentationEntryPoint[]): ProjectReflection;
|
|
106
106
|
/** @internal */
|
|
107
|
-
convertSymbol(context: Context, symbol: ts.Symbol): void;
|
|
107
|
+
convertSymbol(context: Context, symbol: ts.Symbol, exportSymbol?: ts.Symbol): void;
|
|
108
108
|
/**
|
|
109
109
|
* Convert the given TypeScript type into its TypeDoc type reflection.
|
|
110
110
|
*
|
|
@@ -72,8 +72,8 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
72
72
|
return project;
|
|
73
73
|
}
|
|
74
74
|
/** @internal */
|
|
75
|
-
convertSymbol(context, symbol) {
|
|
76
|
-
(0, symbols_1.convertSymbol)(context, symbol);
|
|
75
|
+
convertSymbol(context, symbol, exportSymbol) {
|
|
76
|
+
(0, symbols_1.convertSymbol)(context, symbol, exportSymbol);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Convert the given TypeScript type into its TypeDoc type reflection.
|
|
@@ -15,7 +15,12 @@ function createSignature(context, kind, signature, declaration) {
|
|
|
15
15
|
const sigRef = new models_1.SignatureReflection(kind == models_1.ReflectionKind.ConstructorSignature
|
|
16
16
|
? `new ${context.scope.parent.name}`
|
|
17
17
|
: context.scope.name, kind, context.scope);
|
|
18
|
-
|
|
18
|
+
// If we are creating signatures for a variable and the variable has a comment associated with it
|
|
19
|
+
// then we should prefer that variable's comment over any comment on the signature. The comment plugin
|
|
20
|
+
// will copy the comment down if this signature doesn't have one, so don't set one.
|
|
21
|
+
if (declaration &&
|
|
22
|
+
(!context.scope.comment ||
|
|
23
|
+
!(context.scope.conversionFlags & models_1.ConversionFlags.VariableSource))) {
|
|
19
24
|
sigRef.comment = (0, comments_1.getSignatureComment)(declaration, context.converter.config, context.logger, context.converter.commentStyle);
|
|
20
25
|
}
|
|
21
26
|
sigRef.typeParameters = convertTypeParameters(context, sigRef, signature.typeParameters);
|
|
@@ -16,6 +16,14 @@ function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
|
|
|
16
16
|
convertJsDocInterface(context, declaration, symbol, exportSymbol);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
+
// If the typedef tag is just referring to another type-space symbol, with no type parameters
|
|
20
|
+
// or appropriate forwarding type parameters, then we treat it as a re-export instead of creating
|
|
21
|
+
// a type alias with an import type.
|
|
22
|
+
const aliasedSymbol = getTypedefReExportTarget(context, declaration);
|
|
23
|
+
if (aliasedSymbol) {
|
|
24
|
+
context.converter.convertSymbol(context, aliasedSymbol, exportSymbol ?? symbol);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
19
27
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
20
28
|
reflection.comment = (0, comments_1.getJsDocComment)(declaration, context.converter.config, context.logger);
|
|
21
29
|
reflection.type = context.converter.convertType(context.withScope(reflection), declaration.typeExpression?.type);
|
|
@@ -69,3 +77,36 @@ function convertTemplateParameterNodes(context, nodes) {
|
|
|
69
77
|
const params = (nodes ?? []).flatMap((tag) => tag.typeParameters);
|
|
70
78
|
return (0, signature_1.convertTypeParameterNodes)(context, params);
|
|
71
79
|
}
|
|
80
|
+
function getTypedefReExportTarget(context, declaration) {
|
|
81
|
+
const typeExpression = declaration.typeExpression;
|
|
82
|
+
if (!ts.isJSDocTypedefTag(declaration) ||
|
|
83
|
+
!typeExpression ||
|
|
84
|
+
ts.isJSDocTypeLiteral(typeExpression) ||
|
|
85
|
+
!ts.isImportTypeNode(typeExpression.type) ||
|
|
86
|
+
!typeExpression.type.qualifier ||
|
|
87
|
+
!ts.isIdentifier(typeExpression.type.qualifier)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const targetSymbol = context.expectSymbolAtLocation(typeExpression.type.qualifier);
|
|
91
|
+
const decl = targetSymbol.declarations?.[0];
|
|
92
|
+
if (!decl ||
|
|
93
|
+
!(ts.isTypeAliasDeclaration(decl) ||
|
|
94
|
+
ts.isInterfaceDeclaration(decl) ||
|
|
95
|
+
ts.isJSDocTypedefTag(decl) ||
|
|
96
|
+
ts.isJSDocCallbackTag(decl))) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const targetParams = ts.getEffectiveTypeParameterDeclarations(decl);
|
|
100
|
+
const localParams = ts.getEffectiveTypeParameterDeclarations(declaration);
|
|
101
|
+
const localArgs = typeExpression.type.typeArguments || [];
|
|
102
|
+
// If we have type parameters, ensure they are forwarding parameters with no transformations.
|
|
103
|
+
// This doesn't check constraints since they aren't checked in JSDoc types.
|
|
104
|
+
if (targetParams.length !== localParams.length ||
|
|
105
|
+
localArgs.some((arg, i) => !ts.isTypeReferenceNode(arg) ||
|
|
106
|
+
!ts.isIdentifier(arg.typeName) ||
|
|
107
|
+
arg.typeArguments ||
|
|
108
|
+
localParams[i]?.name.text !== arg.typeName.text)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
return targetSymbol;
|
|
112
|
+
}
|
|
@@ -477,6 +477,7 @@ function convertVariableAsFunction(context, symbol, exportSymbol) {
|
|
|
477
477
|
: context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
478
478
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.Function, symbol, exportSymbol);
|
|
479
479
|
setModifiers(symbol, accessDeclaration, reflection);
|
|
480
|
+
reflection.conversionFlags |= models_1.ConversionFlags.VariableSource;
|
|
480
481
|
context.finalizeDeclarationReflection(reflection);
|
|
481
482
|
const reflectionContext = context.withScope(reflection);
|
|
482
483
|
reflection.signatures ?? (reflection.signatures = []);
|
|
@@ -9,6 +9,7 @@ const converter_events_1 = require("./converter-events");
|
|
|
9
9
|
const index_signature_1 = require("./factories/index-signature");
|
|
10
10
|
const signature_1 = require("./factories/signature");
|
|
11
11
|
const symbols_1 = require("./symbols");
|
|
12
|
+
const nodes_1 = require("./utils/nodes");
|
|
12
13
|
const reflections_1 = require("./utils/reflections");
|
|
13
14
|
const converters = new Map();
|
|
14
15
|
function loadConverters() {
|
|
@@ -576,7 +577,7 @@ const typeOperatorConverter = {
|
|
|
576
577
|
// readonly is only valid on array and tuple literal types.
|
|
577
578
|
if (node.operator === ts.SyntaxKind.ReadonlyKeyword) {
|
|
578
579
|
const resolved = resolveReference(type);
|
|
579
|
-
assert(isObjectType(resolved));
|
|
580
|
+
assert((0, nodes_1.isObjectType)(resolved));
|
|
580
581
|
const args = context.checker
|
|
581
582
|
.getTypeArguments(type)
|
|
582
583
|
.map((type) => convertType(context, type));
|
|
@@ -645,11 +646,8 @@ function requestBugReport(context, nodeOrType) {
|
|
|
645
646
|
return new models_1.UnknownType(typeString);
|
|
646
647
|
}
|
|
647
648
|
}
|
|
648
|
-
function isObjectType(type) {
|
|
649
|
-
return typeof type.objectFlags === "number";
|
|
650
|
-
}
|
|
651
649
|
function resolveReference(type) {
|
|
652
|
-
if (isObjectType(type) && type.objectFlags & ts.ObjectFlags.Reference) {
|
|
650
|
+
if ((0, nodes_1.isObjectType)(type) && type.objectFlags & ts.ObjectFlags.Reference) {
|
|
653
651
|
return type.target;
|
|
654
652
|
}
|
|
655
653
|
return type;
|
|
@@ -3,3 +3,4 @@ export declare function isNamedNode(node: ts.Node): node is ts.Node & {
|
|
|
3
3
|
name: ts.Identifier | ts.PrivateIdentifier | ts.ComputedPropertyName;
|
|
4
4
|
};
|
|
5
5
|
export declare function getHeritageTypes(declarations: readonly (ts.ClassDeclaration | ts.InterfaceDeclaration)[], kind: ts.SyntaxKind.ImplementsKeyword | ts.SyntaxKind.ExtendsKeyword): ts.ExpressionWithTypeArguments[];
|
|
6
|
+
export declare function isObjectType(type: ts.Type): type is ts.ObjectType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHeritageTypes = exports.isNamedNode = void 0;
|
|
3
|
+
exports.isObjectType = exports.getHeritageTypes = exports.isNamedNode = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
function isNamedNode(node) {
|
|
6
6
|
const name = node.name;
|
|
@@ -22,3 +22,7 @@ function getHeritageTypes(declarations, kind) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
exports.getHeritageTypes = getHeritageTypes;
|
|
25
|
+
function isObjectType(type) {
|
|
26
|
+
return typeof type.objectFlags === "number";
|
|
27
|
+
}
|
|
28
|
+
exports.isObjectType = isObjectType;
|
|
@@ -25,6 +25,13 @@ export interface DeclarationHierarchy {
|
|
|
25
25
|
*/
|
|
26
26
|
isTarget?: boolean;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare enum ConversionFlags {
|
|
32
|
+
None = 0,
|
|
33
|
+
VariableSource = 1
|
|
34
|
+
}
|
|
28
35
|
/**
|
|
29
36
|
* A reflection that represents a single declaration emitted by the TypeScript compiler.
|
|
30
37
|
*
|
|
@@ -118,6 +125,11 @@ export declare class DeclarationReflection extends ContainerReflection {
|
|
|
118
125
|
* The version of the module when found.
|
|
119
126
|
*/
|
|
120
127
|
version?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Flags for information about a reflection which is needed solely during conversion.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
conversionFlags: ConversionFlags;
|
|
121
133
|
hasGetterOrSetter(): boolean;
|
|
122
134
|
getAllSignatures(): SignatureReflection[];
|
|
123
135
|
/** @internal */
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeclarationReflection = void 0;
|
|
3
|
+
exports.DeclarationReflection = exports.ConversionFlags = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const abstract_1 = require("./abstract");
|
|
6
6
|
const container_1 = require("./container");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
var ConversionFlags;
|
|
11
|
+
(function (ConversionFlags) {
|
|
12
|
+
ConversionFlags[ConversionFlags["None"] = 0] = "None";
|
|
13
|
+
ConversionFlags[ConversionFlags["VariableSource"] = 1] = "VariableSource";
|
|
14
|
+
})(ConversionFlags = exports.ConversionFlags || (exports.ConversionFlags = {}));
|
|
7
15
|
/**
|
|
8
16
|
* A reflection that represents a single declaration emitted by the TypeScript compiler.
|
|
9
17
|
*
|
|
@@ -11,6 +19,14 @@ const container_1 = require("./container");
|
|
|
11
19
|
* kind of a reflection is stored in its ´kind´ member.
|
|
12
20
|
*/
|
|
13
21
|
class DeclarationReflection extends container_1.ContainerReflection {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
/**
|
|
25
|
+
* Flags for information about a reflection which is needed solely during conversion.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
this.conversionFlags = ConversionFlags.None;
|
|
29
|
+
}
|
|
14
30
|
hasGetterOrSetter() {
|
|
15
31
|
return !!this.getSignature || !!this.setSignature;
|
|
16
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Reflection, ReflectionFlag, ReflectionFlags, TraverseProperty, } from "./abstract";
|
|
2
2
|
export type { TraverseCallback } from "./abstract";
|
|
3
3
|
export { ContainerReflection } from "./container";
|
|
4
|
-
export { DeclarationReflection } from "./declaration";
|
|
4
|
+
export { DeclarationReflection, ConversionFlags } from "./declaration";
|
|
5
5
|
export type { DeclarationHierarchy } from "./declaration";
|
|
6
6
|
export { ReflectionKind } from "./kind";
|
|
7
7
|
export { ParameterReflection } from "./parameter";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0;
|
|
3
|
+
exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.ConversionFlags = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0;
|
|
4
4
|
var abstract_1 = require("./abstract");
|
|
5
5
|
Object.defineProperty(exports, "Reflection", { enumerable: true, get: function () { return abstract_1.Reflection; } });
|
|
6
6
|
Object.defineProperty(exports, "ReflectionFlag", { enumerable: true, get: function () { return abstract_1.ReflectionFlag; } });
|
|
@@ -10,6 +10,7 @@ var container_1 = require("./container");
|
|
|
10
10
|
Object.defineProperty(exports, "ContainerReflection", { enumerable: true, get: function () { return container_1.ContainerReflection; } });
|
|
11
11
|
var declaration_1 = require("./declaration");
|
|
12
12
|
Object.defineProperty(exports, "DeclarationReflection", { enumerable: true, get: function () { return declaration_1.DeclarationReflection; } });
|
|
13
|
+
Object.defineProperty(exports, "ConversionFlags", { enumerable: true, get: function () { return declaration_1.ConversionFlags; } });
|
|
13
14
|
var kind_1 = require("./kind");
|
|
14
15
|
Object.defineProperty(exports, "ReflectionKind", { enumerable: true, get: function () { return kind_1.ReflectionKind; } });
|
|
15
16
|
var parameter_1 = require("./parameter");
|
|
@@ -26,7 +26,7 @@ export declare class DefaultThemeRenderContext {
|
|
|
26
26
|
comment: (props: Reflection) => import("../../../utils/jsx.elements").JsxElement | undefined;
|
|
27
27
|
footer: () => import("../../../utils/jsx.elements").JsxElement | undefined;
|
|
28
28
|
header: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
|
|
29
|
-
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement;
|
|
29
|
+
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement | undefined;
|
|
30
30
|
index: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement;
|
|
31
31
|
member: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
|
|
32
32
|
memberDeclaration: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
|
|
2
2
|
import { JSX } from "../../../../utils";
|
|
3
3
|
import type { DeclarationHierarchy } from "../../../../models";
|
|
4
|
-
export declare
|
|
4
|
+
export declare function hierarchy(context: DefaultThemeRenderContext, props: DeclarationHierarchy | undefined): JSX.Element | undefined;
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hierarchy = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function hierarchy(context, props) {
|
|
6
|
+
if (!props)
|
|
7
|
+
return;
|
|
8
|
+
return (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-hierarchy" },
|
|
9
|
+
utils_1.JSX.createElement("h4", null, "Hierarchy"),
|
|
10
|
+
hierarchyList(context, props)));
|
|
11
|
+
}
|
|
10
12
|
exports.hierarchy = hierarchy;
|
|
13
|
+
function hierarchyList(context, props) {
|
|
14
|
+
return (utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.types.map((item, i, l) => (utils_1.JSX.createElement("li", null,
|
|
15
|
+
props.isTarget ? utils_1.JSX.createElement("span", { class: "target" }, item.toString()) : context.type(item),
|
|
16
|
+
i === l.length - 1 && !!props.next && hierarchyList(context, props.next))))));
|
|
17
|
+
}
|
|
@@ -19,9 +19,7 @@ const memberDeclaration = (context, props) => (utils_1.JSX.createElement(utils_1
|
|
|
19
19
|
" = ",
|
|
20
20
|
props.defaultValue)))),
|
|
21
21
|
context.comment(props),
|
|
22
|
-
(0, lib_1.hasTypeParameters)(props) &&
|
|
23
|
-
utils_1.JSX.createElement("h4", { class: "tsd-type-parameters-title" }, "Type Parameters"),
|
|
24
|
-
context.typeParameters(props.typeParameters))),
|
|
22
|
+
(0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters),
|
|
25
23
|
props.type instanceof models_1.ReflectionType && (utils_1.JSX.createElement("div", { class: "tsd-type-declaration" },
|
|
26
24
|
utils_1.JSX.createElement("h4", null, "Type declaration"),
|
|
27
25
|
context.parameter(props.type.declaration))),
|
|
@@ -7,9 +7,7 @@ const lib_1 = require("../../lib");
|
|
|
7
7
|
const memberSignatureBody = (context, props, { hideSources = false } = {}) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
8
8
|
(0, lib_1.renderFlags)(props.flags, props.comment),
|
|
9
9
|
context.comment(props),
|
|
10
|
-
(0, lib_1.hasTypeParameters)(props) && (
|
|
11
|
-
utils_1.JSX.createElement("h4", { class: "tsd-type-parameters-title" }, "Type Parameters"),
|
|
12
|
-
context.typeParameters(props.typeParameters))),
|
|
10
|
+
(0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters),
|
|
13
11
|
props.parameters && props.parameters.length > 0 && (utils_1.JSX.createElement("div", { class: "tsd-parameters" },
|
|
14
12
|
utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, "Parameters"),
|
|
15
13
|
utils_1.JSX.createElement("ul", { class: "tsd-parameter-list" }, props.parameters.map((item) => (utils_1.JSX.createElement("li", null,
|
package/package.json
CHANGED
package/static/widgets.png
DELETED
|
Binary file
|
package/static/widgets@2x.png
DELETED
|
Binary file
|