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", "_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\n\n\n\n\n\n"; output += "