@next-core/build-config-factory 2.20.0 → 2.21.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/CHANGELOG.md +14 -0
- package/package.json +3 -3
- package/src/generateBrickDocs.js +79 -26
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.21.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.20.0...@next-core/build-config-factory@2.21.0) (2022-07-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** support description of enum and interface ([3b81fe1](https://github.com/easyops-cn/next-core/commit/3b81fe1a5ee3d1666083fad50c7da8d62379c98a))
|
|
12
|
+
* **generateBrickDocs:** support get detail of reflection type from declaration ([b62557f](https://github.com/easyops-cn/next-core/commit/b62557f09a362a85ac25151d8940cec4e691700b))
|
|
13
|
+
* **generateBrickDocs:** support get parameters type of method from declaration ([e88bef6](https://github.com/easyops-cn/next-core/commit/e88bef6006140001bd44271911566df497e03ca4))
|
|
14
|
+
* **generateBrickDocs:** support get property type from setter ([5825363](https://github.com/easyops-cn/next-core/commit/5825363195c4359a21b9b80360a58a261e886825))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
# [2.20.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.19.0...@next-core/build-config-factory@2.20.0) (2022-07-05)
|
|
7
21
|
|
|
8
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"description": "build config factory",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/build-config-factory",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@next-core/brick-utils": "^2.37.
|
|
21
|
+
"@next-core/brick-utils": "^2.37.21",
|
|
22
22
|
"@next-core/repo-config": "^0.2.1",
|
|
23
23
|
"@next-core/typedoc-plugin-filter-inherit": "^1.2.2",
|
|
24
24
|
"@next-core/webpack-config-factory": "^2.16.6",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"typedoc": "^0.19.2",
|
|
38
38
|
"typedoc-plugin-no-inherit": "^1.2.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "34a0808712ecaa925d0860d281ab23cf3bec7317"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -100,11 +100,24 @@ function convertTagsToMapByFields(tags, fields) {
|
|
|
100
100
|
}, {});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function getClassChildType(child) {
|
|
104
|
+
let type = child.type;
|
|
105
|
+
|
|
106
|
+
// setter
|
|
107
|
+
if (!type && child.kindString === "Accessor" && child.setSignature) {
|
|
108
|
+
type = child.setSignature[0].parameters[0].type;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return type;
|
|
112
|
+
}
|
|
113
|
+
|
|
103
114
|
function composeBrickDocProperties(brick) {
|
|
104
|
-
const { name, comment,
|
|
115
|
+
const { name, comment, flags, defaultValue } = brick;
|
|
116
|
+
const type = getClassChildType(brick);
|
|
117
|
+
|
|
105
118
|
return {
|
|
106
119
|
name,
|
|
107
|
-
type: extractRealInterfaceType(type
|
|
120
|
+
type: extractRealInterfaceType(type),
|
|
108
121
|
required: flags?.isOptional !== true,
|
|
109
122
|
default: defaultValue,
|
|
110
123
|
...convertTagsToMapByFields(get(comment, "tags", []), propertyDocComments),
|
|
@@ -126,7 +139,7 @@ function getEventTypeByDecorators(decorators) {
|
|
|
126
139
|
function getDetailTypeByEventType(type) {
|
|
127
140
|
if (type.name === "EventEmitter" && type.typeArguments?.length > 0) {
|
|
128
141
|
const argument = type.typeArguments[0];
|
|
129
|
-
return extractRealInterfaceType(argument
|
|
142
|
+
return extractRealInterfaceType(argument);
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
|
|
@@ -148,6 +161,14 @@ function composeBrickDocMethods(brick) {
|
|
|
148
161
|
[];
|
|
149
162
|
return {
|
|
150
163
|
name,
|
|
164
|
+
params: signatures[0].parameters
|
|
165
|
+
?.map(
|
|
166
|
+
(parameter) =>
|
|
167
|
+
`${parameter.name}${
|
|
168
|
+
parameter.flags?.isOptional ? "?" : ""
|
|
169
|
+
}: ${extractRealInterfaceType(parameter.type)}`
|
|
170
|
+
)
|
|
171
|
+
.join(" "),
|
|
151
172
|
...convertTagsToMapByFields(tags, methodComments),
|
|
152
173
|
};
|
|
153
174
|
}
|
|
@@ -293,8 +314,8 @@ function existBrickDocId(element) {
|
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
|
|
296
|
-
function extractRealInterfaceType(
|
|
297
|
-
switch (type) {
|
|
317
|
+
function extractRealInterfaceType(typeData, parentType) {
|
|
318
|
+
switch (typeData?.type) {
|
|
298
319
|
case "reference":
|
|
299
320
|
// eslint-disable-next-line no-case-declarations
|
|
300
321
|
let result = "";
|
|
@@ -304,25 +325,24 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
304
325
|
|
|
305
326
|
if (typeData.typeArguments && typeData.typeArguments.length > 0) {
|
|
306
327
|
result += `<${typeData.typeArguments
|
|
307
|
-
.map((type) => extractRealInterfaceType(type
|
|
328
|
+
.map((type) => extractRealInterfaceType(type))
|
|
308
329
|
.join(", ")}>`;
|
|
309
330
|
}
|
|
310
331
|
|
|
311
332
|
return result;
|
|
312
333
|
case "array":
|
|
313
334
|
return `${extractRealInterfaceType(
|
|
314
|
-
typeData.elementType.type,
|
|
315
335
|
typeData.elementType,
|
|
316
|
-
type
|
|
336
|
+
typeData.type
|
|
317
337
|
)}[]`;
|
|
318
338
|
case "union":
|
|
319
339
|
if (parentType === "array") {
|
|
320
340
|
return `(${typeData.types
|
|
321
|
-
.map((type) => extractRealInterfaceType(type
|
|
341
|
+
.map((type) => extractRealInterfaceType(type))
|
|
322
342
|
.join(" | ")})`;
|
|
323
343
|
}
|
|
324
344
|
return typeData.types
|
|
325
|
-
.map((type) => extractRealInterfaceType(type
|
|
345
|
+
.map((type) => extractRealInterfaceType(type))
|
|
326
346
|
.join(" | ");
|
|
327
347
|
case "stringLiteral":
|
|
328
348
|
return `"${typeData.value}"`;
|
|
@@ -332,10 +352,31 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
332
352
|
return typeData.name;
|
|
333
353
|
case "intersection":
|
|
334
354
|
return typeData.types
|
|
335
|
-
.map((type) => extractRealInterfaceType(type
|
|
355
|
+
.map((type) => extractRealInterfaceType(type))
|
|
336
356
|
.join(" & ");
|
|
337
|
-
case "reflection":
|
|
338
|
-
|
|
357
|
+
case "reflection": {
|
|
358
|
+
if (typeData.declaration) {
|
|
359
|
+
const { children = [], indexSignature = [] } = typeData.declaration;
|
|
360
|
+
|
|
361
|
+
return `{ ${[
|
|
362
|
+
...children.map(
|
|
363
|
+
(child) =>
|
|
364
|
+
`${child.name}${
|
|
365
|
+
child.flags?.isOptional ? "?" : ""
|
|
366
|
+
}: ${extractRealInterfaceType(child.type)};`
|
|
367
|
+
),
|
|
368
|
+
...indexSignature.map((item) => {
|
|
369
|
+
const parameter = item.parameters[0];
|
|
370
|
+
return `[${parameter.name}: ${extractRealInterfaceType(
|
|
371
|
+
parameter.type.type,
|
|
372
|
+
parameter.type
|
|
373
|
+
)}]: ${extractRealInterfaceType(item.type)};`;
|
|
374
|
+
}),
|
|
375
|
+
].join(" ")} }`;
|
|
376
|
+
} else {
|
|
377
|
+
return "object";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
339
380
|
default:
|
|
340
381
|
return "";
|
|
341
382
|
}
|
|
@@ -347,7 +388,7 @@ function extractBrickDocTypes(type) {
|
|
|
347
388
|
typeParameter: getTypeParameter(type),
|
|
348
389
|
kind: "type",
|
|
349
390
|
description: get(type, ["comment", "shortText"], "").trim(),
|
|
350
|
-
type: extractRealInterfaceType(type.type
|
|
391
|
+
type: extractRealInterfaceType(type.type),
|
|
351
392
|
};
|
|
352
393
|
}
|
|
353
394
|
|
|
@@ -356,6 +397,7 @@ function extractBrickDocEnumerations(enumerations) {
|
|
|
356
397
|
name: enumerations.name,
|
|
357
398
|
typeParameter: null,
|
|
358
399
|
kind: "enum",
|
|
400
|
+
description: enumerations?.comment?.shortText?.trim(),
|
|
359
401
|
children: [
|
|
360
402
|
...enumerations.children.map((child) => {
|
|
361
403
|
return {
|
|
@@ -402,11 +444,12 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
402
444
|
typeParameter: getTypeParameter(finder),
|
|
403
445
|
kind: "interface",
|
|
404
446
|
extendedTypes: finder.extendedTypes,
|
|
447
|
+
description: finder?.comment?.shortText?.trim(),
|
|
405
448
|
children:
|
|
406
449
|
finder.children?.map((child) => {
|
|
407
450
|
return {
|
|
408
451
|
name: child.name,
|
|
409
|
-
type: extractRealInterfaceType(child.type
|
|
452
|
+
type: extractRealInterfaceType(child.type),
|
|
410
453
|
required: !get(child, ["flags", "isOptional"], false),
|
|
411
454
|
description: get(child, ["comment", "shortText"], "").trim(),
|
|
412
455
|
};
|
|
@@ -417,12 +460,9 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
417
460
|
name: child.name,
|
|
418
461
|
parameters: child.parameters.map((parameter) => ({
|
|
419
462
|
...parameter,
|
|
420
|
-
type: extractRealInterfaceType(
|
|
421
|
-
parameter.type.type,
|
|
422
|
-
parameter.type
|
|
423
|
-
),
|
|
463
|
+
type: extractRealInterfaceType(parameter.type),
|
|
424
464
|
})),
|
|
425
|
-
type: extractRealInterfaceType(child.type
|
|
465
|
+
type: extractRealInterfaceType(child.type),
|
|
426
466
|
required: !get(child, ["flags", "isOptional"], false),
|
|
427
467
|
description: get(child, ["comment", "shortText"], "").trim(),
|
|
428
468
|
};
|
|
@@ -467,12 +507,25 @@ function traverseElementUsedInterfaceIds(
|
|
|
467
507
|
traversedTypeSet
|
|
468
508
|
) {
|
|
469
509
|
element.children.forEach((child) => {
|
|
470
|
-
|
|
471
|
-
child.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
510
|
+
if (child.kindString === "Method") {
|
|
511
|
+
child.signatures[0].parameters?.map((parameter) =>
|
|
512
|
+
traverseUsedReferenceIdsByType(
|
|
513
|
+
parameter.type,
|
|
514
|
+
usedReferenceIds,
|
|
515
|
+
references,
|
|
516
|
+
traversedTypeSet
|
|
517
|
+
)
|
|
518
|
+
);
|
|
519
|
+
} else {
|
|
520
|
+
const type = getClassChildType(child);
|
|
521
|
+
|
|
522
|
+
traverseUsedReferenceIdsByType(
|
|
523
|
+
type,
|
|
524
|
+
usedReferenceIds,
|
|
525
|
+
references,
|
|
526
|
+
traversedTypeSet
|
|
527
|
+
);
|
|
528
|
+
}
|
|
476
529
|
});
|
|
477
530
|
}
|
|
478
531
|
|