umberto 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -1
- package/package.json +8 -5
- package/scripts/filter/after-post-render/insert-error-codes.js +3 -1
- package/scripts/utils/transforminfobox.js +13 -2
- package/src/api-builder/classes/description-parser.js +65 -1
- package/src/data-converter/converters/typedoc/abstractparser.js +11 -3
- package/src/data-converter/converters/typedoc/constructorparser.js +5 -0
- package/src/data-converter/converters/typedoc/propertyparser.js +21 -0
- package/src/data-converter/converters/typedoc/typedoc.ts +32 -30
- package/src/data-converter/converters/typedoc/typedocconverter.js +22 -5
- package/themes/umberto/src/css/_top.scss +6 -0
- package/themes/umberto/src/js/_prism.js +5 -0
package/.eslintrc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umberto",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "CKSource Documentation builder",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -56,9 +56,10 @@
|
|
|
56
56
|
"webpack": "^5.74.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@ckeditor/ckeditor5-dev-bump-year": "^
|
|
60
|
-
"@ckeditor/ckeditor5-dev-ci": "^
|
|
61
|
-
"@ckeditor/ckeditor5-dev-
|
|
59
|
+
"@ckeditor/ckeditor5-dev-bump-year": "^34.0.0",
|
|
60
|
+
"@ckeditor/ckeditor5-dev-ci": "^34.0.0",
|
|
61
|
+
"@ckeditor/ckeditor5-dev-docs": "^34.0.0",
|
|
62
|
+
"@ckeditor/ckeditor5-dev-release-tools": "^34.0.0",
|
|
62
63
|
"browser-sync": "^2.27.10",
|
|
63
64
|
"chai": "^4.3.6",
|
|
64
65
|
"chokidar": "^3.5.3",
|
|
@@ -68,7 +69,9 @@
|
|
|
68
69
|
"lint-staged": "^13.0.3",
|
|
69
70
|
"mocha": "^10.0.0",
|
|
70
71
|
"mockery": "^2.1.0",
|
|
71
|
-
"
|
|
72
|
+
"proxyquire": "^2.1.3",
|
|
73
|
+
"sinon": "^14.0.0",
|
|
74
|
+
"typescript": "^4.8.4"
|
|
72
75
|
},
|
|
73
76
|
"engines": {
|
|
74
77
|
"node": ">=14.0.0",
|
|
@@ -49,5 +49,7 @@ hexo.extend.filter.register( 'after_post_render', page => {
|
|
|
49
49
|
$( this ).attr( 'href', relativeUrlHelper( page.path, hrefPath ) );
|
|
50
50
|
} );
|
|
51
51
|
|
|
52
|
-
page.content = page.content.replace( '<p>{@errors}</p>',
|
|
52
|
+
page.content = page.content.replace( '<p>{@errors}</p>', () => {
|
|
53
|
+
return $.html();
|
|
54
|
+
} );
|
|
53
55
|
}, 39 );
|
|
@@ -42,8 +42,19 @@ function processInfobox( content, hexo ) {
|
|
|
42
42
|
|
|
43
43
|
// Remove unwanted indentation.
|
|
44
44
|
const lines = content.split( /\n/ );
|
|
45
|
-
const indentation = lines.length > 1 ? lines[ 1 ].match( /^\s*/ ) : '';
|
|
46
|
-
|
|
45
|
+
const indentation = lines.length > 1 ? lines[ 1 ].match( /^\s*/ )[ 0 ] : '';
|
|
46
|
+
|
|
47
|
+
let pattern;
|
|
48
|
+
|
|
49
|
+
// When using spaces as indentation, some editors may mix them with tabs.
|
|
50
|
+
// In such case, let's try to remove tabs as well. 4 spaces are treat as a single tab character.
|
|
51
|
+
if ( indentation[ 0 ] === ' ' ) {
|
|
52
|
+
pattern = new RegExp( `^${ indentation }|${ '\\t'.repeat( Math.ceil( indentation.length / 4 ) ) }` );
|
|
53
|
+
} else {
|
|
54
|
+
pattern = new RegExp( `^${ indentation }` );
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const trimmedLines = lines.map( line => line.replace( pattern, '' ) );
|
|
47
58
|
content = trimmedLines.join( '\n' );
|
|
48
59
|
|
|
49
60
|
// Remove first linebreak and last linebreak.
|
|
@@ -177,9 +177,73 @@ module.exports = class DescriptionParser {
|
|
|
177
177
|
member = name;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
let targetDoclet = findTargetDoclet( this._dataCollection, { module, structure, member, label, query } );
|
|
181
181
|
let replaceToPhrase;
|
|
182
182
|
|
|
183
|
+
if ( !targetDoclet && options.parentDoclet ) {
|
|
184
|
+
const augmentsNested = [
|
|
185
|
+
// If looking for a property, check if it is defined in a derived class, e.g.,
|
|
186
|
+
//
|
|
187
|
+
// ```ts
|
|
188
|
+
// class A {
|
|
189
|
+
// public foo: any;
|
|
190
|
+
//
|
|
191
|
+
// /**
|
|
192
|
+
// * See {@link ~A#foo}.
|
|
193
|
+
// */
|
|
194
|
+
// public getFoo(): void;
|
|
195
|
+
// }
|
|
196
|
+
// class B extends A {
|
|
197
|
+
// }
|
|
198
|
+
// ```
|
|
199
|
+
//
|
|
200
|
+
// `B` contains the property, so from its perspective, the link is valid.
|
|
201
|
+
// Let's try to parse it as it would be specified as `~B#foo`.
|
|
202
|
+
options.parentDoclet.longname,
|
|
203
|
+
|
|
204
|
+
// When looking for a structure withing the same module, check parent classes, e.g.,
|
|
205
|
+
//
|
|
206
|
+
// ```ts
|
|
207
|
+
// class A {
|
|
208
|
+
// /**
|
|
209
|
+
// * See {@link ~A}.
|
|
210
|
+
// */
|
|
211
|
+
// public getFoo(): void;
|
|
212
|
+
// }
|
|
213
|
+
// class B extends A {
|
|
214
|
+
// }
|
|
215
|
+
// ```
|
|
216
|
+
//
|
|
217
|
+
// `~A` seeing from a module containing the `B` class does not make sense.
|
|
218
|
+
// Let's try to find the proper doclet in parent classes.
|
|
219
|
+
...( options.parentDoclet.augmentsNested || [] )
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
targetDoclet = augmentsNested
|
|
223
|
+
.map( augmentName => {
|
|
224
|
+
const splitResult = splitLongname( augmentName );
|
|
225
|
+
|
|
226
|
+
let structure = [
|
|
227
|
+
`module:${ splitResult.packageName }`,
|
|
228
|
+
...splitResult.directoryNames,
|
|
229
|
+
splitResult.moduleName
|
|
230
|
+
].join( '/' );
|
|
231
|
+
|
|
232
|
+
// When `name` and `className` are equal, we look for a `member` in the `${ structure }~${ className }` doclet.
|
|
233
|
+
if ( splitResult.name === splitResult.className ) {
|
|
234
|
+
structure += `~${ splitResult.className }`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return findTargetDoclet( this._dataCollection, {
|
|
238
|
+
structure,
|
|
239
|
+
member,
|
|
240
|
+
label,
|
|
241
|
+
query
|
|
242
|
+
} );
|
|
243
|
+
} )
|
|
244
|
+
.find( Boolean );
|
|
245
|
+
}
|
|
246
|
+
|
|
183
247
|
if ( targetDoclet ) {
|
|
184
248
|
let href;
|
|
185
249
|
|
|
@@ -203,9 +203,13 @@ module.exports = class AbstractParser {
|
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
const { url } = item.sources[ sourceIndex ];
|
|
207
|
+
|
|
208
|
+
if ( !url ) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return { url };
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
/**
|
|
@@ -330,6 +334,10 @@ module.exports = class AbstractParser {
|
|
|
330
334
|
/**
|
|
331
335
|
* Checks if the member contains the `@skipSource` annotation.
|
|
332
336
|
*
|
|
337
|
+
* Note: The `skipSource` flag can be set to `true` even if the member does not contain the annotation.
|
|
338
|
+
* It happens when the member has not specified `file` property. In such a case, Umberto does not know
|
|
339
|
+
* where to point to a source and decides to skip generating the "See source" button.
|
|
340
|
+
*
|
|
333
341
|
* @param {TypedocReflectionMeta} item
|
|
334
342
|
* @returns {Boolean}
|
|
335
343
|
*/
|
|
@@ -22,6 +22,11 @@ module.exports = class ConstructorParser extends MethodParser {
|
|
|
22
22
|
* @returns {Array.<Object>}
|
|
23
23
|
*/
|
|
24
24
|
parse( item, parentName ) {
|
|
25
|
+
// Absence of sources means that the actual class does not have a constructor.
|
|
26
|
+
if ( !item.sources ) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
const results = super.parse( item, parentName );
|
|
26
31
|
|
|
27
32
|
for ( const item of results ) {
|
|
@@ -50,11 +50,32 @@ module.exports = class PropertyParser extends AbstractParser {
|
|
|
50
50
|
deprecated: this.isDeprecated( item ),
|
|
51
51
|
inherited: !!item.inheritedFrom,
|
|
52
52
|
see: this.getRelated( item, parentName ),
|
|
53
|
+
defaultvalue: this.getDefault( item ),
|
|
53
54
|
|
|
54
55
|
// This property will be filled in the post-processing phase.
|
|
55
56
|
type: null
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the default value of an item defined by the `@defaultValue` or `@default` tags.
|
|
62
|
+
*
|
|
63
|
+
* @param {TypedocReflection} item
|
|
64
|
+
* @returns {String}
|
|
65
|
+
*/
|
|
66
|
+
getDefault( item ) {
|
|
67
|
+
if ( !item.comment || !item.comment.blockTags ) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const defaultTag = item.comment.blockTags.find( blockTag => blockTag.tag === '@defaultValue' || blockTag.tag === '@default' );
|
|
72
|
+
|
|
73
|
+
if ( !defaultTag ) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return defaultTag.content[ 0 ].text;
|
|
78
|
+
}
|
|
58
79
|
};
|
|
59
80
|
|
|
60
81
|
/**
|
|
@@ -144,13 +144,7 @@ export type TypedocCallSignature = TypedocReflectionMeta<'Call signature'> & {
|
|
|
144
144
|
inheritedFrom?: Record<string, any>;
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
export type TypedocTypeDetails = string |
|
|
148
|
-
{
|
|
149
|
-
type: 'reference';
|
|
150
|
-
name: string;
|
|
151
|
-
id?: number;
|
|
152
|
-
typeArguments?: Array<TypedocReflectionTypeParameter>;
|
|
153
|
-
} |
|
|
147
|
+
export type TypedocTypeDetails = string | LiteralOrIntrinsic | Reference | TypeOperator |
|
|
154
148
|
{
|
|
155
149
|
type: 'union';
|
|
156
150
|
types: Array<TypedocReflectionType>;
|
|
@@ -159,23 +153,11 @@ export type TypedocTypeDetails = string |
|
|
|
159
153
|
type: 'array';
|
|
160
154
|
elementType: TypedocTypeDetails;
|
|
161
155
|
} |
|
|
162
|
-
{
|
|
163
|
-
type: 'intrinsic';
|
|
164
|
-
name: string;
|
|
165
|
-
} |
|
|
166
156
|
{
|
|
167
157
|
type: 'indexedAccess';
|
|
168
158
|
objectType: TypedocTypeDetails;
|
|
169
159
|
indexType: TypedocTypeDetails;
|
|
170
160
|
} |
|
|
171
|
-
{
|
|
172
|
-
type: 'literal';
|
|
173
|
-
value: string | number | boolean | null;
|
|
174
|
-
} |
|
|
175
|
-
{
|
|
176
|
-
type: 'intrinsic';
|
|
177
|
-
name: string;
|
|
178
|
-
} |
|
|
179
161
|
{
|
|
180
162
|
type: 'reflection';
|
|
181
163
|
declaration: {
|
|
@@ -192,6 +174,7 @@ export type TypedocTypeDetails = string |
|
|
|
192
174
|
} |
|
|
193
175
|
{
|
|
194
176
|
type: 'intersection';
|
|
177
|
+
types: Array<TypedocReflectionType>;
|
|
195
178
|
} |
|
|
196
179
|
{
|
|
197
180
|
type: 'query';
|
|
@@ -201,16 +184,17 @@ export type TypedocTypeDetails = string |
|
|
|
201
184
|
} |
|
|
202
185
|
{
|
|
203
186
|
type: 'mapped';
|
|
204
|
-
parameter:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
templateType: {
|
|
208
|
-
name: string;
|
|
209
|
-
};
|
|
187
|
+
parameter: string;
|
|
188
|
+
parameterType?: TypeOperator | string;
|
|
189
|
+
templateType: LiteralOrIntrinsic;
|
|
210
190
|
optionalModifier?: string;
|
|
211
191
|
} |
|
|
212
192
|
{
|
|
213
193
|
type: 'conditional';
|
|
194
|
+
checkType: Reference;
|
|
195
|
+
extendsType: TypedocTypeDetails;
|
|
196
|
+
trueType: TypedocTypeDetails;
|
|
197
|
+
falseType: TypedocTypeDetails;
|
|
214
198
|
} |
|
|
215
199
|
{
|
|
216
200
|
type: 'template-literal';
|
|
@@ -220,11 +204,6 @@ export type TypedocTypeDetails = string |
|
|
|
220
204
|
}>;
|
|
221
205
|
head: string;
|
|
222
206
|
} |
|
|
223
|
-
{
|
|
224
|
-
type: 'typeOperator';
|
|
225
|
-
operator: string;
|
|
226
|
-
target: TypedocTypeDetails;
|
|
227
|
-
} |
|
|
228
207
|
{
|
|
229
208
|
type: 'predicate';
|
|
230
209
|
targetType: TypedocTypeDetails;
|
|
@@ -295,3 +274,26 @@ type TypedocSource = {
|
|
|
295
274
|
character: number;
|
|
296
275
|
url: string;
|
|
297
276
|
};
|
|
277
|
+
|
|
278
|
+
type Reference = {
|
|
279
|
+
type: 'reference';
|
|
280
|
+
name: string;
|
|
281
|
+
id?: number;
|
|
282
|
+
typeArguments?: Array<TypedocReflectionTypeParameter>;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
type TypeOperator = {
|
|
286
|
+
type: 'typeOperator';
|
|
287
|
+
operator: string;
|
|
288
|
+
target: Reference;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
type LiteralOrIntrinsic =
|
|
292
|
+
{
|
|
293
|
+
type: 'literal';
|
|
294
|
+
value: string | number | boolean | null;
|
|
295
|
+
} |
|
|
296
|
+
{
|
|
297
|
+
type: 'intrinsic';
|
|
298
|
+
name: string;
|
|
299
|
+
};
|
|
@@ -74,6 +74,11 @@ class TypedocConverter {
|
|
|
74
74
|
|
|
75
75
|
// Then, when all doclets are specified, let's align types.
|
|
76
76
|
for ( const doclet of this._doclets ) {
|
|
77
|
+
// Skip source if the `file` property is not specified.
|
|
78
|
+
if ( !doclet.file ) {
|
|
79
|
+
doclet.skipSource = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
// Post-processing is possible only if a doclet contains its original signature.
|
|
78
83
|
if ( !doclet._signature ) {
|
|
79
84
|
continue;
|
|
@@ -632,19 +637,31 @@ class TypeConverter {
|
|
|
632
637
|
return typeReflection.queryType.name;
|
|
633
638
|
}
|
|
634
639
|
|
|
635
|
-
// A modified object type.
|
|
636
640
|
// See: https://www.typescriptlang.org/docs/handbook/2/mapped-types.html.
|
|
637
641
|
if ( typeReflection.type === 'mapped' ) {
|
|
638
|
-
|
|
642
|
+
const type = [
|
|
639
643
|
'{',
|
|
640
644
|
'[',
|
|
641
645
|
typeReflection.parameter,
|
|
642
|
-
'in'
|
|
643
|
-
|
|
646
|
+
'in'
|
|
647
|
+
];
|
|
648
|
+
|
|
649
|
+
if ( typeReflection.parameterType.type === 'typeOperator' ) {
|
|
650
|
+
type.push(
|
|
651
|
+
typeReflection.parameterType.operator,
|
|
652
|
+
this.convertReference( typeReflection.parameterType.target )
|
|
653
|
+
);
|
|
654
|
+
} else {
|
|
655
|
+
type.push( typeReflection.parameterType.name );
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
type.push(
|
|
644
659
|
']?:', // TODO: Perhaps we should check `typeReflection.optionalModifier`.
|
|
645
660
|
typeReflection.templateType.name,
|
|
646
661
|
'}'
|
|
647
|
-
|
|
662
|
+
);
|
|
663
|
+
|
|
664
|
+
return type.join( ' ' );
|
|
648
665
|
}
|
|
649
666
|
|
|
650
667
|
// A conditional type.
|
|
@@ -173,6 +173,12 @@ $u-rwd-button-size: 24px;
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
&[data-project^='trial'] {
|
|
177
|
+
li.top__menu-project-logo a {
|
|
178
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='67' height='67' version='1.1'%3E%3Cpath d='m29.23 0.34908c-1.0911 0-2.1811 0.27713-3.1622 0.83323l-11.488 6.5108-11.382 6.6941c-1.9443 1.1432-3.1458 3.2231-3.1638 5.4787l-0.10493 13.203 0.10493 13.205c0.018017 2.2555 1.2195 4.3355 3.1638 5.4787l11.382 6.6925 11.488 6.5124c1.9623 1.1122 4.3637 1.1122 6.326 0l11.488-6.5124 11.382-6.6925c1.9443-1.1432 3.1458-3.2231 3.1638-5.4787l0.10494-13.205-0.10494-13.203c-0.01802-2.2555-1.2194-4.3355-3.1638-5.4787l-11.382-6.6941-11.488-6.5108c-0.98114-0.55611-2.0727-0.83323-3.1638-0.83323zm-0.22711 12.909 4.6783 14.4h15.142l-12.249 8.9009 4.6783 14.4-12.25-8.8993-12.251 8.8993 4.6799-14.4-12.25-8.9009h15.141zm-0.17384 7.7826-2.9711 8.8664h-9.6135l7.7779 5.4787-2.9711 8.8649 7.7779-5.4787 7.7779 5.4787-2.9711-8.8649 7.7779-5.4787h-9.6135z' fill='%23efbb23' stroke-width='.80191'/%3E%3C/svg%3E");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
176
182
|
/* Fix proportions of wider logos (ck5 & ck4). */
|
|
177
183
|
&[data-project='letters'],
|
|
178
184
|
&[data-project='cs'],
|
|
@@ -32,6 +32,11 @@ export function setupPrism() {
|
|
|
32
32
|
const classList = element.classList.values();
|
|
33
33
|
const preElement = element.parentElement;
|
|
34
34
|
|
|
35
|
+
// Don't highlight the element if it has no parent.
|
|
36
|
+
if ( !preElement ) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
for ( const className of classList ) {
|
|
36
41
|
preElement.classList.add( `language-${ className }` );
|
|
37
42
|
}
|