umberto 2.3.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umberto",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "CKSource Documentation builder",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -56,10 +56,10 @@
56
56
  "webpack": "^5.74.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@ckeditor/ckeditor5-dev-bump-year": "^32.0.1",
60
- "@ckeditor/ckeditor5-dev-ci": "^32.0.1",
61
- "@ckeditor/ckeditor5-dev-docs": "^32.0.1",
62
- "@ckeditor/ckeditor5-dev-release-tools": "^32.0.1",
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",
63
63
  "browser-sync": "^2.27.10",
64
64
  "chai": "^4.3.6",
65
65
  "chokidar": "^3.5.3",
@@ -177,9 +177,73 @@ module.exports = class DescriptionParser {
177
177
  member = name;
178
178
  }
179
179
 
180
- const targetDoclet = findTargetDoclet( this._dataCollection, { module, structure, member, label, query } );
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
 
@@ -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
  /**