build(docs-infra): do not require abstract directives to declare a @ngModule (#36921)

Abstract directives cannot be part of a `@NgModule`, but the AIO dgeni
setup currently enforces this. This commit updates the logic so that
abstract directives are skipped.

PR Close #36921
This commit is contained in:
Paul Gschwendtner
2020-05-05 17:59:51 +02:00
committed by Alex Rickabaugh
parent e17fe90aaa
commit 854bd7d0c8
3 changed files with 35 additions and 7 deletions
@@ -3,11 +3,20 @@ module.exports = function processNgModuleDocs(getDocFromAlias, createDocMessage,
$runAfter: ['extractDecoratedClassesProcessor', 'computeIdsProcessor'],
$runBefore: ['createSitemap'],
exportDocTypes: ['directive', 'pipe'],
skipAbstractDirectives: true,
$process(docs) {
// Match all the directives/pipes to their module
const errors = [];
docs.forEach(doc => {
if (this.exportDocTypes.indexOf(doc.docType) !== -1) {
const options = doc[`${doc.docType}Options`];
// Directives without a selector are considered abstract and do
// not need to be part of any `@NgModule`.
if (this.skipAbstractDirectives && doc.docType === 'directive' && !options.selector) {
return;
}
if (!doc.ngModules || doc.ngModules.length === 0) {
errors.push(createDocMessage(`"${doc.id}" has no @ngModule tag. Docs of type "${doc.docType}" must have this tag.`, doc));
return;