@next-core/build-config-factory 2.21.0 → 2.22.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 +11 -0
- package/package.json +2 -2
- package/src/generateBrickDocs.js +83 -26
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** support function type ([b085bbf](https://github.com/easyops-cn/next-core/commit/b085bbf089b89dc6e7fa7f743a69731b24ea449a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [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
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.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",
|
|
@@ -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": "42bab4e94fbac369b5e9953272d568ba5cfb15e8"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -168,7 +168,7 @@ function composeBrickDocMethods(brick) {
|
|
|
168
168
|
parameter.flags?.isOptional ? "?" : ""
|
|
169
169
|
}: ${extractRealInterfaceType(parameter.type)}`
|
|
170
170
|
)
|
|
171
|
-
.join(" "),
|
|
171
|
+
.join(", "),
|
|
172
172
|
...convertTagsToMapByFields(tags, methodComments),
|
|
173
173
|
};
|
|
174
174
|
}
|
|
@@ -335,15 +335,15 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
335
335
|
typeData.elementType,
|
|
336
336
|
typeData.type
|
|
337
337
|
)}[]`;
|
|
338
|
-
case "union":
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
.map((type) => extractRealInterfaceType(type))
|
|
342
|
-
.join(" | ")})`;
|
|
343
|
-
}
|
|
344
|
-
return typeData.types
|
|
345
|
-
.map((type) => extractRealInterfaceType(type))
|
|
338
|
+
case "union": {
|
|
339
|
+
const typeStr = typeData.types
|
|
340
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
346
341
|
.join(" | ");
|
|
342
|
+
|
|
343
|
+
return parentType === "array" || parentType === "union"
|
|
344
|
+
? `(${typeStr})`
|
|
345
|
+
: typeStr;
|
|
346
|
+
}
|
|
347
347
|
case "stringLiteral":
|
|
348
348
|
return `"${typeData.value}"`;
|
|
349
349
|
case "intrinsic":
|
|
@@ -356,23 +356,43 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
356
356
|
.join(" & ");
|
|
357
357
|
case "reflection": {
|
|
358
358
|
if (typeData.declaration) {
|
|
359
|
-
const {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
)
|
|
374
|
-
|
|
375
|
-
|
|
359
|
+
const {
|
|
360
|
+
signatures,
|
|
361
|
+
children = [],
|
|
362
|
+
indexSignature = [],
|
|
363
|
+
} = typeData.declaration;
|
|
364
|
+
|
|
365
|
+
if (signatures) {
|
|
366
|
+
const { parameters, type } = signatures[0];
|
|
367
|
+
const typeStr = `(${parameters
|
|
368
|
+
?.map(
|
|
369
|
+
(parameter) =>
|
|
370
|
+
`${parameter.name}${
|
|
371
|
+
parameter.flags?.isOptional ? "?" : ""
|
|
372
|
+
}: ${extractRealInterfaceType(parameter.type)}`
|
|
373
|
+
)
|
|
374
|
+
.join(", ")}) => ${extractRealInterfaceType(type)}`;
|
|
375
|
+
|
|
376
|
+
return parentType === "array" || parentType === "union"
|
|
377
|
+
? `(${typeStr})`
|
|
378
|
+
: typeStr;
|
|
379
|
+
} else {
|
|
380
|
+
return `{ ${[
|
|
381
|
+
...children.map(
|
|
382
|
+
(child) =>
|
|
383
|
+
`${child.name}${
|
|
384
|
+
child.flags?.isOptional ? "?" : ""
|
|
385
|
+
}: ${extractRealInterfaceType(child.type)};`
|
|
386
|
+
),
|
|
387
|
+
...indexSignature.map((item) => {
|
|
388
|
+
const parameter = item.parameters[0];
|
|
389
|
+
return `[${parameter.name}: ${extractRealInterfaceType(
|
|
390
|
+
parameter.type.type,
|
|
391
|
+
parameter.type
|
|
392
|
+
)}]: ${extractRealInterfaceType(item.type)};`;
|
|
393
|
+
}),
|
|
394
|
+
].join(" ")} }`;
|
|
395
|
+
}
|
|
376
396
|
} else {
|
|
377
397
|
return "object";
|
|
378
398
|
}
|
|
@@ -634,6 +654,43 @@ function traverseUsedReferenceIdsByType(
|
|
|
634
654
|
traversedTypeSet
|
|
635
655
|
);
|
|
636
656
|
break;
|
|
657
|
+
case "reflection":
|
|
658
|
+
if (type.declaration) {
|
|
659
|
+
const { signatures, children, indexSignature } = type.declaration;
|
|
660
|
+
|
|
661
|
+
signatures?.forEach((signature) => {
|
|
662
|
+
signature.parameters?.forEach((parameter) =>
|
|
663
|
+
traverseUsedReferenceIdsByType(
|
|
664
|
+
parameter.type,
|
|
665
|
+
usedReferenceIds,
|
|
666
|
+
references,
|
|
667
|
+
traversedTypeSet
|
|
668
|
+
)
|
|
669
|
+
);
|
|
670
|
+
traverseUsedReferenceIdsByType(
|
|
671
|
+
signature.type,
|
|
672
|
+
usedReferenceIds,
|
|
673
|
+
references,
|
|
674
|
+
traversedTypeSet
|
|
675
|
+
);
|
|
676
|
+
});
|
|
677
|
+
children?.forEach((child) => {
|
|
678
|
+
traverseUsedReferenceIdsByType(
|
|
679
|
+
child.type,
|
|
680
|
+
usedReferenceIds,
|
|
681
|
+
references,
|
|
682
|
+
traversedTypeSet
|
|
683
|
+
);
|
|
684
|
+
});
|
|
685
|
+
indexSignature?.forEach((item) => {
|
|
686
|
+
traverseUsedReferenceIdsByType(
|
|
687
|
+
item.type,
|
|
688
|
+
usedReferenceIds,
|
|
689
|
+
references,
|
|
690
|
+
traversedTypeSet
|
|
691
|
+
);
|
|
692
|
+
});
|
|
693
|
+
}
|
|
637
694
|
}
|
|
638
695
|
}
|
|
639
696
|
|