var path = require("path"); var docast = require("docast"); var glob = require("glob"); var marked = require("marked"); var yaml = require("js-yaml"); marked.setOptions({ gfm: true, sanitize: true, pedantic: false }); var above = path.resolve(__dirname, "../lib/"); var match = above + "/**/*.js"; var docs = {}; glob(match, function(er, files){ files.forEach(function(file){ var comments = docast.parse(file); for(var i = 0; i < comments.length; ++i){ var comment = comments[i]; try{ comment.doc = yaml.safeLoad(comment.doc); if(!comment.doc.hasOwnProperty("section")){ continue; } if(!docs[comment.doc.section]){ docs[comment.doc.section] = {}; } for(var key in comment.doc.params){ if(comment.doc.params.hasOwnProperty(key)){ comment.doc.params[key] = comment.doc.params[key].replace(/optional/g, "_optional_"); comment.doc.params[key] = marked(comment.doc.params[key]); } } if(comment.doc.hasOwnProperty("example")){ comment.doc.example = marked(comment.doc.example); } else { comment.doc.example = ""; } if(comment.doc.hasOwnProperty("comment")){ comment.doc.comment = marked(comment.doc.comment); } else { comment.doc.comment = ""; } docs[comment.doc.section][comment.name] = comment.doc; } catch(e){} } }); var output = "\n\n\n"; output += "\n"; output += "\n\n"; output += "\n"; output += "\n"; output += "\n\n"; output += "Jump To Top\n"; output += "
\n"; output += "
\n"; output += "
\n"; output += "

Node Dogapi

\n"; output += "
    \n"; for(var section in docs){ if(!docs.hasOwnProperty(section)){ continue; } output += "
  • " + section + "\n"; output += "
  • \n"; } output += "
\n
\n
\n"; for(var section in docs){ if(!docs.hasOwnProperty(section)){ continue; } methods = docs[section]; output += "
\n"; output += "
\n

" + section + "

\n"; output += "\n"; for(var name in methods){ if(!methods.hasOwnProperty(name)){ continue; } doc = methods[name]; var className = section + "-" + name; output += "
\n"; var definition = name + "("; if(doc.params && typeof doc.params === "object"){ definition += Object.keys(doc.params).join(", "); } definition += ")"; output += "

" + definition + "

\n"; output += "
\n"; output += doc.comment; if(doc.params){ output += "

Parameters:

\n"; output += "
\n"; for(var param in doc.params){ if(!doc.params.hasOwnProperty(param)){ continue; } var comment = doc.params[param]; output += "
" + param + "
\n"; output += "
" + comment + "
\n"; } output += "
\n"; } output += "
\n"; output += "
\n"; output += doc.example; output += "
\n"; output += "
\n"; } output += "
\n"; } output += "
\n"; output += "\"Fork"; output += ""; console.log(output); });