Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (toHighlight.hasOwnProperty(id)) {
highlight(toHighlight[id], function (output) {
readme = readme.replace('//js:' + id, output);
delete toHighlight[id];
highlightSnippets();
});
return;
}
}
writeIndex();
};
highlightSnippets();
// run docco for libs
require('docco').run([
'', '',
'--css', 'site/main.css',
'--template', 'site/docco.jst',
'lib/*.js']);
// run docco for unit tests
require('docco').run([
'', '',
'--css', 'site/main.css',
'--template', 'site/docco.jst',
'--output', 'docs/test/',
'test/*.js']);
var options = grunt.config(['docco', this.target]);
var defaults = _.extend({
exclude : [/\.min\./]
}, grunt.config('strip')._options);
grunt.verbose.writeflags(options, 'Options');
var done = this.async();
var src = grunt.file.expandFiles(this.file.src).filter(function(file) {
for(var i = 0; i < defaults.exclude.length; i++) {
if(defaults.exclude[i].test(file)) {
return false;
}
}
return true;
});
docco.document(src, options.docco || {}, function(err, result, code){
grunt.log.writeln("Doccoed [" + src.join(", ") + "]; " + err ? err : "(No errors)" + "\n" + result + " " + code);
done();
});
});
}
var options = grunt.config.process(['docco', this.target]);
var defaults = _.extend({
exclude : [/\.min\./]
}, grunt.config.process('docco')._options);
grunt.verbose.writeflags(options, 'Options');
var done = this.async();
var src = grunt.file.expandFiles(this.file.src).filter(function(file) {
for(var i = 0; i < defaults.exclude.length; i++) {
if(defaults.exclude[i].test(file)) {
return false;
}
}
return true;
});
docco.document(src, _.extend({}, defaults.docco, options.docco) || {}, function(err, result, code){
grunt.log.writeln("Doccoed [" + src.join(", ") + "]; " + err ? err : "(No errors)" + "\n" + result + " " + code);
done();
});
});
}
function buildDoc(done) {
var dest = 'doc/annotated-source/';
var sources = glob.sync('src/parsley/*.js');
del.sync([dest + '*']);
docco.document({
layout: 'parallel',
output: dest,
args: sources
}, function() {
gulp.src(dest + '*.html', { base: "./" })
.pipe($.replace('<div id="jump_page">', '<div id="jump_page"><a href="../index.html" class="source"><<< back to documentation</a>'))
.pipe($.replace('', ''))
.pipe(gulp.dest('.'))
.on('end', done);
});
}
</div></div>
document : function(menu, callback) {
docco.document(this.doccoFiles(), this.doccoOptions(), function() {
callback(undefined, menu);
});
},
this.files.forEach(function(file) {
docco.document(task.options({ output: file.dest, args: file.src }), function(){
if(++fdone === flength){
done();
}
});
});
});
function buildDoc(done) {
var dest = 'doc/annotated-source/';
var sources = glob.sync('src/parsley/*.js');
del.sync([dest + '*']);
docco.document({
layout: 'parallel',
output: dest,
args: sources
}, function() {
gulp.src(dest + '*.html', { base: "./" })
.pipe($.replace('<div id="jump_page">', '<div id="jump_page"><a href="../index.html" class="source"><<< back to documentation</a>'))
.pipe($.replace('', ''))
.pipe(gulp.dest('.'))
.on('end', done);
});
}
</div></div>
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 = "../";