Skip to content

Commit

Permalink
build(aio): implement rules to prevent headings in content (angular#2…
Browse files Browse the repository at this point in the history
…2759)

* No headings are allowed in `description` and `shortDescription`
* Only heading level 3 is allowed in `usageNotes`

PR Close angular#22759
  • Loading branch information
petebacondarwin authored and wKoza committed Apr 13, 2018
1 parent 5ba597b commit f50ebad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions aio/tools/transforms/angular-api-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
addNotYetDocumentedProperty.docTypes = API_DOC_TYPES;
})

.config(function(checkContentRules, EXPORT_DOC_TYPES) {
const createNoMarkdownHeadings = require('./content-rules/noMarkdownHeadings');
const noMarkdownHeadings = createNoMarkdownHeadings();
const allowOnlyLevel3Headings = createNoMarkdownHeadings(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 => {
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.push(allowOnlyLevel3Headings);
});
})

.config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) {

const API_SEGMENT = 'api';
Expand Down

0 comments on commit f50ebad

Please sign in to comment.