chore(doc-gen): ensure all public exports are rendered in public_docs

Closes #1222
This commit is contained in:
Peter Bacon Darwin 2015-04-08 18:58:14 +02:00
parent ad083ed28f
commit 9f8a9c6fc7
5 changed files with 41 additions and 28 deletions

View File

@ -374,6 +374,6 @@ md-content.demo-source-container > hljs > pre > code.highlight {
margin: 1em 0; margin: 1em 0;
} }
.member { .left-nav {
min-width: 300px;
} }

View File

@ -28,7 +28,7 @@
<section layout="row"> <section layout="row">
<md-content> <md-content class="left-nav">
<h2>Navigation</h2> <h2>Navigation</h2>
<section ng-repeat="area in nav.areas"> <section ng-repeat="area in nav.areas">
<h3>{{ area.name }}</h3> <h3>{{ area.name }}</h3>

View File

@ -3,7 +3,8 @@
{% block body %} {% block body %}
<h1 class="class export">{$ doc.name $} <span class="type">class</span></h1> <h1 class="class export">{$ doc.name $} <span class="type">class</span></h1>
<p class="module">exported from <a href="/{$ doc.moduleDoc.path $}">{$ doc.moduleDoc.id $}</a></p> <p class="module">exported from <a href="/{$ doc.moduleDoc.path $}">{$ doc.moduleDoc.id $}</a><br/>
defined in <a href="https://github.com/angular/angular/tree/master/modules/{$ doc.location.start.source.name $}.js#L{$ doc.location.start.line $}">{$ doc.location.start.source.name $}.js (line {$ doc.location.start.line $})</a></p>
<p>{$ doc.description | marked $}</p> <p>{$ doc.description | marked $}</p>
{%- if doc.constructorDoc or doc.members.length -%} {%- if doc.constructorDoc or doc.members.length -%}

View File

@ -9,7 +9,7 @@
<h2>Exports</h2> <h2>Exports</h2>
<ul> <ul>
{%- for exportDoc in doc.exports %} {%- for exportDoc in doc.exports %}
<li><a href="/{$ exportDoc.path $}">{$ exportDoc.name $} {$ exportDoc.docType $}</a></li> <li><a href="/{$ exportDoc.path $}"><strong>{$ exportDoc.name $}</strong> {$ exportDoc.docType $}</a></li>
{%- endfor %} {%- endfor %}
</ul> </ul>
{% endif %} {% endif %}

View File

@ -10,42 +10,54 @@ module.exports = function filterPublicDocs(modules) {
}, },
$process: function(docs) { $process: function(docs) {
var extraPublicDocs = [];
docTypes = this.docTypes; docTypes = this.docTypes;
_.forEach(docs, function(doc) {
if (docTypes.indexOf(doc.docType) === -1 || !doc.publicModule) return;
var publicModule = modules[doc.publicModule];
if (!publicModule) {
throw new Error('Missing module definition: "' + doc.publicModule + '"\n' +
'Referenced in class: "' + doc.moduleDoc.id + '/' + doc.name + '"');
} else {
// 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) { docs = _.filter(docs, function(doc) {
if (docTypes.indexOf(doc.docType) === -1) return true; if (doc.docType === 'module') {
if (!doc.publicModule) return false; // doc is a module - is it public?
return doc.isPublic;
updateModule(doc); }
if (docTypes.indexOf(doc.docType) === -1) {
// doc is not a type we care about
return true; return true;
}
// doc is in a public module
return doc.moduleDoc && doc.moduleDoc.isPublic;
}); });
docs = _.filter(docs, function(doc) { docs = docs.concat(extraPublicDocs);
return doc.docType !== 'module' || doc.isPublic;
});
return docs; 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);
}
}; };