build(docs-infra): separate NgModules from Classes in API docs (#25734)

PR Close #25734
This commit is contained in:
Pete Bacon Darwin
2018-08-29 17:23:08 +01:00
committed by Kara Erickson
parent 34b848ad51
commit bc5cb8153e
8 changed files with 132 additions and 29 deletions

View File

@ -8,7 +8,7 @@ module.exports = function extractDecoratedClassesProcessor(EXPORT_DOC_TYPES) {
return {
$runAfter: ['processing-docs'],
$runBefore: ['docs-processed'],
decoratorTypes: ['Directive', 'Component', 'Pipe'],
decoratorTypes: ['Directive', 'Component', 'Pipe', 'NgModule'],
$process: function(docs) {
var decoratorTypes = this.decoratorTypes;

View File

@ -0,0 +1,18 @@
module.exports = function processNgModuleDocs() {
return {
$runAfter: ['extractDecoratedClassesProcessor'],
$runBefore: ['docs-processed'],
$process(docs) {
docs.forEach(doc => {
if (doc.docType === 'ngmodule') {
Object.keys(doc.ngmoduleOptions).forEach(key => {
const value = doc.ngmoduleOptions[key];
if (value && !Array.isArray(value)) {
doc.ngmoduleOptions[key] = [value];
}
});
}
});
}
};
};

View File

@ -0,0 +1,24 @@
const testPackage = require('../../helpers/test-package');
const Dgeni = require('dgeni');
describe('processNgModuleDocs processor', () => {
let processor;
beforeEach(() => {
const dgeni = new Dgeni([testPackage('angular-api-package')]);
const injector = dgeni.configureInjector();
processor = injector.get('processNgModuleDocs');
});
it('should be available on the injector', () => {
expect(processor.$process).toBeDefined();
});
it('should run before the correct processor', () => {
expect(processor.$runBefore).toEqual(['docs-processed']);
});
it('should run after the correct processor', () => {
expect(processor.$runAfter).toEqual(['extractDecoratedClassesProcessor']);
});
});