fix(docs-infra): change the key used to find out the cli section (#28293)

PR Close #28293
This commit is contained in:
WilliamKoza
2019-01-22 13:52:04 +01:00
committed by Jason Aden
parent 02975e9166
commit e2c98fbe11
2 changed files with 76 additions and 34 deletions

View File

@ -1,10 +1,14 @@
module.exports = function processCliCommands() {
module.exports = function processCliCommands(createDocMessage) {
return {
$runAfter: ['extra-docs-added'],
$runBefore: ['rendering-docs'],
$process(docs) {
const navigationDoc = docs.find(doc => doc.docType === 'navigation-json');
const navigationNode = navigationDoc && navigationDoc.data['SideNav'].find(node => node.title === 'CLI Commands');
const navigationNode = navigationDoc && navigationDoc.data['SideNav'].find(node => node.children && node.children.length && node.children[0].url === 'cli');
if (!navigationNode) {
throw new Error(createDocMessage('Missing `cli` url - CLI Commands must include a first child node with url set at `cli`', navigationDoc));
}
docs.forEach(doc => {
if (doc.docType === 'cli-command') {
@ -14,9 +18,7 @@ module.exports = function processCliCommands() {
processOptions(doc, doc.options);
// Add to navigation doc
if (navigationNode) {
navigationNode.children.push({ url: doc.path, title: `ng ${doc.name}` });
}
navigationNode.children.push({ url: doc.path, title: `ng ${doc.name}` });
}
});
}