Skip to content

Commit 370ab05

Browse files
committed
Add feature to add injected items that documenter is not providing
1 parent 64744be commit 370ab05

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Example",
11+
"program": "${workspaceFolder}/lib/start.js",
12+
"cwd": "${workspaceFolder}/../../build-tests/api-documenter-test",
13+
"args": [
14+
"generate",
15+
"--input-folder",
16+
"etc",
17+
"--output-folder",
18+
"etc/yaml"
19+
],
20+
"sourceMaps": true
21+
},
22+
]
23+
}

apps/api-documenter/src/documenters/ExperimentalYamlDocumenter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
6666
? this._findInlineTagByName(this._config.filterByInlineTag, apiItem.tsdocComment)
6767
: undefined;
6868

69-
const tagContent: string | undefined =
69+
const tagContent: string | undefined =
7070
docInlineTag && docInlineTag.tagContent && docInlineTag.tagContent.trim();
7171

7272
if (tagContent && this._tocPointerMap[tagContent]) {
@@ -104,7 +104,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
104104
private _generateTocPointersMap(tocConfig: IYamlTocFile | IYamlTocItem): void {
105105
if (tocConfig.items) {
106106
for (const tocItem of tocConfig.items) {
107-
if (tocItem.items && tocItem.items.length > 0) {
107+
if (tocItem.items && tocItem.items.length > 0 && this._shouldNotIncludeInPointersMap(tocItem)) {
108108
this._generateTocPointersMap(tocItem);
109109
} else {
110110
// check for presence of the `catchAllCategory` config option
@@ -136,4 +136,12 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
136136
}
137137
return undefined;
138138
}
139+
140+
private _shouldNotIncludeInPointersMap(item: IYamlTocItem): boolean {
141+
const { categoryNodes } = this._config;
142+
if (categoryNodes && categoryNodes.length) {
143+
return categoryNodes.indexOf(item.name) === -1;
144+
}
145+
return true;
146+
}
139147
}

apps/api-documenter/src/documenters/IConfigFile.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ export interface IConfigTableOfContents {
2323
*/
2424
catchAllCategory?: string;
2525

26-
/**
27-
* When loading more than one api.json files that might include the same API items,
28-
* toggle either to show duplicates or not.
29-
*/
30-
noDuplicateEntries?: boolean;
31-
3226
/**
3327
* Toggle either sorting of the API items should be made based on category name presence
3428
* in the API item's name.
@@ -40,6 +34,11 @@ export interface IConfigTableOfContents {
4034
* that is present on them.
4135
*/
4236
filterByInlineTag?: string;
37+
38+
/**
39+
* Array of node names to which API items will be pushed when filtered
40+
*/
41+
categoryNodes?: string[];
4342
}
4443

4544
/**

build-tests/api-documenter-test/config/api-documenter.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
{ "name": "DocClass1", "items": [] }
1818
]
1919
},
20-
{ "name": "References", "items": [] }
20+
{
21+
"name": "References",
22+
"items": [
23+
{ "name": "InjectedCustomItem", "uid": "customUrl" }
24+
]
25+
}
2126
]
2227
}
2328
]
2429
},
30+
"categoryNodes": ["References"],
2531
"catchAllCategory": "References",
2632
"noDuplicateEntries": true,
2733
"filterByApiItemName": false,

build-tests/api-documenter-test/etc/yaml/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ items:
2525
uid: api-documenter-test.IDocInterface4
2626
- name: References
2727
items:
28+
- name: InjectedCustomItem
29+
uid: customUrl
2830
- name: DocEnum
2931
uid: api-documenter-test.DocEnum
3032
- name: Generic

0 commit comments

Comments
 (0)