build(docs-infra): separate NgModules from Classes in API docs (#25734)
PR Close #25734
This commit is contained in:

committed by
Kara Erickson

parent
34b848ad51
commit
bc5cb8153e
@ -34,6 +34,8 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
.processor(require('./processors/computeStability'))
|
||||
.processor(require('./processors/removeInjectableConstructors'))
|
||||
.processor(require('./processors/processPackages'))
|
||||
.processor(require('./processors/processNgModuleDocs'))
|
||||
|
||||
|
||||
/**
|
||||
* These are the API doc types that will be rendered to actual files.
|
||||
@ -41,7 +43,7 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
* more Angular specific API types, such as decorators and directives.
|
||||
*/
|
||||
.factory(function API_DOC_TYPES_TO_RENDER(EXPORT_DOC_TYPES) {
|
||||
return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe', 'package']);
|
||||
return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe', 'package']);
|
||||
})
|
||||
|
||||
/**
|
||||
@ -198,7 +200,7 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
outputPathTemplate: '${moduleFolder}.json'
|
||||
});
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe']),
|
||||
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe']),
|
||||
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
||||
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
|
||||
});
|
||||
|
@ -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;
|
||||
|
||||
|
18
aio/tools/transforms/angular-api-package/processors/processNgModuleDocs.js
vendored
Normal file
18
aio/tools/transforms/angular-api-package/processors/processNgModuleDocs.js
vendored
Normal 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];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
@ -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']);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user