typedoc 0.26.0-beta.2 → 0.26.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/lib/application.d.ts +6 -1
- package/dist/lib/application.js +10 -0
- package/dist/lib/cli.js +14 -0
- package/dist/lib/converter/comments/discovery.js +0 -1
- package/dist/lib/converter/comments/index.d.ts +1 -1
- package/dist/lib/converter/comments/index.js +5 -2
- package/dist/lib/converter/comments/textParser.d.ts +0 -3
- package/dist/lib/converter/comments/textParser.js +39 -3
- package/dist/lib/converter/context.d.ts +2 -2
- package/dist/lib/converter/context.js +2 -4
- package/dist/lib/converter/converter.d.ts +1 -0
- package/dist/lib/converter/converter.js +58 -9
- package/dist/lib/converter/factories/index-signature.js +1 -1
- package/dist/lib/converter/plugins/ImplementsPlugin.js +3 -2
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +7 -0
- package/dist/lib/converter/plugins/SourcePlugin.d.ts +1 -15
- package/dist/lib/converter/plugins/SourcePlugin.js +4 -45
- package/dist/lib/converter/symbols.js +22 -0
- package/dist/lib/converter/types.js +20 -1
- package/dist/lib/converter/utils/repository.d.ts +46 -1
- package/dist/lib/converter/utils/repository.js +191 -64
- package/dist/lib/internationalization/internationalization.d.ts +5 -2
- package/dist/lib/internationalization/internationalization.js +42 -1
- package/dist/lib/internationalization/locales/jp.cjs +308 -0
- package/dist/lib/internationalization/locales/jp.d.cts +307 -0
- package/dist/lib/internationalization/locales/zh.cjs +308 -0
- package/dist/lib/internationalization/locales/zh.d.cts +307 -0
- package/dist/lib/internationalization/translatable.d.ts +187 -164
- package/dist/lib/internationalization/translatable.js +185 -163
- package/dist/lib/models/comments/comment.d.ts +29 -3
- package/dist/lib/models/comments/comment.js +6 -0
- package/dist/lib/models/reflections/abstract.d.ts +12 -11
- package/dist/lib/models/reflections/abstract.js +46 -49
- package/dist/lib/models/reflections/document.d.ts +6 -1
- package/dist/lib/models/reflections/document.js +12 -2
- package/dist/lib/models/reflections/kind.d.ts +2 -0
- package/dist/lib/models/reflections/kind.js +3 -1
- package/dist/lib/models/reflections/project.js +1 -0
- package/dist/lib/models/reflections/signature.js +7 -2
- package/dist/lib/models/types.d.ts +9 -1
- package/dist/lib/models/types.js +5 -18
- package/dist/lib/output/components.d.ts +2 -0
- package/dist/lib/output/components.js +139 -66
- package/dist/lib/output/models/UrlMapping.d.ts +4 -0
- package/dist/lib/output/plugins/IconsPlugin.js +21 -17
- package/dist/lib/output/renderer.d.ts +16 -0
- package/dist/lib/output/themes/MarkedPlugin.js +8 -2
- package/dist/lib/output/themes/default/DefaultTheme.js +5 -2
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -3
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +3 -2
- package/dist/lib/output/themes/default/layouts/default.js +10 -10
- package/dist/lib/output/themes/default/partials/comment.d.ts +2 -2
- package/dist/lib/output/themes/default/partials/comment.js +24 -15
- package/dist/lib/output/themes/default/partials/footer.js +2 -2
- package/dist/lib/output/themes/default/partials/index.js +1 -1
- package/dist/lib/output/themes/default/partials/member.declaration.js +30 -4
- package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +2 -1
- package/dist/lib/output/themes/default/partials/member.signature.title.js +1 -2
- package/dist/lib/output/themes/default/partials/members.group.js +17 -10
- package/dist/lib/output/themes/default/partials/members.js +7 -3
- package/dist/lib/output/themes/default/partials/navigation.js +10 -4
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +3 -2
- package/dist/lib/output/themes/default/partials/type.js +26 -2
- package/dist/lib/output/themes/default/templates/reflection.js +2 -2
- package/dist/lib/output/themes/lib.d.ts +0 -1
- package/dist/lib/output/themes/lib.js +0 -4
- package/dist/lib/serialization/schema.d.ts +23 -11
- package/dist/lib/serialization/serializer.d.ts +1 -1
- package/dist/lib/utils/component.js +0 -3
- package/dist/lib/utils/events.js +0 -1
- package/dist/lib/utils/general.d.ts +1 -0
- package/dist/lib/utils/general.js +5 -0
- package/dist/lib/utils/html-entities.json +2324 -2231
- package/dist/lib/utils/html.d.ts +59 -1
- package/dist/lib/utils/html.js +577 -19
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/help.js +0 -1
- package/dist/lib/utils/options/options.js +0 -1
- package/dist/lib/utils/options/sources/typedoc.js +6 -0
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
- package/dist/lib/utils/options/tsdoc-defaults.js +5 -1
- package/dist/lib/utils/paths.js +11 -1
- package/dist/lib/utils/perf.js +3 -1
- package/dist/lib/utils/sort.js +4 -13
- package/dist/lib/validation/links.d.ts +1 -1
- package/dist/lib/validation/links.js +42 -7
- package/package.json +5 -7
- package/static/main.js +4 -4
- package/static/style.css +11 -2
- package/dist/lib/converter/utils/base-path.d.ts +0 -36
- package/dist/lib/converter/utils/base-path.js +0 -112
- package/dist/lib/internationalization/locales/test.cjs +0 -8
- package/dist/lib/internationalization/locales/test.d.cts +0 -5
|
@@ -59,23 +59,19 @@ var ReflectionFlag;
|
|
|
59
59
|
ReflectionFlag[ReflectionFlag["Protected"] = 2] = "Protected";
|
|
60
60
|
ReflectionFlag[ReflectionFlag["Public"] = 4] = "Public";
|
|
61
61
|
ReflectionFlag[ReflectionFlag["Static"] = 8] = "Static";
|
|
62
|
-
ReflectionFlag[ReflectionFlag["
|
|
63
|
-
ReflectionFlag[ReflectionFlag["
|
|
64
|
-
ReflectionFlag[ReflectionFlag["
|
|
65
|
-
ReflectionFlag[ReflectionFlag["
|
|
66
|
-
ReflectionFlag[ReflectionFlag["
|
|
67
|
-
ReflectionFlag[ReflectionFlag["
|
|
68
|
-
ReflectionFlag[ReflectionFlag["
|
|
69
|
-
ReflectionFlag[ReflectionFlag["Let"] = 2048] = "Let";
|
|
70
|
-
ReflectionFlag[ReflectionFlag["Readonly"] = 4096] = "Readonly";
|
|
62
|
+
ReflectionFlag[ReflectionFlag["External"] = 16] = "External";
|
|
63
|
+
ReflectionFlag[ReflectionFlag["Optional"] = 32] = "Optional";
|
|
64
|
+
ReflectionFlag[ReflectionFlag["Rest"] = 64] = "Rest";
|
|
65
|
+
ReflectionFlag[ReflectionFlag["Abstract"] = 128] = "Abstract";
|
|
66
|
+
ReflectionFlag[ReflectionFlag["Const"] = 256] = "Const";
|
|
67
|
+
ReflectionFlag[ReflectionFlag["Readonly"] = 512] = "Readonly";
|
|
68
|
+
ReflectionFlag[ReflectionFlag["Inherited"] = 1024] = "Inherited";
|
|
71
69
|
})(ReflectionFlag || (exports.ReflectionFlag = ReflectionFlag = {}));
|
|
72
70
|
const relevantFlags = [
|
|
73
71
|
ReflectionFlag.Private,
|
|
74
72
|
ReflectionFlag.Protected,
|
|
75
73
|
ReflectionFlag.Static,
|
|
76
|
-
ReflectionFlag.ExportAssignment,
|
|
77
74
|
ReflectionFlag.Optional,
|
|
78
|
-
ReflectionFlag.DefaultValue,
|
|
79
75
|
ReflectionFlag.Rest,
|
|
80
76
|
ReflectionFlag.Abstract,
|
|
81
77
|
ReflectionFlag.Const,
|
|
@@ -84,9 +80,8 @@ const relevantFlags = [
|
|
|
84
80
|
/**
|
|
85
81
|
* This must extend Array in order to work with Handlebar's each helper.
|
|
86
82
|
*/
|
|
87
|
-
class ReflectionFlags
|
|
83
|
+
class ReflectionFlags {
|
|
88
84
|
constructor() {
|
|
89
|
-
super(...arguments);
|
|
90
85
|
this.flags = ReflectionFlag.None;
|
|
91
86
|
}
|
|
92
87
|
hasFlag(flag) {
|
|
@@ -136,9 +131,6 @@ class ReflectionFlags extends Array {
|
|
|
136
131
|
get isRest() {
|
|
137
132
|
return this.hasFlag(ReflectionFlag.Rest);
|
|
138
133
|
}
|
|
139
|
-
get hasExportAssignment() {
|
|
140
|
-
return this.hasFlag(ReflectionFlag.ExportAssignment);
|
|
141
|
-
}
|
|
142
134
|
get isAbstract() {
|
|
143
135
|
return this.hasFlag(ReflectionFlag.Abstract);
|
|
144
136
|
}
|
|
@@ -148,6 +140,9 @@ class ReflectionFlags extends Array {
|
|
|
148
140
|
get isReadonly() {
|
|
149
141
|
return this.hasFlag(ReflectionFlag.Readonly);
|
|
150
142
|
}
|
|
143
|
+
get isInherited() {
|
|
144
|
+
return this.hasFlag(ReflectionFlag.Inherited);
|
|
145
|
+
}
|
|
151
146
|
setFlag(flag, set) {
|
|
152
147
|
switch (flag) {
|
|
153
148
|
case ReflectionFlag.Private:
|
|
@@ -175,18 +170,20 @@ class ReflectionFlags extends Array {
|
|
|
175
170
|
this.setSingleFlag(flag, set);
|
|
176
171
|
}
|
|
177
172
|
}
|
|
173
|
+
getFlagStrings(i18n) {
|
|
174
|
+
const strings = [];
|
|
175
|
+
for (const flag of relevantFlags) {
|
|
176
|
+
if (this.hasFlag(flag)) {
|
|
177
|
+
strings.push(i18n.flagString(flag));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return strings;
|
|
181
|
+
}
|
|
178
182
|
setSingleFlag(flag, set) {
|
|
179
|
-
const name = ReflectionFlag[flag].replace(/(.)([A-Z])/g, (_m, a, b) => a + " " + b.toLowerCase());
|
|
180
183
|
if (!set && this.hasFlag(flag)) {
|
|
181
|
-
if (relevantFlags.includes(flag)) {
|
|
182
|
-
this.splice(this.indexOf(name), 1);
|
|
183
|
-
}
|
|
184
184
|
this.flags ^= flag;
|
|
185
185
|
}
|
|
186
186
|
else if (set && !this.hasFlag(flag)) {
|
|
187
|
-
if (relevantFlags.includes(flag)) {
|
|
188
|
-
this.push(name);
|
|
189
|
-
}
|
|
190
187
|
this.flags |= flag;
|
|
191
188
|
}
|
|
192
189
|
}
|
|
@@ -213,10 +210,10 @@ ReflectionFlags.serializedFlags = [
|
|
|
213
210
|
"isExternal",
|
|
214
211
|
"isOptional",
|
|
215
212
|
"isRest",
|
|
216
|
-
"hasExportAssignment",
|
|
217
213
|
"isAbstract",
|
|
218
214
|
"isConst",
|
|
219
215
|
"isReadonly",
|
|
216
|
+
"isInherited",
|
|
220
217
|
];
|
|
221
218
|
var TraverseProperty;
|
|
222
219
|
(function (TraverseProperty) {
|
|
@@ -326,33 +323,33 @@ let Reflection = (() => {
|
|
|
326
323
|
* Return an url safe alias for this reflection.
|
|
327
324
|
*/
|
|
328
325
|
getAlias() {
|
|
329
|
-
|
|
330
|
-
let alias = this.name.replace(/\W/g, "_");
|
|
331
|
-
if (alias === "") {
|
|
332
|
-
alias = `reflection-${this.id}`;
|
|
333
|
-
}
|
|
334
|
-
// NTFS/ExFAT use uppercase, so we will too. It probably won't matter
|
|
335
|
-
// in this case since names will generally be valid identifiers, but to be safe...
|
|
336
|
-
const upperAlias = alias.toUpperCase();
|
|
337
|
-
let target = this;
|
|
338
|
-
while (target.parent && !target.hasOwnDocument) {
|
|
339
|
-
target = target.parent;
|
|
340
|
-
}
|
|
341
|
-
target._aliases ||= new Map();
|
|
342
|
-
let suffix = "";
|
|
343
|
-
if (!target._aliases.has(upperAlias)) {
|
|
344
|
-
target._aliases.set(upperAlias, 1);
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
const count = target._aliases.get(upperAlias);
|
|
348
|
-
suffix = "-" + count.toString();
|
|
349
|
-
target._aliases.set(upperAlias, count + 1);
|
|
350
|
-
}
|
|
351
|
-
alias += suffix;
|
|
352
|
-
this._alias = alias;
|
|
353
|
-
}
|
|
326
|
+
this._alias ||= this.getUniqueAliasInPage(this.name.replace(/\W/g, "_") || `reflection-${this.id}`);
|
|
354
327
|
return this._alias;
|
|
355
328
|
}
|
|
329
|
+
// This really ought not live here, it ought to live in the html renderer, but moving that
|
|
330
|
+
// is more work than I want right now, it can wait for 0.27 when trying to split models into
|
|
331
|
+
// a bundleable structure.
|
|
332
|
+
getUniqueAliasInPage(heading) {
|
|
333
|
+
// NTFS/ExFAT use uppercase, so we will too. It probably won't matter
|
|
334
|
+
// in this case since names will generally be valid identifiers, but to be safe...
|
|
335
|
+
const upperAlias = heading.toUpperCase();
|
|
336
|
+
let target = this;
|
|
337
|
+
while (target.parent && !target.hasOwnDocument) {
|
|
338
|
+
target = target.parent;
|
|
339
|
+
}
|
|
340
|
+
target._aliases ||= new Map();
|
|
341
|
+
let suffix = "";
|
|
342
|
+
if (!target._aliases.has(upperAlias)) {
|
|
343
|
+
target._aliases.set(upperAlias, 1);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
const count = target._aliases.get(upperAlias);
|
|
347
|
+
suffix = "-" + count.toString();
|
|
348
|
+
target._aliases.set(upperAlias, count + 1);
|
|
349
|
+
}
|
|
350
|
+
heading += suffix;
|
|
351
|
+
return heading;
|
|
352
|
+
}
|
|
356
353
|
/**
|
|
357
354
|
* Has this reflection a visible comment?
|
|
358
355
|
*
|
|
@@ -19,9 +19,14 @@ export declare class DocumentReflection extends Reflection {
|
|
|
19
19
|
* boosting search relevance scores at runtime. May be modified by plugins.
|
|
20
20
|
*/
|
|
21
21
|
relevanceBoost?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Child documents, if any are present.
|
|
24
|
+
*/
|
|
25
|
+
children?: DocumentReflection[];
|
|
22
26
|
constructor(name: string, parent: Reflection, content: CommentDisplayPart[], frontmatter: Record<string, unknown>);
|
|
27
|
+
addChild(child: DocumentReflection): void;
|
|
23
28
|
isDocument(): this is DocumentReflection;
|
|
24
|
-
traverse(
|
|
29
|
+
traverse(callback: TraverseCallback): void;
|
|
25
30
|
toObject(serializer: Serializer): JSONOutput.DocumentReflection;
|
|
26
31
|
fromObject(de: Deserializer, obj: JSONOutput.DocumentReflection): void;
|
|
27
32
|
}
|
|
@@ -18,11 +18,19 @@ class DocumentReflection extends abstract_1.Reflection {
|
|
|
18
18
|
delete frontmatter["title"];
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
addChild(child) {
|
|
22
|
+
this.children ||= [];
|
|
23
|
+
this.children.push(child);
|
|
24
|
+
}
|
|
21
25
|
isDocument() {
|
|
22
26
|
return true;
|
|
23
27
|
}
|
|
24
|
-
traverse(
|
|
25
|
-
|
|
28
|
+
traverse(callback) {
|
|
29
|
+
for (const child of this.children || []) {
|
|
30
|
+
if (callback(child, abstract_1.TraverseProperty.Documents) === false) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
toObject(serializer) {
|
|
28
36
|
return {
|
|
@@ -31,6 +39,7 @@ class DocumentReflection extends abstract_1.Reflection {
|
|
|
31
39
|
content: comments_1.Comment.serializeDisplayParts(serializer, this.content),
|
|
32
40
|
frontmatter: this.frontmatter,
|
|
33
41
|
relevanceBoost: this.relevanceBoost,
|
|
42
|
+
children: serializer.toObjectsOptional(this.children),
|
|
34
43
|
};
|
|
35
44
|
}
|
|
36
45
|
fromObject(de, obj) {
|
|
@@ -38,6 +47,7 @@ class DocumentReflection extends abstract_1.Reflection {
|
|
|
38
47
|
this.content = comments_1.Comment.deserializeDisplayParts(de, obj.content);
|
|
39
48
|
this.frontmatter = obj.frontmatter;
|
|
40
49
|
this.relevanceBoost = obj.relevanceBoost;
|
|
50
|
+
this.children = de.reviveMany(obj.children, (obj) => de.reflectionBuilders.document(this, obj));
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
exports.DocumentReflection = DocumentReflection;
|
|
@@ -35,6 +35,7 @@ export declare enum ReflectionKind {
|
|
|
35
35
|
/** @category Reflections */
|
|
36
36
|
export declare namespace ReflectionKind {
|
|
37
37
|
type KindString = EnumKeys<typeof ReflectionKind>;
|
|
38
|
+
/** @internal */
|
|
38
39
|
const All: number;
|
|
39
40
|
/** @internal */
|
|
40
41
|
const ClassOrInterface: number;
|
|
@@ -56,6 +57,7 @@ export declare namespace ReflectionKind {
|
|
|
56
57
|
const SomeMember: number;
|
|
57
58
|
/** @internal */
|
|
58
59
|
const SomeExport: number;
|
|
60
|
+
/** @internal */
|
|
59
61
|
const MayContainDocuments: number;
|
|
60
62
|
/** @internal */
|
|
61
63
|
const ExportContainer: number;
|
|
@@ -37,6 +37,7 @@ var ReflectionKind;
|
|
|
37
37
|
})(ReflectionKind || (exports.ReflectionKind = ReflectionKind = {}));
|
|
38
38
|
/** @category Reflections */
|
|
39
39
|
(function (ReflectionKind) {
|
|
40
|
+
/** @internal */
|
|
40
41
|
ReflectionKind.All = ReflectionKind.Reference * 2 - 1;
|
|
41
42
|
/** @internal */
|
|
42
43
|
ReflectionKind.ClassOrInterface = ReflectionKind.Class | ReflectionKind.Interface;
|
|
@@ -79,7 +80,8 @@ var ReflectionKind;
|
|
|
79
80
|
ReflectionKind.Interface |
|
|
80
81
|
ReflectionKind.TypeAlias |
|
|
81
82
|
ReflectionKind.Reference;
|
|
82
|
-
|
|
83
|
+
/** @internal */
|
|
84
|
+
ReflectionKind.MayContainDocuments = ReflectionKind.SomeExport | ReflectionKind.Project | ReflectionKind.Document;
|
|
83
85
|
/** @internal */
|
|
84
86
|
ReflectionKind.ExportContainer = ReflectionKind.SomeModule | ReflectionKind.Project;
|
|
85
87
|
/** @internal */
|
|
@@ -298,6 +298,7 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
298
298
|
}
|
|
299
299
|
this.files.fromObject(de, obj.files);
|
|
300
300
|
de.defer(() => {
|
|
301
|
+
// Unnecessary conditional in release
|
|
301
302
|
for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
|
|
302
303
|
const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
|
|
303
304
|
if (refl) {
|
|
@@ -50,7 +50,7 @@ class SignatureReflection extends abstract_1.Reflection {
|
|
|
50
50
|
...super.toObject(serializer),
|
|
51
51
|
variant: this.variant,
|
|
52
52
|
sources: serializer.toObjectsOptional(this.sources),
|
|
53
|
-
|
|
53
|
+
typeParameters: serializer.toObjectsOptional(this.typeParameters),
|
|
54
54
|
parameters: serializer.toObjectsOptional(this.parameters),
|
|
55
55
|
type: serializer.toObject(this.type),
|
|
56
56
|
overwrites: serializer.toObject(this.overwrites),
|
|
@@ -61,7 +61,12 @@ class SignatureReflection extends abstract_1.Reflection {
|
|
|
61
61
|
fromObject(de, obj) {
|
|
62
62
|
super.fromObject(de, obj);
|
|
63
63
|
this.sources = de.reviveMany(obj.sources, (t) => new file_1.SourceReference(t.fileName, t.line, t.character));
|
|
64
|
-
|
|
64
|
+
if (obj.typeParameter) {
|
|
65
|
+
this.typeParameters = de.reviveMany(obj.typeParameter, (t) => de.constructReflection(t));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.typeParameters = de.reviveMany(obj.typeParameters, (t) => de.constructReflection(t));
|
|
69
|
+
}
|
|
65
70
|
this.parameters = de.reviveMany(obj.parameters, (t) => de.constructReflection(t));
|
|
66
71
|
this.type = de.reviveType(obj.type);
|
|
67
72
|
this.overwrites = de.reviveType(obj.overwrites);
|
|
@@ -6,6 +6,7 @@ import type { ProjectReflection } from "./reflections/project";
|
|
|
6
6
|
import type { Serializer, JSONOutput, Deserializer } from "../serialization";
|
|
7
7
|
import { ReflectionSymbolId } from "./reflections/ReflectionSymbolId";
|
|
8
8
|
import type { DeclarationReference } from "../converter/comments/declarationReference";
|
|
9
|
+
import { type CommentDisplayPart } from "./comments";
|
|
9
10
|
/**
|
|
10
11
|
* Base class of all type definitions.
|
|
11
12
|
* @category Types
|
|
@@ -507,10 +508,17 @@ export declare class TypeOperatorType extends Type {
|
|
|
507
508
|
export declare class UnionType extends Type {
|
|
508
509
|
types: SomeType[];
|
|
509
510
|
readonly type = "union";
|
|
511
|
+
/**
|
|
512
|
+
* If present, there should be as many items in this array as there are items in the {@link types} array.
|
|
513
|
+
*
|
|
514
|
+
* This member is only valid on unions which are on {@link DeclarationReflection.type | DeclarationReflection.type} with a
|
|
515
|
+
* {@link ReflectionKind} `kind` of `TypeAlias`. Specifying it on any other union is undefined behavior.
|
|
516
|
+
*/
|
|
517
|
+
elementSummaries?: CommentDisplayPart[][];
|
|
510
518
|
constructor(types: SomeType[]);
|
|
511
519
|
protected getTypeString(): string;
|
|
512
520
|
needsParenthesis(context: TypeContext): boolean;
|
|
513
|
-
|
|
521
|
+
fromObject(de: Deserializer, obj: JSONOutput.UnionType): void;
|
|
514
522
|
toObject(serializer: Serializer): JSONOutput.UnionType;
|
|
515
523
|
}
|
|
516
524
|
/**
|
package/dist/lib/models/types.js
CHANGED
|
@@ -30,6 +30,7 @@ const tsutils_1 = require("../utils/tsutils");
|
|
|
30
30
|
const ReflectionSymbolId_1 = require("./reflections/ReflectionSymbolId");
|
|
31
31
|
const fs_1 = require("../utils/fs");
|
|
32
32
|
const kind_1 = require("./reflections/kind");
|
|
33
|
+
const comments_1 = require("./comments");
|
|
33
34
|
/**
|
|
34
35
|
* Base class of all type definitions.
|
|
35
36
|
* @category Types
|
|
@@ -1092,7 +1093,6 @@ class UnionType extends Type {
|
|
|
1092
1093
|
super();
|
|
1093
1094
|
this.types = types;
|
|
1094
1095
|
this.type = "union";
|
|
1095
|
-
this.normalize();
|
|
1096
1096
|
}
|
|
1097
1097
|
getTypeString() {
|
|
1098
1098
|
return this.types
|
|
@@ -1127,29 +1127,16 @@ class UnionType extends Type {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
return map[context];
|
|
1129
1129
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
for (let i = 0; i < this.types.length && (trueIndex === -1 || falseIndex === -1); i++) {
|
|
1134
|
-
const t = this.types[i];
|
|
1135
|
-
if (t instanceof LiteralType) {
|
|
1136
|
-
if (t.value === true) {
|
|
1137
|
-
trueIndex = i;
|
|
1138
|
-
}
|
|
1139
|
-
if (t.value === false) {
|
|
1140
|
-
falseIndex = i;
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
if (trueIndex !== -1 && falseIndex !== -1) {
|
|
1145
|
-
this.types.splice(Math.max(trueIndex, falseIndex), 1);
|
|
1146
|
-
this.types.splice(Math.min(trueIndex, falseIndex), 1, new IntrinsicType("boolean"));
|
|
1130
|
+
fromObject(de, obj) {
|
|
1131
|
+
if (obj.elementSummaries) {
|
|
1132
|
+
this.elementSummaries = obj.elementSummaries.map((parts) => comments_1.Comment.deserializeDisplayParts(de, parts));
|
|
1147
1133
|
}
|
|
1148
1134
|
}
|
|
1149
1135
|
toObject(serializer) {
|
|
1150
1136
|
return {
|
|
1151
1137
|
type: this.type,
|
|
1152
1138
|
types: this.types.map((t) => serializer.toObject(t)),
|
|
1139
|
+
elementSummaries: this.elementSummaries?.map((parts) => comments_1.Comment.serializeDisplayParts(serializer, parts)),
|
|
1153
1140
|
};
|
|
1154
1141
|
}
|
|
1155
1142
|
}
|
|
@@ -28,6 +28,8 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
|
|
|
28
28
|
* Regular expression to test if a string looks like an external url.
|
|
29
29
|
*/
|
|
30
30
|
protected urlPrefix: RegExp;
|
|
31
|
+
private get hostedBaseUrl();
|
|
32
|
+
private accessor useHostedBaseUrlForAbsoluteLinks;
|
|
31
33
|
/**
|
|
32
34
|
* Create a new ContextAwareRendererPlugin instance.
|
|
33
35
|
*
|
|
@@ -15,6 +15,40 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
21
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
22
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
23
|
+
var _, done = false;
|
|
24
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
25
|
+
var context = {};
|
|
26
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
27
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
28
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
29
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
}
|
|
37
|
+
else if (_ = accept(result)) {
|
|
38
|
+
if (kind === "field") initializers.unshift(_);
|
|
39
|
+
else descriptor[key] = _;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
43
|
+
done = true;
|
|
44
|
+
};
|
|
45
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
46
|
+
var useValue = arguments.length > 2;
|
|
47
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
48
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
49
|
+
}
|
|
50
|
+
return useValue ? value : void 0;
|
|
51
|
+
};
|
|
18
52
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
53
|
if (mod && mod.__esModule) return mod;
|
|
20
54
|
var result = {};
|
|
@@ -22,82 +56,121 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
56
|
__setModuleDefault(result, mod);
|
|
23
57
|
return result;
|
|
24
58
|
};
|
|
59
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
60
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
61
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
62
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
63
|
+
};
|
|
64
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
65
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
66
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
67
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
68
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
69
|
+
};
|
|
25
70
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
71
|
exports.ContextAwareRendererComponent = exports.RendererComponent = exports.Component = void 0;
|
|
27
72
|
const Path = __importStar(require("path"));
|
|
28
73
|
const component_1 = require("../utils/component");
|
|
29
74
|
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return component_1.Component; } });
|
|
30
75
|
const events_1 = require("./events");
|
|
76
|
+
const utils_1 = require("../utils");
|
|
31
77
|
class RendererComponent extends component_1.AbstractComponent {
|
|
32
78
|
}
|
|
33
79
|
exports.RendererComponent = RendererComponent;
|
|
34
80
|
/**
|
|
35
81
|
* A plugin for the renderer that reads the current render context.
|
|
36
82
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
83
|
+
let ContextAwareRendererComponent = (() => {
|
|
84
|
+
var _a, _ContextAwareRendererComponent_useHostedBaseUrlForAbsoluteLinks_accessor_storage;
|
|
85
|
+
let _classSuper = RendererComponent;
|
|
86
|
+
let _useHostedBaseUrlForAbsoluteLinks_decorators;
|
|
87
|
+
let _useHostedBaseUrlForAbsoluteLinks_initializers = [];
|
|
88
|
+
let _useHostedBaseUrlForAbsoluteLinks_extraInitializers = [];
|
|
89
|
+
return _a = class ContextAwareRendererComponent extends _classSuper {
|
|
90
|
+
constructor() {
|
|
91
|
+
super(...arguments);
|
|
92
|
+
/**
|
|
93
|
+
* The url of the document that is being currently generated.
|
|
94
|
+
* Set when a page begins rendering.
|
|
95
|
+
*
|
|
96
|
+
* Defaulted to '.' so that tests don't have to set up events.
|
|
97
|
+
*/
|
|
98
|
+
this.location = ".";
|
|
99
|
+
/**
|
|
100
|
+
* Regular expression to test if a string looks like an external url.
|
|
101
|
+
*/
|
|
102
|
+
this.urlPrefix = /^(http|ftp)s?:\/\//;
|
|
103
|
+
_ContextAwareRendererComponent_useHostedBaseUrlForAbsoluteLinks_accessor_storage.set(this, __runInitializers(this, _useHostedBaseUrlForAbsoluteLinks_initializers, void 0));
|
|
104
|
+
this.absoluteToRelativePathMap = (__runInitializers(this, _useHostedBaseUrlForAbsoluteLinks_extraInitializers), new Map());
|
|
105
|
+
}
|
|
106
|
+
get hostedBaseUrl() {
|
|
107
|
+
const url = this.application.options.getValue("hostedBaseUrl");
|
|
108
|
+
return !url || url.endsWith("/") ? url : url + "/";
|
|
109
|
+
}
|
|
110
|
+
get useHostedBaseUrlForAbsoluteLinks() { return __classPrivateFieldGet(this, _ContextAwareRendererComponent_useHostedBaseUrlForAbsoluteLinks_accessor_storage, "f"); }
|
|
111
|
+
set useHostedBaseUrlForAbsoluteLinks(value) { __classPrivateFieldSet(this, _ContextAwareRendererComponent_useHostedBaseUrlForAbsoluteLinks_accessor_storage, value, "f"); }
|
|
112
|
+
/**
|
|
113
|
+
* Create a new ContextAwareRendererPlugin instance.
|
|
114
|
+
*
|
|
115
|
+
* @param renderer The renderer this plugin should be attached to.
|
|
116
|
+
*/
|
|
117
|
+
initialize() {
|
|
118
|
+
this.listenTo(this.owner, {
|
|
119
|
+
[events_1.RendererEvent.BEGIN]: this.onBeginRenderer,
|
|
120
|
+
[events_1.PageEvent.BEGIN]: this.onBeginPage,
|
|
121
|
+
[events_1.RendererEvent.END]: () => this.absoluteToRelativePathMap.clear(),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Transform the given absolute path into a relative path.
|
|
126
|
+
*
|
|
127
|
+
* @param absolute The absolute path to transform.
|
|
128
|
+
* @returns A path relative to the document currently processed.
|
|
129
|
+
*/
|
|
130
|
+
getRelativeUrl(absolute) {
|
|
131
|
+
if (this.urlPrefix.test(absolute)) {
|
|
132
|
+
return absolute;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const key = `${this.location}:${absolute}`;
|
|
136
|
+
let path = this.absoluteToRelativePathMap.get(key);
|
|
137
|
+
if (path)
|
|
138
|
+
return path;
|
|
139
|
+
if (this.useHostedBaseUrlForAbsoluteLinks) {
|
|
140
|
+
path = new URL(absolute, this.hostedBaseUrl).toString();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
path = Path.posix.relative(this.location, absolute) || ".";
|
|
144
|
+
}
|
|
145
|
+
this.absoluteToRelativePathMap.set(key, path);
|
|
146
|
+
return path;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Triggered before the renderer starts rendering a project.
|
|
151
|
+
*
|
|
152
|
+
* @param event An event object describing the current render operation.
|
|
153
|
+
*/
|
|
154
|
+
onBeginRenderer(event) {
|
|
155
|
+
this.project = event.project;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Triggered before a document will be rendered.
|
|
159
|
+
*
|
|
160
|
+
* @param page An event object describing the current render operation.
|
|
161
|
+
*/
|
|
162
|
+
onBeginPage(page) {
|
|
163
|
+
this.location = Path.posix.dirname(page.url);
|
|
164
|
+
this.page = page;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
_ContextAwareRendererComponent_useHostedBaseUrlForAbsoluteLinks_accessor_storage = new WeakMap(),
|
|
168
|
+
(() => {
|
|
169
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
170
|
+
_useHostedBaseUrlForAbsoluteLinks_decorators = [(0, utils_1.Option)("useHostedBaseUrlForAbsoluteLinks")];
|
|
171
|
+
__esDecorate(_a, null, _useHostedBaseUrlForAbsoluteLinks_decorators, { kind: "accessor", name: "useHostedBaseUrlForAbsoluteLinks", static: false, private: false, access: { has: obj => "useHostedBaseUrlForAbsoluteLinks" in obj, get: obj => obj.useHostedBaseUrlForAbsoluteLinks, set: (obj, value) => { obj.useHostedBaseUrlForAbsoluteLinks = value; } }, metadata: _metadata }, _useHostedBaseUrlForAbsoluteLinks_initializers, _useHostedBaseUrlForAbsoluteLinks_extraInitializers);
|
|
172
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
173
|
+
})(),
|
|
174
|
+
_a;
|
|
175
|
+
})();
|
|
103
176
|
exports.ContextAwareRendererComponent = ContextAwareRendererComponent;
|
|
@@ -6,4 +6,8 @@ export declare class UrlMapping<Model = any> {
|
|
|
6
6
|
template: RenderTemplate<PageEvent<Model>>;
|
|
7
7
|
constructor(url: string, model: Model, template: RenderTemplate<PageEvent<Model>>);
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @param data the reflection to render
|
|
11
|
+
* @returns either a string to be written to the file, or an element to be serialized and then written.
|
|
12
|
+
*/
|
|
9
13
|
export type RenderTemplate<T> = (data: T) => JSX.Element | string;
|