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

View File

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

View File

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

View File

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