chore(doc-gen): include exported variable declaration in public docs

This commit is contained in:
Peter Bacon Darwin 2015-03-19 14:48:47 +00:00
parent 8a10edec01
commit 0f20c39f42
4 changed files with 23 additions and 27 deletions

View File

@ -26,6 +26,15 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
.factory(require('./readers/atScript'))
.factory(require('./readers/ngdoc'))
.factory('EXPORT_DOC_TYPES', function() {
return [
'class',
'function',
'var',
'const'
];
})
// Register the processors
.processor(require('./processors/generateDocsFromComments'))
@ -82,15 +91,10 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
// Configure ids and paths
.config(function(computeIdsProcessor, computePathsProcessor) {
.config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) {
computeIdsProcessor.idTemplates.push({
docTypes: [
'class',
'function',
'NAMED_EXPORT',
'VARIABLE_STATEMENT'
],
docTypes: EXPORT_DOC_TYPES,
idTemplate: '${moduleDoc.id}.${name}',
getAliases: function(doc) { return [doc.id]; }
});
@ -123,12 +127,7 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
});
computePathsProcessor.pathTemplates.push({
docTypes: [
'class',
'function',
'NAMED_EXPORT',
'VARIABLE_STATEMENT'
],
docTypes: EXPORT_DOC_TYPES,
pathTemplate: '${moduleDoc.path}/${name}',
outputPathTemplate: MODULES_DOCS_PATH + '/${path}/index.html'
});

View File

@ -24,17 +24,11 @@ module.exports = function ExportTreeVisitor(ParseTreeVisitor, log) {
this.currentExport = null;
},
visitVariableStatement: function(tree) {
if ( this.currentExport ) {
this.updateExport(tree);
this.currentExport.name = "VARIABLE_STATEMENT";
}
},
visitVariableDeclaration: function(tree) {
if ( this.currentExport ) {
this.updateExport(tree);
this.currentExport.name = tree.lvalue;
this.currentExport.docType = 'var';
this.currentExport.name = tree.lvalue.identifierToken.value;
this.currentExport.variableDeclaration = tree;
}
},

View File

@ -10,8 +10,9 @@ module.exports = new Package('angular-public', [basePackage])
parseTagsProcessor.tagDefinitions.push({ name: 'publicModule' });
})
.config(function(processClassDocs) {
.config(function(processClassDocs, filterPublicDocs, EXPORT_DOC_TYPES) {
processClassDocs.ignorePrivateMembers = true;
filterPublicDocs.docTypes = EXPORT_DOC_TYPES;
})
// Configure file writing

View File

@ -4,16 +4,20 @@ module.exports = function filterPublicDocs(modules) {
return {
$runAfter: ['tags-parsed'],
$runBefore: ['computing-ids'],
docTypes: [],
$validate: {
docTypes: { presence: true }
},
$process: function(docs) {
//console.log('filterPublicDocs', Object.keys(modules));
docTypes = this.docTypes;
docs = _.filter(docs, function(doc) {
if (doc.docType !== 'class') return true;
if (docTypes.indexOf(doc.docType) === -1) return true;
if (!doc.publicModule) return false;
//console.log('CLASS:', doc.name, doc.moduleDoc.id);
updateModule(doc);
return true;
@ -39,8 +43,6 @@ module.exports = function filterPublicDocs(modules) {
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);