From 9f8a9c6fc7a20d83c21a74c75c31f8b844e37c23 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Wed, 8 Apr 2015 18:58:14 +0200 Subject: [PATCH] chore(doc-gen): ensure all public exports are rendered in public_docs Closes #1222 --- docs/app/css/app.css | 4 +- docs/app/index.html | 2 +- .../templates/class.template.html | 3 +- .../templates/module.template.html | 2 +- .../processors/filterPublicDocs.js | 58 +++++++++++-------- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/docs/app/css/app.css b/docs/app/css/app.css index 416cd17904..ac23dd0c82 100644 --- a/docs/app/css/app.css +++ b/docs/app/css/app.css @@ -374,6 +374,6 @@ md-content.demo-source-container > hljs > pre > code.highlight { margin: 1em 0; } -.member { - +.left-nav { + min-width: 300px; } \ No newline at end of file diff --git a/docs/app/index.html b/docs/app/index.html index 9df6aa8ae3..cbfac9f869 100644 --- a/docs/app/index.html +++ b/docs/app/index.html @@ -28,7 +28,7 @@
- +

Navigation

{{ area.name }}

diff --git a/docs/dgeni-package/templates/class.template.html b/docs/dgeni-package/templates/class.template.html index f615345c29..6e7c9a8db8 100644 --- a/docs/dgeni-package/templates/class.template.html +++ b/docs/dgeni-package/templates/class.template.html @@ -3,7 +3,8 @@ {% block body %}

{$ doc.name $} class

-

exported from {$ doc.moduleDoc.id $}

+

exported from {$ doc.moduleDoc.id $}
+defined in {$ doc.location.start.source.name $}.js (line {$ doc.location.start.line $})

{$ doc.description | marked $}

{%- if doc.constructorDoc or doc.members.length -%} diff --git a/docs/dgeni-package/templates/module.template.html b/docs/dgeni-package/templates/module.template.html index 2000a4ab7d..d6202a8b28 100644 --- a/docs/dgeni-package/templates/module.template.html +++ b/docs/dgeni-package/templates/module.template.html @@ -9,7 +9,7 @@

Exports

{% endif %} diff --git a/docs/public-docs-package/processors/filterPublicDocs.js b/docs/public-docs-package/processors/filterPublicDocs.js index 2def7eba38..4190f2e740 100644 --- a/docs/public-docs-package/processors/filterPublicDocs.js +++ b/docs/public-docs-package/processors/filterPublicDocs.js @@ -10,42 +10,54 @@ module.exports = function filterPublicDocs(modules) { }, $process: function(docs) { + var extraPublicDocs = []; docTypes = this.docTypes; + _.forEach(docs, function(doc) { - docs = _.filter(docs, function(doc) { + if (docTypes.indexOf(doc.docType) === -1 || !doc.publicModule) return; - if (docTypes.indexOf(doc.docType) === -1) return true; - if (!doc.publicModule) return false; + var publicModule = modules[doc.publicModule]; - updateModule(doc); + if (!publicModule) { + throw new Error('Missing module definition: "' + doc.publicModule + '"\n' + + 'Referenced in class: "' + doc.moduleDoc.id + '/' + doc.name + '"'); + } else { - return true; + // Ensure module is marked as public + publicModule.isPublic = true; + + // Add a clone of export to its "public" module + var publicDoc = _.clone(doc); + publicDoc.moduleDoc = publicModule; + publicModule.exports.push(publicDoc); + extraPublicDocs.push(publicDoc); + } }); + // Filter out the documents that are not public docs = _.filter(docs, function(doc) { - return doc.docType !== 'module' || doc.isPublic; + + if (doc.docType === 'module') { + // doc is a module - is it public? + return doc.isPublic; + } + + if (docTypes.indexOf(doc.docType) === -1) { + // doc is not a type we care about + return true; + } + + // doc is in a public module + return doc.moduleDoc && doc.moduleDoc.isPublic; + }); + + docs = docs.concat(extraPublicDocs); + 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; - - _.remove(classDoc.moduleDoc.exports, function(doc) { return doc === classDoc; }); - classDoc.moduleDoc = publicModule; - publicModule.exports.push(classDoc); - - } }; \ No newline at end of file