Skip to content

Commit 0f20c39

Browse files
chore(doc-gen): include exported variable declaration in public docs
1 parent 8a10ede commit 0f20c39

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

docs/dgeni-package/index.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
2626
.factory(require('./readers/atScript'))
2727
.factory(require('./readers/ngdoc'))
2828

29+
.factory('EXPORT_DOC_TYPES', function() {
30+
return [
31+
'class',
32+
'function',
33+
'var',
34+
'const'
35+
];
36+
})
37+
2938

3039
// Register the processors
3140
.processor(require('./processors/generateDocsFromComments'))
@@ -82,15 +91,10 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
8291

8392

8493
// Configure ids and paths
85-
.config(function(computeIdsProcessor, computePathsProcessor) {
94+
.config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) {
8695

8796
computeIdsProcessor.idTemplates.push({
88-
docTypes: [
89-
'class',
90-
'function',
91-
'NAMED_EXPORT',
92-
'VARIABLE_STATEMENT'
93-
],
97+
docTypes: EXPORT_DOC_TYPES,
9498
idTemplate: '${moduleDoc.id}.${name}',
9599
getAliases: function(doc) { return [doc.id]; }
96100
});
@@ -123,12 +127,7 @@ module.exports = new Package('angular', [jsdocPackage, nunjucksPackage])
123127
});
124128

125129
computePathsProcessor.pathTemplates.push({
126-
docTypes: [
127-
'class',
128-
'function',
129-
'NAMED_EXPORT',
130-
'VARIABLE_STATEMENT'
131-
],
130+
docTypes: EXPORT_DOC_TYPES,
132131
pathTemplate: '${moduleDoc.path}/${name}',
133132
outputPathTemplate: MODULES_DOCS_PATH + '/${path}/index.html'
134133
});

docs/dgeni-package/services/ExportTreeVisitor.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@ module.exports = function ExportTreeVisitor(ParseTreeVisitor, log) {
2424
this.currentExport = null;
2525
},
2626

27-
visitVariableStatement: function(tree) {
28-
if ( this.currentExport ) {
29-
this.updateExport(tree);
30-
this.currentExport.name = "VARIABLE_STATEMENT";
31-
}
32-
},
33-
3427
visitVariableDeclaration: function(tree) {
3528
if ( this.currentExport ) {
3629
this.updateExport(tree);
37-
this.currentExport.name = tree.lvalue;
30+
this.currentExport.docType = 'var';
31+
this.currentExport.name = tree.lvalue.identifierToken.value;
3832
this.currentExport.variableDeclaration = tree;
3933
}
4034
},

docs/public-docs-package/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ module.exports = new Package('angular-public', [basePackage])
1010
parseTagsProcessor.tagDefinitions.push({ name: 'publicModule' });
1111
})
1212

13-
.config(function(processClassDocs) {
13+
.config(function(processClassDocs, filterPublicDocs, EXPORT_DOC_TYPES) {
1414
processClassDocs.ignorePrivateMembers = true;
15+
filterPublicDocs.docTypes = EXPORT_DOC_TYPES;
1516
})
1617

1718
// Configure file writing

docs/public-docs-package/processors/filterPublicDocs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ module.exports = function filterPublicDocs(modules) {
44
return {
55
$runAfter: ['tags-parsed'],
66
$runBefore: ['computing-ids'],
7+
docTypes: [],
8+
$validate: {
9+
docTypes: { presence: true }
10+
},
711
$process: function(docs) {
812

9-
//console.log('filterPublicDocs', Object.keys(modules));
13+
docTypes = this.docTypes;
1014

1115

1216
docs = _.filter(docs, function(doc) {
13-
if (doc.docType !== 'class') return true;
17+
18+
if (docTypes.indexOf(doc.docType) === -1) return true;
1419
if (!doc.publicModule) return false;
1520

16-
//console.log('CLASS:', doc.name, doc.moduleDoc.id);
1721
updateModule(doc);
1822

1923
return true;
@@ -39,8 +43,6 @@ module.exports = function filterPublicDocs(modules) {
3943

4044
publicModule.isPublic = true;
4145

42-
//console.log('UPDATE CLASS', classDoc.id, originalModule.id, publicModule.id);
43-
4446
_.remove(classDoc.moduleDoc.exports, function(doc) { return doc === classDoc; });
4547
classDoc.moduleDoc = publicModule;
4648
publicModule.exports.push(classDoc);

0 commit comments

Comments
 (0)