build(aio): rearrange processors to ensure we catch all content errors (#24000)

PR Close #24000
This commit is contained in:
Pete Bacon Darwin 2018-05-18 19:29:34 +01:00 committed by Miško Hevery
parent e6516b0229
commit bc4f10ca20
4 changed files with 22 additions and 26 deletions

View File

@ -119,8 +119,8 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs')));
})
.config(function(computeStability, splitDescription, addNotYetDocumentedProperty, EXPORT_DOC_TYPES, API_DOC_TYPES) {
computeStability.docTypes = EXPORT_DOC_TYPES;
.config(function(computeStability, splitDescription, addNotYetDocumentedProperty, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES) {
computeStability.docTypes = API_DOC_TYPES_TO_RENDER;
// Only split the description on the API docs
splitDescription.docTypes = API_DOC_TYPES;
addNotYetDocumentedProperty.docTypes = API_DOC_TYPES;
@ -166,9 +166,9 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
filterContainedDocs.docTypes = API_CONTAINED_DOC_TYPES;
})
.config(function(checkContentRules, EXPORT_DOC_TYPES, API_CONTAINED_DOC_TYPES) {
.config(function(checkContentRules, API_DOC_TYPES, API_CONTAINED_DOC_TYPES) {
addMinLengthRules(checkContentRules);
addHeadingRules(checkContentRules, EXPORT_DOC_TYPES);
addHeadingRules(checkContentRules, API_DOC_TYPES);
addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES);
})
@ -214,37 +214,33 @@ function addMinLengthRules(checkContentRules) {
paramRules.push(createMinLengthRule());
}
function addHeadingRules(checkContentRules, EXPORT_DOC_TYPES) {
function addHeadingRules(checkContentRules, API_DOC_TYPES) {
const createNoMarkdownHeadingsRule = require('./content-rules/noMarkdownHeadings');
const noMarkdownHeadings = createNoMarkdownHeadingsRule();
const allowOnlyLevel3Headings = createNoMarkdownHeadingsRule(1, 2, '4,');
const DOC_TYPES_TO_CHECK = EXPORT_DOC_TYPES.concat(['member', 'overload-info']);
const PROPS_TO_CHECK = ['description', 'shortDescription'];
DOC_TYPES_TO_CHECK.forEach(docType => {
API_DOC_TYPES.forEach(docType => {
let rules;
const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {};
PROPS_TO_CHECK.forEach(prop => {
const rules = ruleSet[prop] = ruleSet[prop] || [];
rules.push(noMarkdownHeadings);
});
const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
rules = ruleSet['description'] = ruleSet['description'] || [];
rules.push(noMarkdownHeadings);
rules = ruleSet['shortDescription'] = ruleSet['shortDescription'] || [];
rules.push(noMarkdownHeadings);
rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
rules.push(allowOnlyLevel3Headings);
});
}
function addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES) {
const PROPS_TO_DISALLOW = ['usageNotes'];
API_CONTAINED_DOC_TYPES.forEach(docType => {
const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {};
PROPS_TO_DISALLOW.forEach(prop => {
const rules = ruleSet[prop] = ruleSet[prop] || [];
rules.push((doc, prop, value) => {
return value &&
!isMethod(doc) &&
`Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`;
});
});
const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
rules.push((doc, prop, value) => value && !isMethod(doc) &&
`Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`);
});
}

View File

@ -5,7 +5,7 @@
module.exports = function filterContainedDocs() {
return {
docTypes: ['member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter'],
$runAfter: ['extra-docs-added'],
$runAfter: ['extra-docs-added', 'checkContentRules'],
$runBefore: ['computing-paths'],
$process: function(docs) {
var docTypes = this.docTypes;

View File

@ -1,6 +1,6 @@
module.exports = function filterPrivateDocs() {
return {
$runAfter: ['extra-docs-added'],
$runAfter: ['extra-docs-added', 'checkContentRules'],
$runBefore: ['computing-paths'],
$process: function(docs) {
return docs.filter(function(doc) { return doc.privateExport !== true; });

View File

@ -18,7 +18,7 @@ describe('filterPrivateDocs processor', () => {
it('should run after the correct processor', () => {
const processor = processorFactory();
expect(processor.$runAfter).toEqual(['extra-docs-added']);
expect(processor.$runAfter).toEqual(['extra-docs-added', 'checkContentRules']);
});
it('should remove docs that are marked as private exports', () => {