Skip to content

Commit 88fdf23

Browse files
committed
chore(doc-gen): report on missing or obsolete error docs
Closes angular#12527
1 parent 54cfd06 commit 88fdf23

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

docs/config/processors/error-docs.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,36 @@
55
* @description
66
* Process "error" docType docs and generate errorNamespace docs
77
*/
8-
module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
8+
module.exports = function errorDocsProcessor(log, errorNamespaceMap, getMinerrInfo) {
99
return {
1010
$runAfter: ['tags-extracted'],
1111
$runBefore: ['extra-docs-added'],
1212
$process: function(docs) {
1313

14+
// Get the extracted min errors to compare with the error docs, and report any mismatch
15+
var collectedErrors = require('../../../build/errors.json').errors;
16+
var flatErrors = [];
17+
18+
for (var namespace in collectedErrors) {
19+
for (var error in collectedErrors[namespace]) {
20+
flatErrors.push(namespace + ':' + error);
21+
}
22+
}
23+
1424
// Create error namespace docs and attach error docs to each
1525
docs.forEach(function(doc) {
1626
var parts, namespaceDoc;
1727

1828
if (doc.docType === 'error') {
1929

30+
var matchingMinErr = flatErrors.indexOf(doc.name);
31+
32+
if (matchingMinErr === -1) {
33+
log.warn('Error doc: ' + doc.name + ' has no matching min error');
34+
} else {
35+
flatErrors.splice(matchingMinErr, 1);
36+
}
37+
2038
// Parse out the error info from the id
2139
parts = doc.name.split(':');
2240
doc.namespace = parts[0];
@@ -41,6 +59,10 @@ module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
4159
}
4260
});
4361

62+
flatErrors.forEach(function(value) {
63+
log.warn('No error doc exists for min error: ' + value);
64+
});
65+
4466
errorNamespaceMap.forEach(function(errorNamespace) {
4567
docs.push(errorNamespace);
4668
});

0 commit comments

Comments
 (0)