chore(docs): add a processor to get the name of a guide doc from its markdown
This commit is contained in:
parent
83f650fca7
commit
3d12d08f8a
|
@ -29,7 +29,7 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
|
|||
.processor(require('./processors/processModuleDocs'))
|
||||
.processor(require('./processors/processClassDocs'))
|
||||
.processor(require('./processors/generateNavigationDoc'))
|
||||
|
||||
.processor(require('./processors/extractTitleFromGuides'))
|
||||
|
||||
// Configure the log service
|
||||
.config(function(log) {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
var _ = require('lodash');
|
||||
|
||||
module.exports = function extractTitleFromGuides() {
|
||||
|
||||
return {
|
||||
$runAfter: ['processing-docs'],
|
||||
$runBefore: ['docs-processed'],
|
||||
$process: function(docs) {
|
||||
_(docs).forEach(function(doc) {
|
||||
if (doc.docType === 'guide') {
|
||||
doc.name = doc.name || getNameFromHeading(doc.description);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
function getNameFromHeading(text) {
|
||||
var match = /^\s*#\s*(.*)/.exec(text);
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue