No longer need to add @lends to the documentation for module.exports.

This commit is contained in:
Michael Mathews 2011-03-12 13:50:00 +00:00
parent 98f5751ff7
commit 4edb8bcff6
4 changed files with 55 additions and 18 deletions

50
main.js
View File

@ -234,6 +234,53 @@ function main() {
packageDocs.files = sourceFiles || [];
docs.push(packageDocs);
}
function indexAll(docs) {
var index = {};
docs.forEach(function(doc) {
if (!index[doc.longname]) index[doc.longname] = [];
index[doc.longname].push(doc);
});
docs.index = index;
}
function doop(o) {
return eval(uneval(o));
}
function resolveBorrowed(docs) {
docs.forEach(function(doc) {
if (doc.borrowed) {
doc.borrowed.forEach(function(b, i) {
var from = docs.index[b.from],
asName = b['as'] || b.from;
if (from) {
var cloned = doop(from);
cloned.forEach(function(c) {
asName = asName.replace(/^prototype\./, '#');
var parts = asName.split('#');
if (parts.length === 2) c.scope = 'instance';
else c.scope = 'static';
asName = parts.pop();
c.name = asName;
c.memberof = doc.longname;
c.longname = c.memberof + (c.scope === 'instance'? '#': '.') + c.name;
docs.push(c);
});
}
});
}
});
}
indexAll(docs);
resolveBorrowed(docs);
if (env.opts.expel) {
dump(docs);
@ -253,5 +300,8 @@ function main() {
}
else { // TODO throw no publish warning?
}
}
}

View File

@ -55,7 +55,7 @@
if (!newDoclet.memberof && e.astnode) {
var memberofName,
scope;
if ( /^(exports|this)(\.|$)/.test(newDoclet.name) ) {
if ( /^((module.)?exports|this)(\.|$)/.test(newDoclet.name) ) {
var nameStartsWith = RegExp.$1;
newDoclet.name = newDoclet.name.replace(/^(exports|this)(\.|$)/, '');
@ -65,6 +65,10 @@
memberofName = currentModule;
scope = 'static';
}
else if (newDoclet.name === 'module.exports' && currentModule) {
newDoclet.addTag('name', currentModule);
newDoclet.postProcess();
}
else {
// like /** @module foo */ exports = {bar: 1};
// or /** blah */ this.foo = 1;

View File

@ -99,22 +99,6 @@
}
?>
<?js
if (doc.borrowed && doc.borrowed.length && doc.borrowed.forEach) {
?>
<h3 class="subsection-title">Borrows</h3>
<ul><?js
doc.borrowed.forEach(function(b) {
?>
<li><?js= linkto(b.from, b.from) ?></li>
<?js
});
?></ul>
<?js } ?>
<?js
var classes = find({kind: 'class', memberof: doc.longname});
if (doc.kind !== 'globalobj' && classes && classes.length) {

View File

@ -1,6 +1,5 @@
/** @module color/mixer */
/** @lends module:color/mixer */
module.exports = {
/** Blend two colors together. */
blend: function(color1, color2) { }