Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sources.forEach(function (source) {
var sourceName = source.replace(/\.js$/, "");
var dest = grunt.option("dest") + "/source/" + source + ".html";
grunt.log.writeln("Rendering " + source.cyan + " to " + dest.cyan);
var code = grunt.file.read("togetherjs/" + source);
var sections = docco.parse(source, code, {languages:{}});
doccoFormat(source, sections);
sections.forEach(function (section, i) {
section.index = i;
section.empty = section.codeText.replace(/\s/gm, "") === "";
});
var first = marked.lexer(sections[0].docsText)[0];
var hasTitle = first && first.type == 'heading' && first.depth == 1;
var title = hasTitle ? first.text : path.basename(source, ".js");
var tmpl = env.getTemplate("source-code.tmpl");
var tmplVars = Object.create(vars);
tmplVars.title = title;
tmplVars.sections = sections;
tmplVars.source = source;
tmplVars.sourceName = sourceName;
tmplVars.sourceDescription = marked(sourceDescriptions[sourceName] || "", {smartypants: true});
tmplVars.base = "../";