|
1 | 1 | const { ApiItemKind } = require('@microsoft/api-extractor-model');
|
2 | 2 |
|
3 | 3 | /**
|
4 |
| - * This is taken from the docusaurus-plugin-api-extractor codebase as specified in the |
5 |
| - * [standard-markdown-documenter README](https://github.com/gabrielcsapo/docusaurus-plugin-api-extractor/tree/main/plugin/standard-markdown-documenter#custom-sidebar-visitor). |
6 |
| - * @see https://github.com/gabrielcsapo/docusaurus-plugin-api-extractor/tree/main/plugin/standard-markdown-documenter#custom-sidebar-visitor |
7 |
| - * |
8 |
| - * @dkozma: We had to change this code because the API model parsed an `IndexSignature` from `c2pa.manifestresolvers` |
9 |
| - * which gets picked up by the sidebar but a file doesn't get generated. I'm not sure why this is the case or how to |
10 |
| - * fix it, so I put a hack in here to just strip the `._indexer_` suffix since standard-markdown-documenter doesn't |
11 |
| - * seem to let me return an empty node or node that returns a valid `html` or `link` type. |
| 4 | + * @dkozma: We had to change this code because the API model parsed an `IndexSignature` from `c2pa.manifestresolvers` which gets picked up by the sidebar but a file doesn't get generated. |
| 5 | + * HACK: Strip the `._indexer_` suffix since standard-markdown-documenter doesn't seem to let |
| 6 | + * you return an empty node or node that returns a valid `html` or `link` type. |
12 | 7 | */
|
13 | 8 | exports.SIDEBAR_VISITOR = {
|
14 |
| - [ApiItemKind.Package](apiItem, meta) { |
15 |
| - return containerNode(apiItem, meta); |
16 |
| - }, |
17 |
| - [ApiItemKind.Namespace](apiItem, meta) { |
18 |
| - return containerNode(apiItem, meta); |
19 |
| - }, |
20 |
| - [ApiItemKind.Interface](apiItem, meta) { |
21 |
| - return containerNode(apiItem, meta); |
22 |
| - }, |
23 |
| - [ApiItemKind.Class](apiItem, meta) { |
24 |
| - return containerNode(apiItem, meta); |
25 |
| - }, |
26 |
| - [ApiItemKind.CallSignature](apiItem, meta) { |
27 |
| - return terminalNode(apiItem.displayName, meta.id); |
28 |
| - }, |
29 |
| - [ApiItemKind.ConstructSignature](apiItem, meta) { |
30 |
| - return terminalNode(apiItem.displayName, meta.id); |
31 |
| - }, |
32 |
| - [ApiItemKind.Constructor](apiItem, meta) { |
33 |
| - return terminalNode(apiItem.displayName, meta.id); |
34 |
| - }, |
35 |
| - [ApiItemKind.Enum](apiItem, meta) { |
36 |
| - return terminalNode(apiItem.displayName, meta.id); |
37 |
| - }, |
38 |
| - |
39 |
| - [ApiItemKind.EnumMember](apiItem, meta) { |
40 |
| - return terminalNode(apiItem.displayName, meta.id); |
41 |
| - }, |
42 |
| - |
43 |
| - [ApiItemKind.Function](apiItem, meta) { |
44 |
| - return terminalNode(apiItem.displayName, meta.id); |
45 |
| - }, |
46 |
| - |
47 |
| - [ApiItemKind.IndexSignature](apiItem, meta) { |
48 |
| - return terminalNode( |
49 |
| - apiItem.displayName, |
50 |
| - meta.id.replace(/._indexer_$/, ''), |
51 |
| - ); |
52 |
| - }, |
53 |
| - |
54 |
| - [ApiItemKind.Method](apiItem, meta) { |
55 |
| - return terminalNode(apiItem.displayName, meta.id); |
56 |
| - }, |
57 |
| - |
58 |
| - [ApiItemKind.Method](apiItem, meta) { |
59 |
| - return terminalNode(apiItem.displayName, meta.id); |
60 |
| - }, |
61 |
| - |
62 |
| - [ApiItemKind.MethodSignature](apiItem, meta) { |
63 |
| - return terminalNode(apiItem.displayName, meta.id); |
64 |
| - }, |
65 |
| - |
66 |
| - [ApiItemKind.Property](apiItem, meta) { |
67 |
| - return terminalNode(apiItem.displayName, meta.id); |
68 |
| - }, |
69 |
| - |
70 |
| - [ApiItemKind.PropertySignature](apiItem, meta) { |
71 |
| - return terminalNode(apiItem.displayName, meta.id); |
72 |
| - }, |
73 |
| - |
74 |
| - [ApiItemKind.TypeAlias](apiItem, meta) { |
75 |
| - return terminalNode(apiItem.displayName, meta.id); |
76 |
| - }, |
77 |
| - |
78 |
| - [ApiItemKind.Variable](apiItem, meta) { |
79 |
| - return terminalNode(apiItem.displayName, meta.id); |
80 |
| - }, |
81 |
| - |
82 |
| - [ApiItemKind.Model]() { |
83 |
| - return { |
84 |
| - type: 'category', |
85 |
| - label: 'Packages', |
86 |
| - items: [terminalNode('Overview', 'index')], |
87 |
| - collapsed: false, |
88 |
| - }; |
89 |
| - }, |
| 9 | + [ApiItemKind.Package]: containerNode, |
| 10 | + [ApiItemKind.Namespace]: containerNode, |
| 11 | + [ApiItemKind.Interface]: containerNode, |
| 12 | + [ApiItemKind.Class]: containerNode, |
| 13 | + [ApiItemKind.CallSignature]: terminalNode, |
| 14 | + [ApiItemKind.ConstructSignature]: terminalNode, |
| 15 | + [ApiItemKind.Constructor]: terminalNode, |
| 16 | + [ApiItemKind.Enum]: terminalNode, |
| 17 | + [ApiItemKind.EnumMember]: terminalNode, |
| 18 | + [ApiItemKind.Function]: terminalNode, |
| 19 | + [ApiItemKind.IndexSignature]: (apiItem, meta) => |
| 20 | + terminalNode(apiItem.displayName, meta.id.replace(/._indexer_$/, '')), |
| 21 | + [ApiItemKind.Method]: terminalNode, |
| 22 | + [ApiItemKind.MethodSignature]: terminalNode, |
| 23 | + [ApiItemKind.Property]: terminalNode, |
| 24 | + [ApiItemKind.PropertySignature]: terminalNode, |
| 25 | + [ApiItemKind.TypeAlias]: terminalNode, |
| 26 | + [ApiItemKind.Variable]: terminalNode, |
| 27 | + [ApiItemKind.Model]: () => ({ |
| 28 | + type: 'category', |
| 29 | + label: 'Packages', |
| 30 | + items: [terminalNode('Overview', 'index')], |
| 31 | + collapsed: false, |
| 32 | + }), |
90 | 33 | };
|
91 | 34 |
|
92 | 35 | function containerNode(apiItem, meta) {
|
|
0 commit comments