umberto 2.3.0 → 2.3.1

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 CHANGED
@@ -21,7 +21,8 @@ module.exports = {
21
21
  ignorePatterns: [
22
22
  'source/**/*.js',
23
23
  'temp/**/*.js',
24
- 'themes/umberto/source/**/*.js'
24
+ 'themes/umberto/source/**/*.js',
25
+ 'tests/src/data-converter/converters/typedoc/fixtures'
25
26
  ],
26
27
  overrides: [
27
28
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umberto",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "CKSource Documentation builder",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -58,6 +58,7 @@
58
58
  "devDependencies": {
59
59
  "@ckeditor/ckeditor5-dev-bump-year": "^32.0.1",
60
60
  "@ckeditor/ckeditor5-dev-ci": "^32.0.1",
61
+ "@ckeditor/ckeditor5-dev-docs": "^32.0.1",
61
62
  "@ckeditor/ckeditor5-dev-release-tools": "^32.0.1",
62
63
  "browser-sync": "^2.27.10",
63
64
  "chai": "^4.3.6",
@@ -68,7 +69,9 @@
68
69
  "lint-staged": "^13.0.3",
69
70
  "mocha": "^10.0.0",
70
71
  "mockery": "^2.1.0",
71
- "sinon": "^14.0.0"
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>', $.html() );
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
- const trimmedLines = lines.map( line => line.replace( new RegExp( `^${ indentation }` ), '' ) );
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.
@@ -203,9 +203,13 @@ module.exports = class AbstractParser {
203
203
  return null;
204
204
  }
205
205
 
206
- return {
207
- url: item.sources[ sourceIndex ].url
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
  */
@@ -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
- name: string;
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
- return [
642
+ const type = [
639
643
  '{',
640
644
  '[',
641
645
  typeReflection.parameter,
642
- 'in',
643
- typeReflection.parameterType.name,
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
- ].join( ' ' );
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
  }