Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add method params to --api

  • Loading branch information...
commit 48471bc3fdaea2081da0eb57601409dcfd99cd99 1 parent 1d59fde
@tj authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 lib/api.js
View
23 lib/api.js
@@ -10,11 +10,30 @@ module.exports = function(comments){
if (!ctx) return;
if (~desc.full.indexOf('Module dependencies')) return;
if (!ctx.string.indexOf('module.exports')) return;
- buf.push('## ' + ctx.string.replace('.prototype.', '#'));
+ buf.push('### ' + context(comment));
buf.push('');
buf.push(desc.full.trim().replace(/^/gm, ' '));
buf.push('');
});
return buf.join('\n');
-};
+};
+
+function context(comment) {
+ var ctx = comment.ctx;
+ var tags = comment.tags;
+ switch (ctx.type) {
+ case 'method':
+ return ctx.constructor + '#' + ctx.name + '(' + params(tags) + ')';
+ default:
+ return ctx.string;
+ }
+}
+
+function params(tags) {
+ return tags.filter(function(tag){
+ return tag.type == 'param';
+ }).map(function(param){
+ return param.name + ':' + param.types.join('|');
+ }).join(',');
+}
Please sign in to comment.
Something went wrong with that request. Please try again.