chore(docs): add a processor to get the name of a guide doc from its markdown

This commit is contained in:
Peter Bacon Darwin 2015-02-17 08:08:24 +00:00
parent 83f650fca7
commit 3d12d08f8a
2 changed files with 25 additions and 1 deletions

View File

@ -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) {

View File

@ -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];
}
}