typedoc 0.25.4 → 0.25.5
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/discovery.js +1 -1
- package/dist/lib/converter/context.d.ts +0 -3
- package/dist/lib/converter/context.js +0 -3
- package/dist/lib/converter/converter.d.ts +0 -1
- package/dist/lib/converter/converter.js +0 -1
- package/dist/lib/converter/factories/signature.js +29 -3
- package/dist/lib/converter/plugins/CategoryPlugin.d.ts +0 -7
- package/dist/lib/converter/plugins/CategoryPlugin.js +6 -12
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +1 -0
- package/dist/lib/converter/plugins/CommentPlugin.js +59 -29
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +0 -7
- package/dist/lib/converter/plugins/GroupPlugin.js +7 -13
- package/dist/lib/converter/plugins/SourcePlugin.js +23 -0
- package/dist/lib/converter/symbols.js +44 -23
- package/dist/lib/converter/types.js +14 -10
- package/dist/lib/models/comments/comment.d.ts +0 -1
- package/dist/lib/models/comments/comment.js +0 -1
- package/dist/lib/models/reflections/abstract.d.ts +3 -1
- package/dist/lib/models/reflections/abstract.js +4 -2
- package/dist/lib/models/reflections/declaration.js +1 -1
- package/dist/lib/models/reflections/kind.d.ts +6 -0
- package/dist/lib/models/reflections/kind.js +17 -0
- package/dist/lib/models/reflections/parameter.js +1 -1
- package/dist/lib/models/reflections/project.d.ts +3 -0
- package/dist/lib/models/reflections/project.js +59 -6
- package/dist/lib/models/reflections/signature.js +1 -1
- package/dist/lib/models/sources/file.d.ts +1 -1
- package/dist/lib/models/types.d.ts +5 -0
- package/dist/lib/models/types.js +21 -10
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +1 -1
- package/dist/lib/output/themes/default/DefaultTheme.js +82 -11
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +1 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +2 -0
- package/dist/lib/output/themes/default/partials/hierarchy.js +18 -1
- package/dist/lib/output/themes/default/partials/icon.js +2 -2
- package/dist/lib/output/themes/default/partials/member.getterSetter.js +2 -2
- package/dist/lib/output/themes/default/partials/member.signature.title.js +2 -2
- package/dist/lib/output/themes/default/partials/parameter.js +2 -2
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +3 -3
- package/dist/lib/output/themes/default/partials/type.js +2 -3
- package/dist/lib/output/themes/default/partials/typeParameters.js +6 -3
- package/dist/lib/output/themes/default/templates/hierarchy.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/hierarchy.js +32 -0
- package/dist/lib/output/themes/lib.js +3 -3
- package/dist/lib/serialization/components.d.ts +1 -1
- package/dist/lib/serialization/schema.d.ts +1 -0
- package/dist/lib/serialization/serializer.d.ts +0 -1
- package/dist/lib/serialization/serializer.js +0 -1
- package/dist/lib/utils/enum.d.ts +1 -0
- package/dist/lib/utils/enum.js +5 -1
- package/dist/lib/utils/loggers.d.ts +0 -3
- package/dist/lib/utils/loggers.js +0 -1
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/readers/tsconfig.js +4 -1
- package/dist/lib/utils/options/sources/typedoc.js +1 -0
- package/dist/lib/utils/tsconfig.d.ts +1 -0
- package/dist/lib/utils/tsconfig.js +33 -1
- package/dist/lib/validation/documentation.js +23 -16
- package/package.json +9 -8
- package/static/main.js +2 -2
- package/static/style.css +35 -15
|
@@ -366,7 +366,7 @@ let Reflection = (() => {
|
|
|
366
366
|
/**
|
|
367
367
|
* Return a child by its name.
|
|
368
368
|
*
|
|
369
|
-
* @param
|
|
369
|
+
* @param arg The name hierarchy of the child to look for.
|
|
370
370
|
* @returns The found child or undefined.
|
|
371
371
|
*/
|
|
372
372
|
getChildByName(arg) {
|
|
@@ -405,7 +405,7 @@ let Reflection = (() => {
|
|
|
405
405
|
let signaturesDeprecated = false;
|
|
406
406
|
this.visit({
|
|
407
407
|
declaration(decl) {
|
|
408
|
-
if (decl.signatures &&
|
|
408
|
+
if (decl.signatures?.length &&
|
|
409
409
|
decl.signatures.every((sig) => sig.comment?.getTag("@deprecated"))) {
|
|
410
410
|
signaturesDeprecated = true;
|
|
411
411
|
}
|
|
@@ -428,6 +428,8 @@ let Reflection = (() => {
|
|
|
428
428
|
/**
|
|
429
429
|
* Return a string representation of this reflection and all of its children.
|
|
430
430
|
*
|
|
431
|
+
* Note: This is intended as a debug tool only, output may change between patch versions.
|
|
432
|
+
*
|
|
431
433
|
* @param indent Used internally to indent child reflections.
|
|
432
434
|
*/
|
|
433
435
|
toStringHierarchy(indent = "") {
|
|
@@ -104,7 +104,7 @@ class DeclarationReflection extends container_1.ContainerReflection {
|
|
|
104
104
|
result += "<" + parameters.join(", ") + ">";
|
|
105
105
|
}
|
|
106
106
|
if (this.type) {
|
|
107
|
-
result += ":" + this.type.toString();
|
|
107
|
+
result += ": " + this.type.toString();
|
|
108
108
|
}
|
|
109
109
|
return result;
|
|
110
110
|
}
|
|
@@ -58,11 +58,17 @@ export declare namespace ReflectionKind {
|
|
|
58
58
|
const Inheritable: number;
|
|
59
59
|
/** @internal */
|
|
60
60
|
const ContainsCallSignatures: number;
|
|
61
|
+
/** @internal */
|
|
62
|
+
const TypeReferenceTarget: number;
|
|
63
|
+
/** @internal */
|
|
64
|
+
const ValueReferenceTarget: number;
|
|
61
65
|
/**
|
|
62
66
|
* Note: This does not include Class/Interface, even though they technically could contain index signatures
|
|
63
67
|
* @internal
|
|
64
68
|
*/
|
|
65
69
|
const SignatureContainer: number;
|
|
70
|
+
const VariableContainer: number;
|
|
71
|
+
const MethodContainer: number;
|
|
66
72
|
function singularString(kind: ReflectionKind): string;
|
|
67
73
|
function pluralString(kind: ReflectionKind): string;
|
|
68
74
|
function classString(kind: ReflectionKind): string;
|
|
@@ -87,11 +87,28 @@ var ReflectionKind;
|
|
|
87
87
|
ReflectionKind.ContainsCallSignatures = ReflectionKind.Constructor |
|
|
88
88
|
ReflectionKind.Function |
|
|
89
89
|
ReflectionKind.Method;
|
|
90
|
+
// The differences between Type/Value here only really matter for
|
|
91
|
+
// possibly merged declarations where we have multiple reflections.
|
|
92
|
+
/** @internal */
|
|
93
|
+
ReflectionKind.TypeReferenceTarget = ReflectionKind.Interface |
|
|
94
|
+
ReflectionKind.TypeAlias |
|
|
95
|
+
ReflectionKind.Class |
|
|
96
|
+
ReflectionKind.Enum;
|
|
97
|
+
/** @internal */
|
|
98
|
+
ReflectionKind.ValueReferenceTarget = ReflectionKind.Module |
|
|
99
|
+
ReflectionKind.Namespace |
|
|
100
|
+
ReflectionKind.Variable |
|
|
101
|
+
ReflectionKind.Function;
|
|
90
102
|
/**
|
|
91
103
|
* Note: This does not include Class/Interface, even though they technically could contain index signatures
|
|
92
104
|
* @internal
|
|
93
105
|
*/
|
|
94
106
|
ReflectionKind.SignatureContainer = ReflectionKind.ContainsCallSignatures | ReflectionKind.Accessor;
|
|
107
|
+
ReflectionKind.VariableContainer = ReflectionKind.SomeModule | ReflectionKind.Project;
|
|
108
|
+
ReflectionKind.MethodContainer = ReflectionKind.ClassOrInterface |
|
|
109
|
+
ReflectionKind.VariableOrProperty |
|
|
110
|
+
ReflectionKind.FunctionOrMethod |
|
|
111
|
+
ReflectionKind.TypeLiteral;
|
|
95
112
|
const SINGULARS = {
|
|
96
113
|
[ReflectionKind.Enum]: "Enumeration",
|
|
97
114
|
[ReflectionKind.EnumMember]: "Enumeration Member",
|
|
@@ -22,7 +22,7 @@ class ParameterReflection extends abstract_1.Reflection {
|
|
|
22
22
|
* Return a string representation of this reflection.
|
|
23
23
|
*/
|
|
24
24
|
toString() {
|
|
25
|
-
return super.toString() + (this.type ? ":" + this.type.toString() : "");
|
|
25
|
+
return (super.toString() + (this.type ? ": " + this.type.toString() : ""));
|
|
26
26
|
}
|
|
27
27
|
toObject(serializer) {
|
|
28
28
|
return {
|
|
@@ -81,10 +81,13 @@ export declare class ProjectReflection extends ContainerReflection {
|
|
|
81
81
|
getReflectionFromSymbol(symbol: ts.Symbol): Reflection | undefined;
|
|
82
82
|
/**
|
|
83
83
|
* Gets the reflection associated with the given symbol id, if it exists.
|
|
84
|
+
* If there are multiple reflections associated with this symbol, gets the first one.
|
|
84
85
|
* @internal
|
|
85
86
|
*/
|
|
86
87
|
getReflectionFromSymbolId(symbolId: ReflectionSymbolId): Reflection | undefined;
|
|
87
88
|
/** @internal */
|
|
89
|
+
getReflectionsFromSymbolId(symbolId: ReflectionSymbolId): Reflection[];
|
|
90
|
+
/** @internal */
|
|
88
91
|
getSymbolIdFromReflection(reflection: Reflection): ReflectionSymbolId | undefined;
|
|
89
92
|
/** @internal */
|
|
90
93
|
registerSymbolId(reflection: Reflection, id: ReflectionSymbolId): void;
|
|
@@ -65,10 +65,27 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
65
65
|
}
|
|
66
66
|
this.reflections[reflection.id] = reflection;
|
|
67
67
|
if (symbol) {
|
|
68
|
-
const id = new ReflectionSymbolId_1.ReflectionSymbolId(symbol);
|
|
69
|
-
this.symbolToReflectionIdMap.set(id, this.symbolToReflectionIdMap.get(id) ?? reflection.id);
|
|
70
|
-
this.reflectionIdToSymbolIdMap.set(reflection.id, id);
|
|
71
68
|
this.reflectionIdToSymbolMap.set(reflection.id, symbol);
|
|
69
|
+
const id = new ReflectionSymbolId_1.ReflectionSymbolId(symbol);
|
|
70
|
+
this.registerSymbolId(reflection, id);
|
|
71
|
+
// #2466
|
|
72
|
+
// If we just registered a member of a class or interface, then we need to check if
|
|
73
|
+
// we've registered this symbol before under the wrong parent reflection.
|
|
74
|
+
// This can happen because the compiler API will use non-dependently-typed symbols
|
|
75
|
+
// for properties of classes/interfaces which inherit them, so we can't rely on the
|
|
76
|
+
// property being unique for each class.
|
|
77
|
+
if (reflection.parent?.kindOf(kind_1.ReflectionKind.ClassOrInterface) &&
|
|
78
|
+
reflection.kindOf(kind_1.ReflectionKind.SomeMember)) {
|
|
79
|
+
const saved = this.symbolToReflectionIdMap.get(id);
|
|
80
|
+
const parentSymbolReflection = symbol.parent &&
|
|
81
|
+
this.getReflectionFromSymbol(symbol.parent);
|
|
82
|
+
if (typeof saved === "object" &&
|
|
83
|
+
saved.length > 1 &&
|
|
84
|
+
parentSymbolReflection) {
|
|
85
|
+
(0, utils_1.removeIf)(saved, (item) => this.getReflectionById(item)?.parent !==
|
|
86
|
+
parentSymbolReflection);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
72
89
|
}
|
|
73
90
|
}
|
|
74
91
|
/**
|
|
@@ -91,6 +108,9 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
91
108
|
}
|
|
92
109
|
if (property === abstract_1.TraverseProperty.Children) {
|
|
93
110
|
(0, utils_1.removeIfPresent)(parent.children, reflection);
|
|
111
|
+
if (!parent.children?.length) {
|
|
112
|
+
delete parent.children;
|
|
113
|
+
}
|
|
94
114
|
}
|
|
95
115
|
else if (property === abstract_1.TraverseProperty.GetSignature) {
|
|
96
116
|
delete parent.getSignature;
|
|
@@ -100,18 +120,29 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
100
120
|
}
|
|
101
121
|
else if (property === abstract_1.TraverseProperty.Parameters) {
|
|
102
122
|
(0, utils_1.removeIfPresent)(reflection.parent.parameters, reflection);
|
|
123
|
+
if (!reflection.parent.parameters
|
|
124
|
+
?.length) {
|
|
125
|
+
delete reflection.parent
|
|
126
|
+
.parameters;
|
|
127
|
+
}
|
|
103
128
|
}
|
|
104
129
|
else if (property === abstract_1.TraverseProperty.SetSignature) {
|
|
105
130
|
delete parent.setSignature;
|
|
106
131
|
}
|
|
107
132
|
else if (property === abstract_1.TraverseProperty.Signatures) {
|
|
108
133
|
(0, utils_1.removeIfPresent)(parent.signatures, reflection);
|
|
134
|
+
if (!parent.signatures?.length) {
|
|
135
|
+
delete parent.signatures;
|
|
136
|
+
}
|
|
109
137
|
}
|
|
110
138
|
else if (property === abstract_1.TraverseProperty.TypeLiteral) {
|
|
111
139
|
parent.type = new types_1.IntrinsicType("Object");
|
|
112
140
|
}
|
|
113
141
|
else if (property === abstract_1.TraverseProperty.TypeParameter) {
|
|
114
142
|
(0, utils_1.removeIfPresent)(parent.typeParameters, reflection);
|
|
143
|
+
if (!parent.typeParameters?.length) {
|
|
144
|
+
delete parent.typeParameters;
|
|
145
|
+
}
|
|
115
146
|
}
|
|
116
147
|
return false; // Stop iteration
|
|
117
148
|
});
|
|
@@ -144,9 +175,13 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
144
175
|
const symbol = this.reflectionIdToSymbolMap.get(reflection.id);
|
|
145
176
|
if (symbol) {
|
|
146
177
|
const id = new ReflectionSymbolId_1.ReflectionSymbolId(symbol);
|
|
147
|
-
|
|
178
|
+
const saved = this.symbolToReflectionIdMap.get(id);
|
|
179
|
+
if (saved === reflection.id) {
|
|
148
180
|
this.symbolToReflectionIdMap.delete(id);
|
|
149
181
|
}
|
|
182
|
+
else if (typeof saved === "object") {
|
|
183
|
+
(0, utils_1.removeIfPresent)(saved, reflection.id);
|
|
184
|
+
}
|
|
150
185
|
}
|
|
151
186
|
this.reflectionIdToSymbolIdMap.delete(reflection.id);
|
|
152
187
|
delete this.reflections[reflection.id];
|
|
@@ -167,13 +202,22 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
167
202
|
}
|
|
168
203
|
/**
|
|
169
204
|
* Gets the reflection associated with the given symbol id, if it exists.
|
|
205
|
+
* If there are multiple reflections associated with this symbol, gets the first one.
|
|
170
206
|
* @internal
|
|
171
207
|
*/
|
|
172
208
|
getReflectionFromSymbolId(symbolId) {
|
|
209
|
+
return this.getReflectionsFromSymbolId(symbolId)[0];
|
|
210
|
+
}
|
|
211
|
+
/** @internal */
|
|
212
|
+
getReflectionsFromSymbolId(symbolId) {
|
|
173
213
|
const id = this.symbolToReflectionIdMap.get(symbolId);
|
|
174
214
|
if (typeof id === "number") {
|
|
175
|
-
return this.getReflectionById(id);
|
|
215
|
+
return [this.getReflectionById(id)];
|
|
216
|
+
}
|
|
217
|
+
else if (typeof id === "object") {
|
|
218
|
+
return id.map((id) => this.getReflectionById(id));
|
|
176
219
|
}
|
|
220
|
+
return [];
|
|
177
221
|
}
|
|
178
222
|
/** @internal */
|
|
179
223
|
getSymbolIdFromReflection(reflection) {
|
|
@@ -182,7 +226,16 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
182
226
|
/** @internal */
|
|
183
227
|
registerSymbolId(reflection, id) {
|
|
184
228
|
this.reflectionIdToSymbolIdMap.set(reflection.id, id);
|
|
185
|
-
|
|
229
|
+
const previous = this.symbolToReflectionIdMap.get(id);
|
|
230
|
+
if (previous) {
|
|
231
|
+
if (typeof previous === "number") {
|
|
232
|
+
this.symbolToReflectionIdMap.set(id, [previous, reflection.id]);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
previous.push(reflection.id);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
186
239
|
this.symbolToReflectionIdMap.set(id, reflection.id);
|
|
187
240
|
}
|
|
188
241
|
}
|
|
@@ -365,6 +365,11 @@ export declare class ReferenceType extends Type {
|
|
|
365
365
|
* be registered on the project.
|
|
366
366
|
*/
|
|
367
367
|
refersToTypeParameter: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* If set, will prefer reflections with {@link ReflectionKind | ReflectionKinds} which represent
|
|
370
|
+
* values rather than those which represent types.
|
|
371
|
+
*/
|
|
372
|
+
preferValues: boolean;
|
|
368
373
|
private _target;
|
|
369
374
|
private _project;
|
|
370
375
|
private constructor();
|
package/dist/lib/models/types.js
CHANGED
|
@@ -28,6 +28,7 @@ const ts = __importStar(require("typescript"));
|
|
|
28
28
|
const tsutils_1 = require("../utils/tsutils");
|
|
29
29
|
const ReflectionSymbolId_1 = require("./reflections/ReflectionSymbolId");
|
|
30
30
|
const fs_1 = require("../utils/fs");
|
|
31
|
+
const kind_1 = require("./reflections/kind");
|
|
31
32
|
/**
|
|
32
33
|
* Base class of all type definitions.
|
|
33
34
|
* @category Types
|
|
@@ -676,9 +677,16 @@ class ReferenceType extends Type {
|
|
|
676
677
|
if (typeof this._target === "number") {
|
|
677
678
|
return this._project?.getReflectionById(this._target);
|
|
678
679
|
}
|
|
679
|
-
const
|
|
680
|
-
if (
|
|
681
|
-
|
|
680
|
+
const resolvePotential = this._project?.getReflectionsFromSymbolId(this._target);
|
|
681
|
+
if (!resolvePotential?.length) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const kind = this.preferValues
|
|
685
|
+
? kind_1.ReflectionKind.ValueReferenceTarget
|
|
686
|
+
: kind_1.ReflectionKind.TypeReferenceTarget;
|
|
687
|
+
const resolved = resolvePotential.find((refl) => refl.kindOf(kind)) ||
|
|
688
|
+
resolvePotential.find((refl) => refl.kindOf(~kind));
|
|
689
|
+
this._target = resolved.id;
|
|
682
690
|
return resolved;
|
|
683
691
|
}
|
|
684
692
|
/**
|
|
@@ -719,6 +727,11 @@ class ReferenceType extends Type {
|
|
|
719
727
|
* be registered on the project.
|
|
720
728
|
*/
|
|
721
729
|
this.refersToTypeParameter = false;
|
|
730
|
+
/**
|
|
731
|
+
* If set, will prefer reflections with {@link ReflectionKind | ReflectionKinds} which represent
|
|
732
|
+
* values rather than those which represent types.
|
|
733
|
+
*/
|
|
734
|
+
this.preferValues = false;
|
|
722
735
|
this.name = name;
|
|
723
736
|
if (typeof target === "number") {
|
|
724
737
|
this._target = target;
|
|
@@ -733,14 +746,8 @@ class ReferenceType extends Type {
|
|
|
733
746
|
return new ReferenceType(name, target, project, name);
|
|
734
747
|
}
|
|
735
748
|
static createSymbolReference(symbol, context, name) {
|
|
736
|
-
// Type parameters should never have resolved references because they
|
|
737
|
-
// cannot be linked to, and might be declared within the type with conditional types.
|
|
738
|
-
if (symbol.flags & ts.SymbolFlags.TypeParameter) {
|
|
739
|
-
const ref = ReferenceType.createBrokenReference(name ?? symbol.name, context.project);
|
|
740
|
-
ref.refersToTypeParameter = true;
|
|
741
|
-
return ref;
|
|
742
|
-
}
|
|
743
749
|
const ref = new ReferenceType(name ?? symbol.name, new ReflectionSymbolId_1.ReflectionSymbolId(symbol), context.project, (0, tsutils_1.getQualifiedName)(symbol, name ?? symbol.name));
|
|
750
|
+
ref.refersToTypeParameter = !!(symbol.flags & ts.SymbolFlags.TypeParameter);
|
|
744
751
|
const symbolPath = symbol?.declarations?.[0]
|
|
745
752
|
?.getSourceFile()
|
|
746
753
|
.fileName.replace(/\\/g, "/");
|
|
@@ -804,6 +811,9 @@ class ReferenceType extends Type {
|
|
|
804
811
|
if (this.refersToTypeParameter) {
|
|
805
812
|
result.refersToTypeParameter = true;
|
|
806
813
|
}
|
|
814
|
+
if (typeof this._target !== "number" && this.preferValues) {
|
|
815
|
+
result.preferValues = true;
|
|
816
|
+
}
|
|
807
817
|
return result;
|
|
808
818
|
}
|
|
809
819
|
fromObject(de, obj) {
|
|
@@ -830,6 +840,7 @@ class ReferenceType extends Type {
|
|
|
830
840
|
this.qualifiedName = obj.qualifiedName ?? obj.name;
|
|
831
841
|
this.package = obj.package;
|
|
832
842
|
this.refersToTypeParameter = !!obj.refersToTypeParameter;
|
|
843
|
+
this.preferValues = !!obj.preferValues;
|
|
833
844
|
}
|
|
834
845
|
}
|
|
835
846
|
exports.ReferenceType = ReferenceType;
|
|
@@ -23,6 +23,7 @@ export declare class DefaultTheme extends Theme {
|
|
|
23
23
|
getRenderContext(pageEvent: PageEvent<Reflection>): DefaultThemeRenderContext;
|
|
24
24
|
reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element;
|
|
25
25
|
indexTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
|
|
26
|
+
hierarchyTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
|
|
26
27
|
defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>) => JSX.Element;
|
|
27
28
|
getReflectionClasses(reflection: DeclarationReflection): string;
|
|
28
29
|
/**
|
|
@@ -34,7 +35,6 @@ export declare class DefaultTheme extends Theme {
|
|
|
34
35
|
* Create a new DefaultTheme instance.
|
|
35
36
|
*
|
|
36
37
|
* @param renderer The renderer this theme is attached to.
|
|
37
|
-
* @param basePath The base path of this theme.
|
|
38
38
|
*/
|
|
39
39
|
constructor(renderer: Renderer);
|
|
40
40
|
/**
|
|
@@ -23,7 +23,6 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
23
23
|
* Create a new DefaultTheme instance.
|
|
24
24
|
*
|
|
25
25
|
* @param renderer The renderer this theme is attached to.
|
|
26
|
-
* @param basePath The base path of this theme.
|
|
27
26
|
*/
|
|
28
27
|
constructor(renderer) {
|
|
29
28
|
super(renderer);
|
|
@@ -33,6 +32,9 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
33
32
|
this.indexTemplate = (pageEvent) => {
|
|
34
33
|
return this.getRenderContext(pageEvent).indexTemplate(pageEvent);
|
|
35
34
|
};
|
|
35
|
+
this.hierarchyTemplate = (pageEvent) => {
|
|
36
|
+
return this.getRenderContext(pageEvent).hierarchyTemplate(pageEvent);
|
|
37
|
+
};
|
|
36
38
|
this.defaultLayoutTemplate = (pageEvent, template) => {
|
|
37
39
|
return this.getRenderContext(pageEvent).defaultLayout(template, pageEvent);
|
|
38
40
|
};
|
|
@@ -102,6 +104,9 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
102
104
|
urls.push(new UrlMapping_1.UrlMapping("modules.html", project, this.reflectionTemplate));
|
|
103
105
|
urls.push(new UrlMapping_1.UrlMapping("index.html", project, this.indexTemplate));
|
|
104
106
|
}
|
|
107
|
+
if (includeHierarchyPage(project)) {
|
|
108
|
+
urls.push(new UrlMapping_1.UrlMapping("hierarchy.html", project, this.hierarchyTemplate));
|
|
109
|
+
}
|
|
105
110
|
project.children?.forEach((child) => {
|
|
106
111
|
if (child instanceof models_1.DeclarationReflection) {
|
|
107
112
|
this.buildUrls(child, urls);
|
|
@@ -225,19 +230,59 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
225
230
|
if (parent.groups && shouldShowGroups(parent, opts)) {
|
|
226
231
|
return parent.groups.map(toNavigation);
|
|
227
232
|
}
|
|
233
|
+
if (opts.includeFolders &&
|
|
234
|
+
parent.children?.every((child) => child.kindOf(models_1.ReflectionKind.Module)) &&
|
|
235
|
+
parent.children.some((child) => child.name.includes("/"))) {
|
|
236
|
+
return deriveModuleFolders(parent.children);
|
|
237
|
+
}
|
|
228
238
|
return parent.children?.map(toNavigation);
|
|
229
239
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
240
|
+
function deriveModuleFolders(children) {
|
|
241
|
+
const result = [];
|
|
242
|
+
const resolveOrCreateParents = (path, root = result) => {
|
|
243
|
+
if (path.length > 1) {
|
|
244
|
+
const inner = root.find((el) => el.text === path[0]);
|
|
245
|
+
if (inner) {
|
|
246
|
+
inner.children ||= [];
|
|
247
|
+
return resolveOrCreateParents(path.slice(1), inner.children);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
root.push({
|
|
251
|
+
text: path[0],
|
|
252
|
+
children: [],
|
|
253
|
+
});
|
|
254
|
+
return resolveOrCreateParents(path.slice(1), root[root.length - 1].children);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return root;
|
|
258
|
+
};
|
|
259
|
+
// Note: This might end up putting a module within another module if we document
|
|
260
|
+
// both foo/index.ts and foo/bar.ts.
|
|
261
|
+
for (const child of children) {
|
|
262
|
+
const parts = child.name.split("/");
|
|
263
|
+
const collection = resolveOrCreateParents(parts);
|
|
264
|
+
const nav = toNavigation(child);
|
|
265
|
+
nav.text = parts[parts.length - 1];
|
|
266
|
+
collection.push(nav);
|
|
233
267
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
268
|
+
// Now merge single-possible-paths together so we don't have folders in our navigation
|
|
269
|
+
// which contain only another single folder.
|
|
270
|
+
const queue = [...result];
|
|
271
|
+
while (queue.length) {
|
|
272
|
+
const review = queue.shift();
|
|
273
|
+
queue.push(...(review.children || []));
|
|
274
|
+
if (review.kind || review.path)
|
|
275
|
+
continue;
|
|
276
|
+
if (review.children?.length === 1) {
|
|
277
|
+
const copyFrom = review.children[0];
|
|
278
|
+
const fullName = `${review.text}/${copyFrom.text}`;
|
|
279
|
+
delete review.children;
|
|
280
|
+
Object.assign(review, copyFrom);
|
|
281
|
+
review.text = fullName;
|
|
282
|
+
queue.push(review);
|
|
283
|
+
}
|
|
239
284
|
}
|
|
240
|
-
return
|
|
285
|
+
return result;
|
|
241
286
|
}
|
|
242
287
|
}
|
|
243
288
|
/**
|
|
@@ -247,7 +292,9 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
247
292
|
* @param container The nearest reflection having an own document.
|
|
248
293
|
*/
|
|
249
294
|
static applyAnchorUrl(reflection, container) {
|
|
250
|
-
if (!(reflection instanceof models_1.DeclarationReflection) &&
|
|
295
|
+
if (!(reflection instanceof models_1.DeclarationReflection) &&
|
|
296
|
+
!(reflection instanceof models_1.SignatureReflection) &&
|
|
297
|
+
!(reflection instanceof models_1.TypeParameterReflection)) {
|
|
251
298
|
return;
|
|
252
299
|
}
|
|
253
300
|
if (!reflection.url || !DefaultTheme.URL_PREFIX.test(reflection.url)) {
|
|
@@ -306,3 +353,27 @@ function getReflectionClasses(reflection, filters) {
|
|
|
306
353
|
}
|
|
307
354
|
return classes.join(" ");
|
|
308
355
|
}
|
|
356
|
+
function shouldShowCategories(reflection, opts) {
|
|
357
|
+
if (opts.includeCategories) {
|
|
358
|
+
return !reflection.comment?.hasModifier("@hideCategories");
|
|
359
|
+
}
|
|
360
|
+
return reflection.comment?.hasModifier("@showCategories") === true;
|
|
361
|
+
}
|
|
362
|
+
function shouldShowGroups(reflection, opts) {
|
|
363
|
+
if (opts.includeGroups) {
|
|
364
|
+
return !reflection.comment?.hasModifier("@hideGroups");
|
|
365
|
+
}
|
|
366
|
+
return reflection.comment?.hasModifier("@showGroups") === true;
|
|
367
|
+
}
|
|
368
|
+
function includeHierarchyPage(project) {
|
|
369
|
+
for (const id in project.reflections) {
|
|
370
|
+
const refl = project.reflections[id];
|
|
371
|
+
if (refl.kindOf(models_1.ReflectionKind.ClassOrInterface)) {
|
|
372
|
+
// Keep this condition in sync with the one in hierarchy.tsx for determining roots
|
|
373
|
+
if (!(refl.implementedTypes || refl.extendedTypes) && (refl.implementedBy || refl.extendedBy)) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
@@ -22,6 +22,7 @@ export declare class DefaultThemeRenderContext {
|
|
|
22
22
|
getReflectionClasses: (refl: DeclarationReflection) => string;
|
|
23
23
|
reflectionTemplate: (props: PageEvent<import("../../../models").ContainerReflection>) => JSX.Element;
|
|
24
24
|
indexTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => JSX.Element;
|
|
25
|
+
hierarchyTemplate: (props: PageEvent<import("../../../models").ProjectReflection>) => JSX.Element;
|
|
25
26
|
defaultLayout: (template: import("../..").RenderTemplate<PageEvent<Reflection>>, props: PageEvent<Reflection>) => JSX.Element;
|
|
26
27
|
/**
|
|
27
28
|
* Rendered just after the description for a reflection.
|
|
@@ -29,6 +29,7 @@ const type_1 = require("./partials/type");
|
|
|
29
29
|
const typeAndParent_1 = require("./partials/typeAndParent");
|
|
30
30
|
const typeParameters_1 = require("./partials/typeParameters");
|
|
31
31
|
const templates_1 = require("./templates");
|
|
32
|
+
const hierarchy_2 = require("./templates/hierarchy");
|
|
32
33
|
const reflection_1 = require("./templates/reflection");
|
|
33
34
|
function bind(fn, first) {
|
|
34
35
|
return (...r) => fn(first, ...r);
|
|
@@ -59,6 +60,7 @@ class DefaultThemeRenderContext {
|
|
|
59
60
|
this.getReflectionClasses = (refl) => this.theme.getReflectionClasses(refl);
|
|
60
61
|
this.reflectionTemplate = bind(reflection_1.reflectionTemplate, this);
|
|
61
62
|
this.indexTemplate = bind(templates_1.indexTemplate, this);
|
|
63
|
+
this.hierarchyTemplate = bind(hierarchy_2.hierarchyTemplate, this);
|
|
62
64
|
this.defaultLayout = bind(default_1.defaultLayout, this);
|
|
63
65
|
/**
|
|
64
66
|
* Rendered just after the description for a reflection.
|
|
@@ -2,11 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hierarchy = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
|
+
const isLinkedReferenceType = (type) => type.visit({
|
|
6
|
+
reference: (ref) => ref.reflection !== undefined,
|
|
7
|
+
}) ?? false;
|
|
8
|
+
function hasAnyLinkedReferenceType(h) {
|
|
9
|
+
if (!h)
|
|
10
|
+
return false;
|
|
11
|
+
if (!h.isTarget && h.types.some(isLinkedReferenceType))
|
|
12
|
+
return true;
|
|
13
|
+
return hasAnyLinkedReferenceType(h.next);
|
|
14
|
+
}
|
|
5
15
|
function hierarchy(context, props) {
|
|
6
16
|
if (!props)
|
|
7
17
|
return;
|
|
18
|
+
const fullLink = hasAnyLinkedReferenceType(props) ? (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
19
|
+
" ",
|
|
20
|
+
"(",
|
|
21
|
+
utils_1.JSX.createElement("a", { class: "link", href: context.relativeURL("hierarchy.html") + "#" + context.page.model.getFullName() }, "view full"),
|
|
22
|
+
")")) : (utils_1.JSX.createElement(utils_1.JSX.Fragment, null));
|
|
8
23
|
return (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-hierarchy" },
|
|
9
|
-
utils_1.JSX.createElement("h4", null,
|
|
24
|
+
utils_1.JSX.createElement("h4", null,
|
|
25
|
+
"Hierarchy",
|
|
26
|
+
fullLink),
|
|
10
27
|
hierarchyList(context, props)));
|
|
11
28
|
}
|
|
12
29
|
exports.hierarchy = hierarchy;
|
|
@@ -57,14 +57,14 @@ exports.icons = {
|
|
|
57
57
|
[models_1.ReflectionKind.Interface]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z", fill: "var(--color-text)" }), "var(--color-ts-interface)"),
|
|
58
58
|
[models_1.ReflectionKind.Method]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z", fill: "var(--color-text)" }), "#FF4DB8", true),
|
|
59
59
|
[models_1.ReflectionKind.Module]() {
|
|
60
|
-
return
|
|
60
|
+
return kindIcon(utils_1.JSX.createElement("path", { d: "M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z", fill: "var(--color-text)" }), "var(--color-ts-module)");
|
|
61
61
|
},
|
|
62
62
|
[models_1.ReflectionKind.Namespace]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z", fill: "var(--color-text)" }), "var(--color-ts-namespace)"),
|
|
63
63
|
[models_1.ReflectionKind.Parameter]() {
|
|
64
64
|
return this[models_1.ReflectionKind.Property]();
|
|
65
65
|
},
|
|
66
66
|
[models_1.ReflectionKind.Project]() {
|
|
67
|
-
return this[models_1.ReflectionKind.
|
|
67
|
+
return this[models_1.ReflectionKind.Module]();
|
|
68
68
|
},
|
|
69
69
|
[models_1.ReflectionKind.Property]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z", fill: "var(--color-text)" }), "#FF984D", true),
|
|
70
70
|
[models_1.ReflectionKind.Reference]: () => kindIcon(utils_1.JSX.createElement("path", { d: "M10.354 17V8.24H13.066C13.586 8.24 14.042 8.348 14.434 8.564C14.826 8.772 15.13 9.064 15.346 9.44C15.562 9.816 15.67 10.256 15.67 10.76C15.67 11.352 15.514 11.86 15.202 12.284C14.898 12.708 14.482 13 13.954 13.16L15.79 17H14.518L12.838 13.28H11.434V17H10.354ZM11.434 12.308H13.066C13.514 12.308 13.874 12.168 14.146 11.888C14.418 11.6 14.554 11.224 14.554 10.76C14.554 10.288 14.418 9.912 14.146 9.632C13.874 9.352 13.514 9.212 13.066 9.212H11.434V12.308Z", fill: "var(--color-text)" }), "#FF4D82", // extract into a CSS variable potentially?
|
|
@@ -9,7 +9,7 @@ const memberGetterSetter = (context, props) => (utils_1.JSX.createElement(utils_
|
|
|
9
9
|
}, context.getReflectionClasses(props)) },
|
|
10
10
|
!!props.getSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
11
11
|
utils_1.JSX.createElement("li", { class: "tsd-signature", id: props.getSignature.anchor },
|
|
12
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
12
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "get"),
|
|
13
13
|
" ",
|
|
14
14
|
props.name,
|
|
15
15
|
context.memberSignatureTitle(props.getSignature, {
|
|
@@ -18,7 +18,7 @@ const memberGetterSetter = (context, props) => (utils_1.JSX.createElement(utils_
|
|
|
18
18
|
utils_1.JSX.createElement("li", { class: "tsd-description" }, context.memberSignatureBody(props.getSignature)))),
|
|
19
19
|
!!props.setSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
20
20
|
utils_1.JSX.createElement("li", { class: "tsd-signature", id: props.setSignature.anchor },
|
|
21
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
21
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "set"),
|
|
22
22
|
" ",
|
|
23
23
|
props.name,
|
|
24
24
|
context.memberSignatureTitle(props.setSignature, {
|
|
@@ -25,8 +25,8 @@ function memberSignatureTitle(context, props, { hideName = false, arrowStyle = f
|
|
|
25
25
|
const renderParam = hideParamTypes ? renderParameterWithoutType : renderParameterWithType.bind(null, context);
|
|
26
26
|
return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
27
27
|
!hideName ? (utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) }, (0, lib_1.wbr)(props.name))) : (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.kind === models_1.ReflectionKind.ConstructorSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
28
|
-
!!props.flags.isAbstract && utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
29
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
28
|
+
!!props.flags.isAbstract && utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "abstract "),
|
|
29
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "new "))))),
|
|
30
30
|
(0, lib_1.renderTypeParametersSignature)(context, props.typeParameters),
|
|
31
31
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("),
|
|
32
32
|
(0, lib_1.join)(", ", props.parameters ?? [], renderParam),
|
|
@@ -55,7 +55,7 @@ const parameter = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fra
|
|
|
55
55
|
utils_1.JSX.createElement("li", { class: "tsd-parameter" },
|
|
56
56
|
utils_1.JSX.createElement("h5", null,
|
|
57
57
|
context.reflectionFlags(item.getSignature),
|
|
58
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
58
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "get "),
|
|
59
59
|
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, (0, lib_1.wbr)(item.name)),
|
|
60
60
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "(): "),
|
|
61
61
|
context.type(item.getSignature.type)),
|
|
@@ -65,7 +65,7 @@ const parameter = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fra
|
|
|
65
65
|
utils_1.JSX.createElement("li", { class: "tsd-parameter" },
|
|
66
66
|
utils_1.JSX.createElement("h5", null,
|
|
67
67
|
context.reflectionFlags(item.setSignature),
|
|
68
|
-
utils_1.JSX.createElement("span", { class: "tsd-signature-
|
|
68
|
+
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "set "),
|
|
69
69
|
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(item) }, (0, lib_1.wbr)(item.name)),
|
|
70
70
|
utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "("),
|
|
71
71
|
item.setSignature.parameters?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
|
|
@@ -12,9 +12,9 @@ function reflectionPreview(context, props) {
|
|
|
12
12
|
if (props.kindOf(models_1.ReflectionKind.Interface)) {
|
|
13
13
|
return (utils_1.JSX.createElement("div", { class: "tsd-signature" },
|
|
14
14
|
utils_1.JSX.createElement("span", { class: "tsd-signature-keyword" }, "interface "),
|
|
15
|
-
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) },
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
utils_1.JSX.createElement("span", { class: (0, lib_1.getKindClass)(props) }, props.name),
|
|
16
|
+
(0, lib_1.renderTypeParametersSignature)(context, props.typeParameters),
|
|
17
|
+
" ",
|
|
18
18
|
context.type(new models_1.ReflectionType(props), { topLevelLinks: true })));
|
|
19
19
|
}
|
|
20
20
|
}
|