build(aio): rearrange processors to ensure we catch all content errors (#24000)
PR Close #24000
This commit is contained in:
parent
e6516b0229
commit
bc4f10ca20
|
@ -119,8 +119,8 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||||
parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs')));
|
parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs')));
|
||||||
})
|
})
|
||||||
|
|
||||||
.config(function(computeStability, splitDescription, addNotYetDocumentedProperty, EXPORT_DOC_TYPES, API_DOC_TYPES) {
|
.config(function(computeStability, splitDescription, addNotYetDocumentedProperty, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES) {
|
||||||
computeStability.docTypes = EXPORT_DOC_TYPES;
|
computeStability.docTypes = API_DOC_TYPES_TO_RENDER;
|
||||||
// Only split the description on the API docs
|
// Only split the description on the API docs
|
||||||
splitDescription.docTypes = API_DOC_TYPES;
|
splitDescription.docTypes = API_DOC_TYPES;
|
||||||
addNotYetDocumentedProperty.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;
|
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);
|
addMinLengthRules(checkContentRules);
|
||||||
addHeadingRules(checkContentRules, EXPORT_DOC_TYPES);
|
addHeadingRules(checkContentRules, API_DOC_TYPES);
|
||||||
addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES);
|
addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -214,37 +214,33 @@ function addMinLengthRules(checkContentRules) {
|
||||||
paramRules.push(createMinLengthRule());
|
paramRules.push(createMinLengthRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHeadingRules(checkContentRules, EXPORT_DOC_TYPES) {
|
function addHeadingRules(checkContentRules, API_DOC_TYPES) {
|
||||||
const createNoMarkdownHeadingsRule = require('./content-rules/noMarkdownHeadings');
|
const createNoMarkdownHeadingsRule = require('./content-rules/noMarkdownHeadings');
|
||||||
const noMarkdownHeadings = createNoMarkdownHeadingsRule();
|
const noMarkdownHeadings = createNoMarkdownHeadingsRule();
|
||||||
const allowOnlyLevel3Headings = createNoMarkdownHeadingsRule(1, 2, '4,');
|
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] || {};
|
const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {};
|
||||||
PROPS_TO_CHECK.forEach(prop => {
|
|
||||||
const rules = ruleSet[prop] = ruleSet[prop] || [];
|
rules = ruleSet['description'] = ruleSet['description'] || [];
|
||||||
rules.push(noMarkdownHeadings);
|
rules.push(noMarkdownHeadings);
|
||||||
});
|
|
||||||
const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
|
rules = ruleSet['shortDescription'] = ruleSet['shortDescription'] || [];
|
||||||
|
rules.push(noMarkdownHeadings);
|
||||||
|
|
||||||
|
rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
|
||||||
rules.push(allowOnlyLevel3Headings);
|
rules.push(allowOnlyLevel3Headings);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES) {
|
function addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES) {
|
||||||
const PROPS_TO_DISALLOW = ['usageNotes'];
|
|
||||||
|
|
||||||
API_CONTAINED_DOC_TYPES.forEach(docType => {
|
API_CONTAINED_DOC_TYPES.forEach(docType => {
|
||||||
const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {};
|
const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {};
|
||||||
PROPS_TO_DISALLOW.forEach(prop => {
|
|
||||||
const rules = ruleSet[prop] = ruleSet[prop] || [];
|
const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || [];
|
||||||
rules.push((doc, prop, value) => {
|
rules.push((doc, prop, value) => value && !isMethod(doc) &&
|
||||||
return value &&
|
`Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`);
|
||||||
!isMethod(doc) &&
|
|
||||||
`Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
module.exports = function filterContainedDocs() {
|
module.exports = function filterContainedDocs() {
|
||||||
return {
|
return {
|
||||||
docTypes: ['member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter'],
|
docTypes: ['member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter'],
|
||||||
$runAfter: ['extra-docs-added'],
|
$runAfter: ['extra-docs-added', 'checkContentRules'],
|
||||||
$runBefore: ['computing-paths'],
|
$runBefore: ['computing-paths'],
|
||||||
$process: function(docs) {
|
$process: function(docs) {
|
||||||
var docTypes = this.docTypes;
|
var docTypes = this.docTypes;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = function filterPrivateDocs() {
|
module.exports = function filterPrivateDocs() {
|
||||||
return {
|
return {
|
||||||
$runAfter: ['extra-docs-added'],
|
$runAfter: ['extra-docs-added', 'checkContentRules'],
|
||||||
$runBefore: ['computing-paths'],
|
$runBefore: ['computing-paths'],
|
||||||
$process: function(docs) {
|
$process: function(docs) {
|
||||||
return docs.filter(function(doc) { return doc.privateExport !== true; });
|
return docs.filter(function(doc) { return doc.privateExport !== true; });
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('filterPrivateDocs processor', () => {
|
||||||
|
|
||||||
it('should run after the correct processor', () => {
|
it('should run after the correct processor', () => {
|
||||||
const processor = processorFactory();
|
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', () => {
|
it('should remove docs that are marked as private exports', () => {
|
||||||
|
|
Loading…
Reference in New Issue