diff --git a/main.js b/main.js index add8a973..7de31724 100644 --- a/main.js +++ b/main.js @@ -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? } + + + } } \ No newline at end of file diff --git a/modules/jsdoc/src/handlers.js b/modules/jsdoc/src/handlers.js index 7e346f97..8443a73f 100644 --- a/modules/jsdoc/src/handlers.js +++ b/modules/jsdoc/src/handlers.js @@ -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; diff --git a/templates/default/tmpl/container.tmpl b/templates/default/tmpl/container.tmpl index 493abfdd..ebe5ab23 100644 --- a/templates/default/tmpl/container.tmpl +++ b/templates/default/tmpl/container.tmpl @@ -99,22 +99,6 @@ } ?> - - -

Borrows

- - - - -