style(docs-infra): format files (#35801)

PR Close #35801
This commit is contained in:
Pete Bacon Darwin 2020-03-02 17:47:06 +00:00 committed by atscott
parent c296bfcaf9
commit c1b5daf5a8
2 changed files with 94 additions and 104 deletions

View File

@ -4,10 +4,14 @@ module.exports = function processCliCommands(createDocMessage) {
$runBefore: ['rendering-docs'],
$process(docs) {
const navigationDoc = docs.find(doc => doc.docType === 'navigation-json');
const navigationNode = navigationDoc && navigationDoc.data['SideNav'].find(node => node.children && node.children.length && node.children[0].url === 'cli');
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));
throw new Error(createDocMessage(
'Missing `cli` url - CLI Commands must include a first child node with url set at `cli`',
navigationDoc));
}
docs.forEach(doc => {
@ -31,7 +35,9 @@ function processOptions(container, options) {
options.forEach(option => {
// Ignore any hidden options
if (option.hidden) { return; }
if (option.hidden) {
return;
}
option.types = option.types || [option.type];
option.names = collectNames(option.name, option.aliases);

View File

@ -7,11 +7,7 @@ describe('processCliCommands processor', () => {
const navigationStub = {
docType: 'navigation-json',
data: {
SideNav: [{
children: [{'url': 'cli'}]
}]
}
data: {SideNav: [{children: [{'url': 'cli'}]}]}
};
beforeEach(() => {
@ -21,17 +17,13 @@ describe('processCliCommands processor', () => {
createDocMessage = injector.get('createDocMessage');
});
it('should be available on the injector', () => {
expect(processor.$process).toBeDefined();
});
it('should be available on the injector', () => { expect(processor.$process).toBeDefined(); });
it('should run after the correct processor', () => {
expect(processor.$runAfter).toEqual(['extra-docs-added']);
});
it('should run after the correct processor',
() => { expect(processor.$runAfter).toEqual(['extra-docs-added']); });
it('should run before the correct processor', () => {
expect(processor.$runBefore).toEqual(['rendering-docs']);
});
it('should run before the correct processor',
() => { expect(processor.$runBefore).toEqual(['rendering-docs']); });
it('should collect the names (name + aliases)', () => {
const doc = {
@ -237,7 +229,8 @@ describe('processCliCommands processor', () => {
});
});
it('should add the command to the CLI node in the navigation doc if there is a first child node with a `cli` url', () => {
it('should add the command to the CLI node in the navigation doc if there is a first child node with a `cli` url',
() => {
const command = {
docType: 'cli-command',
name: 'command1',
@ -249,16 +242,10 @@ describe('processCliCommands processor', () => {
docType: 'navigation-json',
data: {
SideNav: [
{ url: 'some/page', title: 'Some Page' },
{
{url: 'some/page', title: 'Some Page'}, {
title: 'CLI Commands',
tooltip: 'Angular CLI command reference',
children: [
{
'title': 'Overview',
'url': 'cli'
}
]
children: [{'title': 'Overview', 'url': 'cli'}]
},
{url: 'other/page', title: 'Other Page'}
]
@ -284,21 +271,18 @@ describe('processCliCommands processor', () => {
docType: 'navigation-json',
data: {
SideNav: [
{ url: 'some/page', title: 'Some Page' },
{
{url: 'some/page', title: 'Some Page'}, {
title: 'CLI Commands',
tooltip: 'Angular CLI command reference',
children: [
{
'title': 'Overview',
'url': 'client'
}
]
children: [{'title': 'Overview', 'url': 'client'}]
},
{url: 'other/page', title: 'Other Page'}
]
}
};
expect(() => processor.$process([command, navigation])).toThrowError(createDocMessage('Missing `cli` url - CLI Commands must include a first child node with url set at `cli`', navigation));
expect(() => processor.$process([command, navigation]))
.toThrowError(createDocMessage(
'Missing `cli` url - CLI Commands must include a first child node with url set at `cli`',
navigation));
});
});