umberto 6.1.1 → 7.0.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.
Files changed (30) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +1 -1
  3. package/scripts/filter/before-post-render/has-own-favicons.js +12 -0
  4. package/scripts/utils/has-own-favicons.js +48 -0
  5. package/src/api-builder/utils/findtargetdoclet.js +2 -2
  6. package/src/data-converter/converters/typedoc/abstractparser.js +54 -50
  7. package/src/data-converter/converters/typedoc/accessorparser.js +7 -5
  8. package/src/data-converter/converters/typedoc/classparser.js +5 -3
  9. package/src/data-converter/converters/typedoc/computedpropertyparser.js +4 -3
  10. package/src/data-converter/converters/typedoc/constantparser.js +5 -3
  11. package/src/data-converter/converters/typedoc/constructorparser.js +4 -3
  12. package/src/data-converter/converters/typedoc/errorparser.js +4 -10
  13. package/src/data-converter/converters/typedoc/eventparser.js +4 -10
  14. package/src/data-converter/converters/typedoc/functionparser.js +5 -3
  15. package/src/data-converter/converters/typedoc/interfaceparser.js +5 -3
  16. package/src/data-converter/converters/typedoc/methodparser.js +6 -4
  17. package/src/data-converter/converters/typedoc/moduleparser.js +9 -3
  18. package/src/data-converter/converters/typedoc/propertyparser.js +7 -28
  19. package/src/data-converter/converters/typedoc/referenceparser.js +41 -0
  20. package/src/data-converter/converters/typedoc/reflectionkind.js +34 -0
  21. package/src/data-converter/converters/typedoc/typedoc.ts +215 -214
  22. package/src/data-converter/converters/typedoc/typedocconverter.js +130 -99
  23. package/src/data-converter/converters/typedoc/typeparser.js +10 -6
  24. package/src/data-converter/converters/typedoc2umberto.js +9 -3
  25. package/themes/umberto/layout/gloria/_api-docs/_mixin/_type.pug +9 -0
  26. package/themes/umberto/layout/gloria/_partial/head.pug +7 -4
  27. package/themes/umberto/layout/umberto/_api-docs/_mixin/_type.pug +9 -0
  28. package/themes/umberto/layout/umberto/_partial/head.pug +7 -4
  29. package/themes/umberto/src/gloria/js/_codeswitcherbuttons.js +2 -2
  30. package/themes/umberto/src/umberto/js/_codeswitcherbuttons.js +2 -2
@@ -6,286 +6,287 @@
6
6
  // This file contains several types and definitions used in the Typedoc converter mechanism.
7
7
  // It is not loaded anywhere in Umberto, and should not cause any errors.
8
8
 
9
- /**
10
- * @typeParameter V Kind string.
11
- */
12
- export type TypedocReflectionMeta<V extends string> = {
9
+ import type * as ReflectionKind from './reflectionkind.js';
13
10
 
14
- /**
15
- * A name of a parser that should process given structure.
16
- */
17
- kindString: V;
11
+ export type TypedocCommentItem = {
12
+ kind: 'text' | 'code' | 'inline-tag';
13
+ text: string;
18
14
 
19
15
  /**
20
- * An internal (Typedoc) kind identifier.
16
+ * Available when `kind === 'inline-tag'`.
21
17
  */
22
- kind: number;
18
+ tag?: string;
23
19
 
24
20
  /**
25
- * An identifier used to map reference reflections.
21
+ * Available if `tag === '@link'` and it points to an existing reflection.
26
22
  */
27
- id: number;
23
+ target?: number;
24
+ };
28
25
 
29
- /**
30
- * A name of a member.
31
- */
26
+ export type BaseReflection<T> = {
27
+ id: number;
28
+ kind: T;
32
29
  name: string;
33
-
30
+ variant: 'declaration' | 'reference' | 'signature';
34
31
  flags: Record<
35
32
  'isReadonly' | 'isPrivate' | 'isProtected' | 'isPublic' | 'isStatic' | 'isOptional' | 'isRest' | 'isExternal',
36
33
  true | undefined
37
34
  >;
38
-
39
35
  comment?: {
40
-
41
- /**
42
- * A description of the code. It contains all text found before processing annotations.
43
- */
44
36
  summary: Array<TypedocCommentItem>;
45
-
46
- /**
47
- * Annotations that require additional description, e.g. `@param`.
48
- */
49
37
  blockTags: Array<{
50
38
  tag: `@${ string }`;
51
39
  name: string;
52
40
  content: Array<TypedocCommentItem>;
53
41
  }>;
54
-
55
- /**
56
- * Annotation without descriptions, e.g. `@internal`.
57
- */
58
42
  modifierTags: Array<`@${ string }`>;
59
43
  };
44
+ sources?: Array<{
45
+ fileName: string;
46
+ line: number;
47
+ character: number;
48
+ url: string;
49
+ }>;
50
+ };
51
+
52
+ export type ProjectReflection = BaseReflection<typeof ReflectionKind.Project> & {
53
+ children: Array<ModuleReflection>;
54
+ };
55
+
56
+ export type ModuleReflection = BaseReflection<typeof ReflectionKind.Module> & {
57
+ children: Array<
58
+ VariableReflection |
59
+ FunctionReflection |
60
+ CKEditor5ErrorReflection |
61
+ ClassReflection |
62
+ InterfaceReflection |
63
+ ReferenceReflection |
64
+ LiteralObjectReflection
65
+ >;
66
+ };
67
+
68
+ export type VariableReflection = BaseReflection<typeof ReflectionKind.Variable> & {
69
+ type: AvailableTypes;
70
+ defaultValue: string;
71
+ };
72
+
73
+ export type ReferenceReflection = BaseReflection<typeof ReflectionKind.Reference> & {
74
+ variant: 'reference';
75
+ target: number;
76
+ };
77
+
78
+ export type LiteralObjectReflection = BaseReflection<typeof ReflectionKind.TypeLiteral> & {
79
+ type?: LiteralTypeReflection;
60
80
  };
61
81
 
62
82
  /**
63
- * @typeParam T A name of a parser that should process given structure.
83
+ * CKEditor 5 structures.
64
84
  */
65
- export type TypedocReflection<T extends TypedocParsers> = TypedocReflectionMeta<T> & {
66
85
 
67
- /**
68
- * An array of reflections children if the given structure can be a parent. Otherwise, `undefined`.
69
- */
70
- children: ChildrenMap[T] extends null ? undefined : Array<ChildrenMap[T]>;
86
+ export type CKEditor5ErrorReflection = BaseReflection<typeof ReflectionKind.Document> & {
87
+ isCKEditor5Error: true;
88
+ parameters: Array<ParameterReflection>;
89
+ };
71
90
 
72
- /**
73
- * An array of parent classes or interfaces that given structure extends.
74
- */
75
- extendedTypes: T extends ClassOrInterface ? Array<TypedocReflectionMeta<TypedocParsers>> : undefined;
91
+ export type CKEditor5EventReflection = BaseReflection<typeof ReflectionKind.Document> & {
92
+ parameters: Array<ParameterReflection>;
93
+ };
76
94
 
77
- /**
78
- * An array of interfaces that given class implements.
79
- */
80
- implementedTypes: T extends 'Class' ? Array<TypedocReflectionMeta<TypedocParsers>> : undefined;
95
+ export type Eventable = {
96
+ ckeditor5Events: Array<CKEditor5EventReflection>;
97
+ };
81
98
 
82
- /**
83
- * Type parameters for an interface or a class.
84
- *
85
- * Also, due to lack of knowledge how to create parameters for a custom structure, we keep event arguments here.
86
- */
87
- typeParameters: T extends ClassOrInterface | 'Event' ? Array<TypedocReflectionTypeParameter> : undefined;
99
+ /**
100
+ * OOP.
101
+ */
88
102
 
89
- /**
90
- * Type parameters for a constant or a callable expression.
91
- */
92
- typeParameter: T extends 'Variable' | 'Method' | 'Function' ? Array<TypedocReflectionTypeParameter> : undefined;
103
+ export type TypeParameterReflection = BaseReflection<typeof ReflectionKind.TypeParameter> & {
104
+ type?: AvailableTypes;
105
+ default?: LiteralOrIntrinsic | ReferenceType;
106
+ };
93
107
 
94
- /**
95
- * For inherited properties, the property contains a parent reflection.
96
- */
97
- inheritedFrom: T extends 'Method' | 'Function' ? Record<string, any> : undefined;
108
+ export type Inheritable = {
109
+ extendedTypes: Array<ReferenceType>;
110
+ implementedTypes: Array<ReferenceType>;
111
+ typeParameters: Array<TypeParameterReflection>;
112
+ inheritedFrom: ReferenceType;
113
+ };
98
114
 
99
- /**
100
- * The `signatures` property exists only for callable doclets.
101
- */
102
- signatures: T extends ConstructorOrMethod | 'Function' ? Array<TypedocCallSignature> : undefined;
115
+ export type ClassReflection = BaseReflection<typeof ReflectionKind.Class> & Inheritable & Eventable & {
116
+ children: Array<AccessorReflection | ConstructorReflection | MethodReflection | PropertyReflection>;
117
+ };
103
118
 
104
- /**
105
- * A value defined by an exported constant (`export const ...`).
106
- */
107
- defaultValue: T extends 'Variable' ? TypedocReflectionType : undefined;
119
+ export type InterfaceReflection = BaseReflection<typeof ReflectionKind.Interface> & Inheritable & Eventable & {
120
+ children: Array<AccessorReflection | MethodReflection | PropertyReflection>;
121
+ };
108
122
 
109
- /**
110
- * The `setSignature` and `getSignature` exist only when processing a getter or/and setter.
111
- *
112
- * However, the getter does not allow setting a value. The `set*` property does not exist in such a case.
113
- * The same applies to setters and their `get*` properties.
114
- */
115
- setSignature?: T extends 'Accessor' ? TypedocCallSignature : undefined;
116
- getSignature?: T extends 'Accessor' ? TypedocCallSignature : undefined;
123
+ export type AccessorReflection = BaseReflection<typeof ReflectionKind.Accessor> & {
124
+ getSignature: Omit<
125
+ CallSignatureReflection<typeof ReflectionKind.GetSignature>,
126
+ 'typeParameters' | 'parameters'
127
+ >;
128
+ setSignature: Omit<
129
+ CallSignatureReflection<typeof ReflectionKind.SetSignature>,
130
+ 'typeParameters'
131
+ >;
132
+ };
117
133
 
118
- /**
119
- * An array of sources that defines given structure.
120
- */
121
- sources?: Array<TypedocSource>;
122
- originalName?: string;
134
+ export type PropertyReflection = BaseReflection<typeof ReflectionKind.Property> & {
135
+ type: AvailableTypes;
123
136
  };
124
137
 
125
- export type TypedocReflectionType = TypedocReflectionMeta<'Parameter'> & {
126
- type: TypedocTypeDetails;
127
- elementType?: TypedocTypeDetails;
128
- declaration?: {
129
- signatures?: Array<TypedocCallSignature>;
130
- children?: Array<TypedocReflection<TypedocParsers>>;
131
- };
132
- types?: Array<TypedocReflectionType>;
133
- defaultValue?: string;
138
+ export type ComputedPropertyReflection = BaseReflection<typeof ReflectionKind.IndexSignature>;
139
+
140
+ /**
141
+ * Callables.
142
+ */
143
+
144
+ export type TypedocCallable<T> = {
145
+ signatures: Array<CallSignatureReflection<T>>;
134
146
  };
135
147
 
136
- export type TypedocReflectionTypeParameter = TypedocReflectionMeta<'Type parameter'> & TypedocTypeDetails & {
137
- default?: TypedocTypeDetails;
138
- type?: TypedocReflectionType;
148
+ export type ParameterReflection = BaseReflection<typeof ReflectionKind.Parameter> & {
149
+ type: AvailableTypes;
139
150
  };
140
151
 
141
- export type TypedocCallSignature = TypedocReflectionMeta<'Call signature'> & {
142
- type: TypedocReflectionType;
143
- parameters?: Array<TypedocReflectionType>;
144
- inheritedFrom?: Record<string, any>;
152
+ export type CallSignatureReflection<T> = BaseReflection<T> & {
153
+ type: AvailableTypes;
154
+ parameters?: Array<ParameterReflection>;
155
+ typeParameters?: Array<TypeParameterReflection>;
156
+ inheritedFrom?: ReferenceType;
157
+ children?: Array<PropertyReflection>;
158
+ indexSignatures?: Array<IndexSignatureType>;
145
159
  };
146
160
 
147
- export type TypedocTypeDetails = string | LiteralOrIntrinsic | Reference | TypeOperator |
148
- {
149
- type: 'union';
150
- types: Array<TypedocReflectionType>;
151
- } |
152
- {
153
- type: 'array';
154
- elementType: TypedocTypeDetails;
155
- } |
156
- {
157
- type: 'indexedAccess';
158
- objectType: TypedocTypeDetails;
159
- indexType: TypedocTypeDetails;
160
- } |
161
- {
162
- type: 'reflection';
163
- declaration: {
164
- signatures?: Array<TypedocCallSignature>;
165
- };
166
- } |
167
- {
168
- type: 'tuple';
169
- elements: Array<TypedocTypeDetails>;
170
- } |
171
- {
172
- type: 'named-tuple-member';
173
- element: TypedocTypeDetails;
174
- } |
175
- {
176
- type: 'intersection';
177
- types: Array<TypedocReflectionType>;
178
- } |
179
- {
180
- type: 'query';
181
- queryType: {
182
- name: string;
183
- };
184
- } |
185
- {
186
- type: 'mapped';
187
- parameter: string;
188
- parameterType?: TypeOperator | string;
189
- templateType: LiteralOrIntrinsic;
190
- optionalModifier?: string;
191
- } |
192
- {
193
- type: 'conditional';
194
- checkType: Reference;
195
- extendsType: TypedocTypeDetails;
196
- trueType: TypedocTypeDetails;
197
- falseType: TypedocTypeDetails;
198
- } |
199
- {
200
- type: 'template-literal';
201
- tail: Array<{
202
- type: TypedocTypeDetails;
203
- suffix: string;
204
- }>;
205
- head: string;
206
- } |
207
- {
208
- type: 'predicate';
209
- targetType: TypedocTypeDetails;
161
+ export type ConstructorReflection =
162
+ BaseReflection<typeof ReflectionKind.Constructor> & TypedocCallable<typeof ReflectionKind.ConstructorSignature>;
163
+
164
+ export type MethodReflection =
165
+ BaseReflection<typeof ReflectionKind.Method> & TypedocCallable<typeof ReflectionKind.CallSignature>;
166
+
167
+ export type FunctionReflection =
168
+ BaseReflection<typeof ReflectionKind.Function> & TypedocCallable<typeof ReflectionKind.CallSignature>;
169
+
170
+ /**
171
+ * Types.
172
+ */
173
+
174
+ export type AvailableTypes = string |
175
+ LiteralOrIntrinsic |
176
+ ReferenceType |
177
+ TypeOperator |
178
+ LiteralTypeReflection |
179
+ UnionType |
180
+ ArrayType |
181
+ IndexAccessType |
182
+ TupleType |
183
+ NamedTupleMemberType |
184
+ IntersectionType |
185
+ QueryType |
186
+ MappedType |
187
+ ConditionalType |
188
+ TemplateLiteralType |
189
+ PredicateType;
190
+
191
+ export type LiteralTypeReflection = BaseReflection<typeof ReflectionKind.TypeLiteral> & {
192
+ type: 'reflection';
193
+ declaration?: {
194
+ name: '__type';
195
+ children?: Array<PropertyReflection>;
196
+ signatures?: TypedocCallable<typeof ReflectionKind.CallSignature>;
197
+ indexSignatures?: Array<IndexSignatureType>;
210
198
  };
199
+ };
211
200
 
212
- export type TypedocCommentItem = {
213
- kind: 'text' | 'code' | 'inline-tag';
214
- text: string;
201
+ export type IndexSignatureType = BaseReflection<typeof ReflectionKind.IndexSignature> & {
202
+ name: '__index';
203
+ variant: 'signature';
204
+ parameters: Array<ParameterReflection>;
205
+ type: AvailableTypes;
206
+ };
215
207
 
216
- /**
217
- * Available when `kind === 'inline-tag'`.
218
- */
219
- tag?: string;
208
+ export type UnionType = {
209
+ type: 'union';
210
+ types: Array<LiteralTypeReflection>;
211
+ };
220
212
 
221
- /**
222
- * Available if `tag === '@link'` and it points to an existing reflection.
223
- */
224
- target?: number;
213
+ export type ArrayType = {
214
+ type: 'array';
215
+ elementType: AvailableTypes;
225
216
  };
226
217
 
227
- /**
228
- * Available parsers for processing reflections.
229
- */
230
- export type TypedocParsers = keyof ChildrenMap;
218
+ export type IndexAccessType = {
219
+ type: 'indexedAccess';
220
+ objectType: AvailableTypes;
221
+ indexType: AvailableTypes;
222
+ };
231
223
 
232
- /**
233
- * An alias for callable properties from a class or an interface.
234
- */
235
- export type ConstructorOrMethod = 'Constructor' | 'Method';
224
+ export type TupleType = {
225
+ type: 'tuple';
226
+ elements: Array<AvailableTypes>;
227
+ };
236
228
 
237
- /**
238
- * An alias for types that contains children.
239
- */
240
- type ClassOrInterface = 'Class' | 'Interface';
229
+ export type NamedTupleMemberType = {
230
+ type: 'namedTupleMember';
231
+ element: AvailableTypes;
232
+ };
241
233
 
242
- /**
243
- * A map containing the possible types of children for a given parent type.
244
- */
245
- type ChildrenMap = {
246
- // Root.
247
- Module: TypedocReflection<ClassOrInterface | 'Function' | 'Type alias' | 'Error' | 'Variable'>;
234
+ export type IntersectionType = {
235
+ type: 'intersection';
236
+ types: Array<LiteralTypeReflection>;
237
+ };
248
238
 
249
- // Module children.
250
- Class: TypedocReflection<ConstructorOrMethod | 'Event' | 'Accessor' | 'Property'>;
251
- Interface: TypedocReflection<ConstructorOrMethod | 'Event' | 'Accessor' | 'Property'>;
252
- Function: null;
253
- 'Type alias': null;
254
- Error: null;
255
- Variable: null;
239
+ export type QueryType = {
240
+ type: 'query';
241
+ queryType: {
242
+ name: string;
243
+ };
244
+ };
256
245
 
257
- // Class/interface children.
258
- Constructor: null;
259
- Method: null;
260
- Property: null;
261
- Accessor: null;
262
- Event: null;
246
+ export type MappedType = {
247
+ type: 'mapped';
248
+ parameter: string;
249
+ parameterType?: TypeOperator | string;
250
+ templateType: LiteralOrIntrinsic;
251
+ optionalModifier?: string;
252
+ };
263
253
 
264
- // A special "parser" that points to an existing doclet that most probably has been already converted.
265
- Reference: null;
254
+ export type ConditionalType = {
255
+ type: 'conditional';
256
+ checkType: ReferenceType;
257
+ extendsType: AvailableTypes;
258
+ trueType: AvailableTypes;
259
+ falseType: AvailableTypes;
260
+ };
266
261
 
267
- // To detect if a specified argument is a class instance or a function.
268
- 'Constructor signature': null;
262
+ export type TemplateLiteralType = {
263
+ type: 'templateLiteral';
264
+ tail: Array<{
265
+ type: AvailableTypes;
266
+ suffix: string;
267
+ }>;
268
+ head: string;
269
269
  };
270
270
 
271
- type TypedocSource = {
272
- fileName: string;
273
- line: number;
274
- character: number;
275
- url: string;
271
+ export type PredicateType = {
272
+ type: 'predicate';
273
+ targetType: AvailableTypes;
276
274
  };
277
275
 
278
- type Reference = {
276
+ export type ReferenceType = {
279
277
  type: 'reference';
280
- name: string;
281
- id?: number;
282
- typeArguments?: Array<TypedocReflectionTypeParameter>;
278
+ target: number | {
279
+ packageName: 'typescript';
280
+ packagePath: string;
281
+ qualifiedName: string;
282
+ };
283
+ typeArguments?: Array<TypeParameterReflection>;
283
284
  };
284
285
 
285
- type TypeOperator = {
286
+ export type TypeOperator = {
286
287
  type: 'typeOperator';
287
288
  operator: string;
288
- target: Reference;
289
+ target: ReferenceType;
289
290
  };
290
291
 
291
292
  type LiteralOrIntrinsic =