chore(doc-gen): add new "public" docs configuration

This commit is contained in:
Peter Bacon Darwin 2015-03-17 16:49:07 +00:00 committed by Misko Hevery
parent ede7690be3
commit f503c1e9e6
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,16 @@
var Package = require('dgeni').Package;
var basePackage = require('../dgeni-package');
module.exports = new Package('angular-public', [basePackage])
.processor(require('./processors/filterPublicDocs'))
.config(function(parseTagsProcessor) {
parseTagsProcessor.tagDefinitions.push({ name: 'publicModule' });
})
// Configure file writing
.config(function(writeFilesProcessor) {
writeFilesProcessor.outputFolder = 'dist/public_docs';
});

View File

@ -0,0 +1,49 @@
var _ = require('lodash');
module.exports = function filterPublicDocs(modules) {
return {
$runAfter: ['tags-parsed'],
$runBefore: ['computing-ids'],
$process: function(docs) {
//console.log('filterPublicDocs', Object.keys(modules));
docs = _.filter(docs, function(doc) {
if (doc.docType !== 'class') return true;
if (!doc.publicModule) return false;
//console.log('CLASS:', doc.name, doc.moduleDoc.id);
updateModule(doc);
return true;
});
docs = _.filter(docs, function(doc) {
return doc.docType !== 'module' || doc.isPublic;
});
return docs;
}
};
function updateModule(classDoc) {
var originalModule = classDoc.moduleDoc;
var publicModule = modules[classDoc.publicModule];
if (!publicModule) {
throw new Error('Missing module definition: "' + classDoc.publicModule + '"\n' +
'Referenced in class: "' + classDoc.moduleDoc.id + '/' + classDoc.name + '"');
}
publicModule.isPublic = true;
//console.log('UPDATE CLASS', classDoc.id, originalModule.id, publicModule.id);
_.remove(classDoc.moduleDoc.exports, function(doc) { return doc === classDoc; });
classDoc.moduleDoc = publicModule;
publicModule.exports.push(classDoc);
}
};