Skip to content

Commit e55ade0

Browse files
committed
Separate external packages into their own TOC section
1 parent fb5f074 commit e55ade0

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎libraries/api-documenter/src/DocItemSet.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ export class DocItem {
128128
}
129129
return undefined;
130130
}
131+
132+
/**
133+
* Returns true if this is a package, and it has been classified as "external",
134+
* i.e. a system library that is maintained by an external party, but included in the
135+
* documentation for informational purposes.
136+
*/
137+
public get isExternalPackage(): boolean {
138+
// We should define a better criteria for this
139+
return this.apiItem.kind === 'package' && this.apiItem.name.substr(0, 1) === '@';
140+
}
131141
}
132142

133143
/**

‎libraries/api-documenter/src/yaml/IYamlTocFile.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
export interface IYamlTocItem {
88
name: string;
9-
href: string;
9+
href?: string;
1010
items?: IYamlTocItem[];
1111
}
1212

‎libraries/api-documenter/src/yaml/YamlGenerator.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,26 @@ export class YamlGenerator {
110110
*/
111111
private _writeTocFile(docItems: DocItem[]): void {
112112
const tocFile: IYamlTocFile = {
113-
items: this._buildTocItems(docItems)
113+
items: [ ]
114114
};
115+
116+
tocFile.items.push({
117+
name: 'SharePoint Framework', // TODO: parameterize this
118+
items: this._buildTocItems(docItems.filter(x => x.isExternalPackage))
119+
});
120+
121+
const externalPackages: DocItem[] = docItems.filter(x => !x.isExternalPackage);
122+
if (externalPackages.length) {
123+
tocFile.items.push({
124+
name: '─────────────'
125+
});
126+
tocFile.items.push({
127+
name: 'External Packages',
128+
items: this._buildTocItems(externalPackages)
129+
});
130+
}
131+
132+
this._buildTocItems(docItems);
115133
const tocFilePath: string = path.join(this._outputFolder, 'toc.yml');
116134
console.log('Writing ' + tocFilePath);
117135
this._writeYamlFile(tocFile, tocFilePath, '', undefined);
@@ -126,7 +144,7 @@ export class YamlGenerator {
126144
}
127145

128146
const tocItem: IYamlTocItem = {
129-
name: docItem.name,
147+
name: RenderingHelpers.getUnscopedPackageName(docItem.name),
130148
href: this._getRelativeUrlForDocItem(docItem, this._outputFolder)
131149
};
132150

0 commit comments

Comments
 (0)