@next-core/build-config-factory 2.22.0 → 2.23.3
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 +46 -0
- package/package.json +3 -3
- package/src/generateBrickDocs.js +64 -29
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
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.23.3](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.23.2...@next-core/build-config-factory@2.23.3) (2022-07-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** filter element childern without supported decorators ([a2f8e50](https://github.com/easyops-cn/next-core/commit/a2f8e50425a6a1c6aec4ed2d6c21858d2d4dbea4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.23.2](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.23.1...@next-core/build-config-factory@2.23.2) (2022-07-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **generateBrickDocs:** support wrapping intersection types ([9dca68d](https://github.com/easyops-cn/next-core/commit/9dca68d14396fec7f250c2ad41ba95464dcc3577))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [2.23.1](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.23.0...@next-core/build-config-factory@2.23.1) (2022-07-12)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @next-core/build-config-factory
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [2.23.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.22.0...@next-core/build-config-factory@2.23.0) (2022-07-12)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **generateBrickDocs:** filter inherited properties ([38daaff](https://github.com/easyops-cn/next-core/commit/38daaffa0dcb5c4ef66cc3d846e525db2ea3ba95))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **generateBrickDocs:** support typle types ([148ad87](https://github.com/easyops-cn/next-core/commit/148ad87935a8deac87c69fd4d60828a2aef7723f))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
6
52
|
# [2.22.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.21.0...@next-core/build-config-factory@2.22.0) (2022-07-11)
|
|
7
53
|
|
|
8
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.3",
|
|
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.22",
|
|
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": "00b8306625746d076f581d99f3132f8fdabfe977"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -11,7 +11,7 @@ const brickKindMap = {
|
|
|
11
11
|
};
|
|
12
12
|
const extraScanPaths = ["src/interfaces"];
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const supportedDecoratorSet = new Set(["property", "event", "method"]);
|
|
15
15
|
const methodComments = ["params", "description", "deprecated"];
|
|
16
16
|
const eventDocComments = ["detail", "description", "deprecated"];
|
|
17
17
|
const propertyDocComments = [
|
|
@@ -225,7 +225,7 @@ function getRealBrickDocCategory(brick) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
const finder = brick.decorators.find((d) =>
|
|
228
|
-
|
|
228
|
+
supportedDecoratorSet.has(d.name)
|
|
229
229
|
);
|
|
230
230
|
|
|
231
231
|
if (finder) {
|
|
@@ -314,6 +314,14 @@ function existBrickDocId(element) {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
function wrapBracketByParentType(typeStr, parentType) {
|
|
318
|
+
return parentType === "array" ||
|
|
319
|
+
parentType === "union" ||
|
|
320
|
+
parentType === "intersection"
|
|
321
|
+
? `(${typeStr})`
|
|
322
|
+
: typeStr;
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
function extractRealInterfaceType(typeData, parentType) {
|
|
318
326
|
switch (typeData?.type) {
|
|
319
327
|
case "reference":
|
|
@@ -335,15 +343,13 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
335
343
|
typeData.elementType,
|
|
336
344
|
typeData.type
|
|
337
345
|
)}[]`;
|
|
338
|
-
case "union":
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
: typeStr;
|
|
346
|
-
}
|
|
346
|
+
case "union":
|
|
347
|
+
return wrapBracketByParentType(
|
|
348
|
+
typeData.types
|
|
349
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
350
|
+
.join(" | "),
|
|
351
|
+
parentType
|
|
352
|
+
);
|
|
347
353
|
case "stringLiteral":
|
|
348
354
|
return `"${typeData.value}"`;
|
|
349
355
|
case "intrinsic":
|
|
@@ -351,9 +357,12 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
351
357
|
case "unknown": // unknown 暂定是`type`中的数字类型,e.g: type t = 0 | 1 | 'string'
|
|
352
358
|
return typeData.name;
|
|
353
359
|
case "intersection":
|
|
354
|
-
return
|
|
355
|
-
.
|
|
356
|
-
|
|
360
|
+
return wrapBracketByParentType(
|
|
361
|
+
typeData.types
|
|
362
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
363
|
+
.join(" & "),
|
|
364
|
+
parentType
|
|
365
|
+
);
|
|
357
366
|
case "reflection": {
|
|
358
367
|
if (typeData.declaration) {
|
|
359
368
|
const {
|
|
@@ -373,30 +382,32 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
373
382
|
)
|
|
374
383
|
.join(", ")}) => ${extractRealInterfaceType(type)}`;
|
|
375
384
|
|
|
376
|
-
return
|
|
377
|
-
? `(${typeStr})`
|
|
378
|
-
: typeStr;
|
|
385
|
+
return wrapBracketByParentType(typeStr, parentType);
|
|
379
386
|
} else {
|
|
380
387
|
return `{ ${[
|
|
381
388
|
...children.map(
|
|
382
389
|
(child) =>
|
|
383
390
|
`${child.name}${
|
|
384
391
|
child.flags?.isOptional ? "?" : ""
|
|
385
|
-
}: ${extractRealInterfaceType(child.type)}
|
|
392
|
+
}: ${extractRealInterfaceType(child.type)}`
|
|
386
393
|
),
|
|
387
394
|
...indexSignature.map((item) => {
|
|
388
395
|
const parameter = item.parameters[0];
|
|
389
396
|
return `[${parameter.name}: ${extractRealInterfaceType(
|
|
390
397
|
parameter.type.type,
|
|
391
398
|
parameter.type
|
|
392
|
-
)}]: ${extractRealInterfaceType(item.type)}
|
|
399
|
+
)}]: ${extractRealInterfaceType(item.type)}`;
|
|
393
400
|
}),
|
|
394
|
-
].join(" ")} }`;
|
|
401
|
+
].join("; ")} }`;
|
|
395
402
|
}
|
|
396
403
|
} else {
|
|
397
404
|
return "object";
|
|
398
405
|
}
|
|
399
406
|
}
|
|
407
|
+
case "tuple":
|
|
408
|
+
return `[${typeData.elements
|
|
409
|
+
?.map((element) => element.name)
|
|
410
|
+
.join(", ")}]`;
|
|
400
411
|
default:
|
|
401
412
|
return "";
|
|
402
413
|
}
|
|
@@ -466,14 +477,20 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
466
477
|
extendedTypes: finder.extendedTypes,
|
|
467
478
|
description: finder?.comment?.shortText?.trim(),
|
|
468
479
|
children:
|
|
469
|
-
finder.children
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
480
|
+
finder.children
|
|
481
|
+
?.filter((child) => !child.inheritedFrom)
|
|
482
|
+
.map((child) => {
|
|
483
|
+
return {
|
|
484
|
+
name: child.name,
|
|
485
|
+
type: extractRealInterfaceType(child.type),
|
|
486
|
+
required: !get(child, ["flags", "isOptional"], false),
|
|
487
|
+
description: get(
|
|
488
|
+
child,
|
|
489
|
+
["comment", "shortText"],
|
|
490
|
+
""
|
|
491
|
+
).trim(),
|
|
492
|
+
};
|
|
493
|
+
}) || [],
|
|
477
494
|
indexSignature:
|
|
478
495
|
finder.indexSignature?.map((child) => {
|
|
479
496
|
return {
|
|
@@ -484,7 +501,6 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
484
501
|
})),
|
|
485
502
|
type: extractRealInterfaceType(child.type),
|
|
486
503
|
required: !get(child, ["flags", "isOptional"], false),
|
|
487
|
-
description: get(child, ["comment", "shortText"], "").trim(),
|
|
488
504
|
};
|
|
489
505
|
}) || [],
|
|
490
506
|
};
|
|
@@ -527,6 +543,14 @@ function traverseElementUsedInterfaceIds(
|
|
|
527
543
|
traversedTypeSet
|
|
528
544
|
) {
|
|
529
545
|
element.children.forEach((child) => {
|
|
546
|
+
if (
|
|
547
|
+
!child.decorators?.some((decorator) =>
|
|
548
|
+
supportedDecoratorSet.has(decorator.name)
|
|
549
|
+
)
|
|
550
|
+
) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
530
554
|
if (child.kindString === "Method") {
|
|
531
555
|
child.signatures[0].parameters?.map((parameter) =>
|
|
532
556
|
traverseUsedReferenceIdsByType(
|
|
@@ -691,6 +715,17 @@ function traverseUsedReferenceIdsByType(
|
|
|
691
715
|
);
|
|
692
716
|
});
|
|
693
717
|
}
|
|
718
|
+
break;
|
|
719
|
+
case "tuple":
|
|
720
|
+
type.elements?.forEach((element) =>
|
|
721
|
+
traverseUsedReferenceIdsByType(
|
|
722
|
+
element,
|
|
723
|
+
usedReferenceIds,
|
|
724
|
+
references,
|
|
725
|
+
traversedTypeSet
|
|
726
|
+
)
|
|
727
|
+
);
|
|
728
|
+
break;
|
|
694
729
|
}
|
|
695
730
|
}
|
|
696
731
|
|