Skip to content

Commit 53e8126

Browse files
committed
docs: add usage desc of api-extractor
1 parent edd2550 commit 53e8126

12 files changed

+362
-27
lines changed

docs/gen-api-docs.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Generate API docs by powerful ts-doc
2+
3+
**require follows-as directory structure by api-documenter**
4+
5+
```text
6+
./docs
7+
├── input # move the `<project-name>.api.json` from temp dir to input dir
8+
└── markdown # generate api markdown file by `api-documenter markdown`
9+
└── temp # generate by `api-extractor run --local --verbose`
10+
|-- api-extractor.json # generate by `api-extractor init`
11+
```
12+
13+
## Install globally api-extractor api-documenter
14+
15+
```bash
16+
npm install -g @microsoft/api-extractor @microsoft/api-documenter
17+
```
18+
19+
## Generate markdown steps
20+
21+
1. Init api-extractor
22+
23+
enter root directory of project
24+
25+
```bash
26+
api-extractor init
27+
```
28+
29+
after exec completely, will generate `api-extractor.json` file
30+
31+
2. generate API JSON file for api markdown
32+
33+
```bash
34+
api-extractor run --local --verbose
35+
```
36+
37+
3. Enter into docs directory
38+
39+
```bash
40+
api-documenter markdown
41+
```
42+
43+
after exec completely, will generate all api markdown file in markdown directory
44+
45+
## Reference documents
46+
47+
1. [API Extractor](https://api-extractor.com/pages/setup/invoking/)
48+
2. [Generating API docs](https://api-extractor.com/pages/setup/generating_docs/)

docs/input/sculp-js.api.json

Lines changed: 191 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,8 +1315,17 @@
13151315
},
13161316
{
13171317
"kind": "Reference",
1318-
"text": "Object",
1319-
"canonicalReference": "!Object:interface"
1318+
"text": "AnyObject",
1319+
"canonicalReference": "sculp-js!AnyObject:type"
1320+
},
1321+
{
1322+
"kind": "Content",
1323+
"text": " | "
1324+
},
1325+
{
1326+
"kind": "Reference",
1327+
"text": "AnyArray",
1328+
"canonicalReference": "sculp-js!AnyArray:type"
13201329
},
13211330
{
13221331
"kind": "Content",
@@ -1326,7 +1335,7 @@
13261335
"fileUrlPath": "lib/index.d.ts",
13271336
"returnTypeTokenRange": {
13281337
"startIndex": 6,
1329-
"endIndex": 7
1338+
"endIndex": 9
13301339
},
13311340
"releaseTag": "Public",
13321341
"overloadIndex": 1,
@@ -2257,7 +2266,7 @@
22572266
{
22582267
"kind": "Function",
22592268
"canonicalReference": "sculp-js!forEachDeep:function(1)",
2260-
"docComment": "/**\n * 自定义深度优先遍历函数(支持continue和break操作)\n *\n * @param tree - 树形数据\n *\n * @param iterator - 迭代函数, 返回值为true时continue, 返回值为false时break\n *\n * @param children - 定制子元素的key\n *\n * @param isReverse - 是否反向遍历\n *\n * @returns {*}\n */\n",
2269+
"docComment": "/**\n * 自定义深度优先遍历函数(支持continue和break操作), 可用于insert tree item 和 remove tree item\n *\n * @param tree - 树形数据\n *\n * @param iterator - 迭代函数, 返回值为true时continue, 返回值为false时break\n *\n * @param children - 定制子元素的key\n *\n * @param isReverse - 是否反向遍历\n *\n * @returns {*}\n */\n",
22612270
"excerptTokens": [
22622271
{
22632272
"kind": "Content",
@@ -2278,7 +2287,16 @@
22782287
},
22792288
{
22802289
"kind": "Content",
2281-
"text": "(val: V, i: number, arr: "
2290+
"text": "(val: V, i: number, currentArr: "
2291+
},
2292+
{
2293+
"kind": "Reference",
2294+
"text": "ArrayLike",
2295+
"canonicalReference": "!ArrayLike:interface"
2296+
},
2297+
{
2298+
"kind": "Content",
2299+
"text": "<V>, tree: "
22822300
},
22832301
{
22842302
"kind": "Reference",
@@ -2320,8 +2338,8 @@
23202338
],
23212339
"fileUrlPath": "lib/index.d.ts",
23222340
"returnTypeTokenRange": {
2323-
"startIndex": 12,
2324-
"endIndex": 13
2341+
"startIndex": 14,
2342+
"endIndex": 15
23252343
},
23262344
"releaseTag": "Public",
23272345
"overloadIndex": 1,
@@ -2338,23 +2356,23 @@
23382356
"parameterName": "iterator",
23392357
"parameterTypeTokenRange": {
23402358
"startIndex": 4,
2341-
"endIndex": 7
2359+
"endIndex": 9
23422360
},
23432361
"isOptional": false
23442362
},
23452363
{
23462364
"parameterName": "children",
23472365
"parameterTypeTokenRange": {
2348-
"startIndex": 8,
2349-
"endIndex": 9
2366+
"startIndex": 10,
2367+
"endIndex": 11
23502368
},
23512369
"isOptional": true
23522370
},
23532371
{
23542372
"parameterName": "isReverse",
23552373
"parameterTypeTokenRange": {
2356-
"startIndex": 10,
2357-
"endIndex": 11
2374+
"startIndex": 12,
2375+
"endIndex": 13
23582376
},
23592377
"isOptional": true
23602378
}
@@ -2497,6 +2515,68 @@
24972515
],
24982516
"name": "formatNumber"
24992517
},
2518+
{
2519+
"kind": "Function",
2520+
"canonicalReference": "sculp-js!formatTree:function(1)",
2521+
"docComment": "/**\n * 扁平化数组转换成树(效率高于buildTree)\n *\n * @param list - \n *\n * @param options - \n *\n * @returns {any[]}\n */\n",
2522+
"excerptTokens": [
2523+
{
2524+
"kind": "Content",
2525+
"text": "declare function formatTree(list: "
2526+
},
2527+
{
2528+
"kind": "Content",
2529+
"text": "any[]"
2530+
},
2531+
{
2532+
"kind": "Content",
2533+
"text": ", options?: "
2534+
},
2535+
{
2536+
"kind": "Reference",
2537+
"text": "IFieldOptions",
2538+
"canonicalReference": "sculp-js!IFieldOptions:interface"
2539+
},
2540+
{
2541+
"kind": "Content",
2542+
"text": "): "
2543+
},
2544+
{
2545+
"kind": "Content",
2546+
"text": "any[]"
2547+
},
2548+
{
2549+
"kind": "Content",
2550+
"text": ";"
2551+
}
2552+
],
2553+
"fileUrlPath": "lib/index.d.ts",
2554+
"returnTypeTokenRange": {
2555+
"startIndex": 5,
2556+
"endIndex": 6
2557+
},
2558+
"releaseTag": "Public",
2559+
"overloadIndex": 1,
2560+
"parameters": [
2561+
{
2562+
"parameterName": "list",
2563+
"parameterTypeTokenRange": {
2564+
"startIndex": 1,
2565+
"endIndex": 2
2566+
},
2567+
"isOptional": false
2568+
},
2569+
{
2570+
"parameterName": "options",
2571+
"parameterTypeTokenRange": {
2572+
"startIndex": 3,
2573+
"endIndex": 4
2574+
},
2575+
"isOptional": true
2576+
}
2577+
],
2578+
"name": "formatTree"
2579+
},
25002580
{
25012581
"kind": "Function",
25022582
"canonicalReference": "sculp-js!genCanvasWM:function(1)",
@@ -3220,6 +3300,105 @@
32203300
"endIndex": 2
32213301
}
32223302
},
3303+
{
3304+
"kind": "Interface",
3305+
"canonicalReference": "sculp-js!IFieldOptions:interface",
3306+
"docComment": "",
3307+
"excerptTokens": [
3308+
{
3309+
"kind": "Content",
3310+
"text": "interface IFieldOptions "
3311+
}
3312+
],
3313+
"fileUrlPath": "lib/index.d.ts",
3314+
"releaseTag": "Public",
3315+
"name": "IFieldOptions",
3316+
"preserveMemberOrder": false,
3317+
"members": [
3318+
{
3319+
"kind": "PropertySignature",
3320+
"canonicalReference": "sculp-js!IFieldOptions#childField:member",
3321+
"docComment": "",
3322+
"excerptTokens": [
3323+
{
3324+
"kind": "Content",
3325+
"text": "childField: "
3326+
},
3327+
{
3328+
"kind": "Content",
3329+
"text": "string"
3330+
},
3331+
{
3332+
"kind": "Content",
3333+
"text": ";"
3334+
}
3335+
],
3336+
"isReadonly": false,
3337+
"isOptional": false,
3338+
"releaseTag": "Public",
3339+
"name": "childField",
3340+
"propertyTypeTokenRange": {
3341+
"startIndex": 1,
3342+
"endIndex": 2
3343+
}
3344+
},
3345+
{
3346+
"kind": "PropertySignature",
3347+
"canonicalReference": "sculp-js!IFieldOptions#keyField:member",
3348+
"docComment": "",
3349+
"excerptTokens": [
3350+
{
3351+
"kind": "Content",
3352+
"text": "keyField: "
3353+
},
3354+
{
3355+
"kind": "Content",
3356+
"text": "string"
3357+
},
3358+
{
3359+
"kind": "Content",
3360+
"text": ";"
3361+
}
3362+
],
3363+
"isReadonly": false,
3364+
"isOptional": false,
3365+
"releaseTag": "Public",
3366+
"name": "keyField",
3367+
"propertyTypeTokenRange": {
3368+
"startIndex": 1,
3369+
"endIndex": 2
3370+
}
3371+
},
3372+
{
3373+
"kind": "PropertySignature",
3374+
"canonicalReference": "sculp-js!IFieldOptions#pidField:member",
3375+
"docComment": "",
3376+
"excerptTokens": [
3377+
{
3378+
"kind": "Content",
3379+
"text": "pidField: "
3380+
},
3381+
{
3382+
"kind": "Content",
3383+
"text": "string"
3384+
},
3385+
{
3386+
"kind": "Content",
3387+
"text": ";"
3388+
}
3389+
],
3390+
"isReadonly": false,
3391+
"isOptional": false,
3392+
"releaseTag": "Public",
3393+
"name": "pidField",
3394+
"propertyTypeTokenRange": {
3395+
"startIndex": 1,
3396+
"endIndex": 2
3397+
}
3398+
}
3399+
],
3400+
"extendsTokenRanges": []
3401+
},
32233402
{
32243403
"kind": "Variable",
32253404
"canonicalReference": "sculp-js!isArray:var",

docs/markdown/sculp-js.clonedeep.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
**Signature:**
1010

1111
```typescript
12-
declare function cloneDeep(obj: Object, map?: WeakMap<object, any>): Object;
12+
declare function cloneDeep(obj: Object, map?: WeakMap<object, any>): AnyObject | AnyArray;
1313
```
1414

1515
## Parameters
@@ -21,6 +21,6 @@ declare function cloneDeep(obj: Object, map?: WeakMap<object, any>): Object;
2121

2222
**Returns:**
2323

24-
Object
24+
[AnyObject](./sculp-js.anyobject.md) \| [AnyArray](./sculp-js.anyarray.md)
2525

2626
{<!-- -->AnyObject \| AnyArray<!-- -->}

docs/markdown/sculp-js.foreachdeep.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@
44

55
## forEachDeep() function
66

7-
自定义深度优先遍历函数(支持continue和break操作)
7+
自定义深度优先遍历函数(支持continue和break操作), 可用于insert tree item 和 remove tree item
88

99
**Signature:**
1010

1111
```typescript
1212
declare function forEachDeep<V>(
1313
tree: ArrayLike<V>,
14-
iterator: (val: V, i: number, arr: ArrayLike<V>, parent: V | null, level: number) => boolean | void,
14+
iterator: (
15+
val: V,
16+
i: number,
17+
currentArr: ArrayLike<V>,
18+
tree: ArrayLike<V>,
19+
parent: V | null,
20+
level: number
21+
) => boolean | void,
1522
children?: string,
1623
isReverse?: boolean
1724
): void;
1825
```
1926

2027
## Parameters
2128

22-
| Parameter | Type | Description |
23-
| --------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
24-
| tree | ArrayLike&lt;V&gt; | 树形数据 |
25-
| iterator | (val: V, i: number, arr: ArrayLike&lt;V&gt;, parent: V \| null, level: number) =&gt; boolean \| void | 迭代函数, 返回值为true时continue, 返回值为false时break |
26-
| children | string | _(Optional)_ 定制子元素的key |
27-
| isReverse | boolean | _(Optional)_ 是否反向遍历 |
29+
| Parameter | Type | Description |
30+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
31+
| tree | ArrayLike&lt;V&gt; | 树形数据 |
32+
| iterator | (val: V, i: number, currentArr: ArrayLike&lt;V&gt;, tree: ArrayLike&lt;V&gt;, parent: V \| null, level: number) =&gt; boolean \| void | 迭代函数, 返回值为true时continue, 返回值为false时break |
33+
| children | string | _(Optional)_ 定制子元素的key |
34+
| isReverse | boolean | _(Optional)_ 是否反向遍历 |
2835

2936
**Returns:**
3037

0 commit comments

Comments
 (0)