aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests
diff options
context:
space:
mode:
authorAlec Perkins2012-09-09 17:25:34 -0400
committerAlec Perkins2012-09-09 17:27:24 -0400
commit4cbc53a75d2d30d05f202777d4e1626011c2cb2e (patch)
tree8d1d54514df5ed48fc7bcc6ae77cca189171c382 /djangorestframework/tests
parent9684b3fe22d731eb84f67877ab94ee74c8761a01 (diff)
downloaddjango-rest-framework-4cbc53a75d2d30d05f202777d4e1626011c2cb2e.tar.bz2
Whoops, forgot to explain these.
Diffstat (limited to 'djangorestframework/tests')
0 files changed, 0 insertions, 0 deletions
function collect(callback){ findJsFiles('src', callback.waitMany(function(file) { //console.log('reading', file, '...'); findNgDocInJsFile(file, callback.waitMany(function(doc, line) { callback(doc, file, line); })); })); findNgDocInDir('docs/', callback.waitMany(callback)); callback.done(); } function findJsFiles(dir, callback){ fs.readdir(dir, callback.waitFor(function(err, files){ if (err) return this.error(err); files.forEach(function(file){ var path = dir + '/' + file; fs.lstat(path, callback.waitFor(function(err, stat){ if (err) return this.error(err); if (stat.isDirectory()) findJsFiles(path, callback.waitMany(callback)); else if (/\.js$/.test(path)) callback(path); })); }); callback.done(); })); } function findNgDocInDir(directory, docNotify) { fs.readdir(directory, docNotify.waitFor(function(err, files){ if (err) return this.error(err); files.forEach(function(file){ //console.log('reading', directory + file, '...'); if (!file.match(/\.ngdoc$/)) return; fs.readFile(directory + file, docNotify.waitFor(function(err, content){ if (err) return this.error(err); docNotify(content.toString(), directory + file, 1); })); }); docNotify.done(); })); } function findNgDocInJsFile(file, callback) { fs.readFile(file, callback.waitFor(function(err, content){ var lines = content.toString().split(NEW_LINE); var text; var startingLine ; var match; var inDoc = false; lines.forEach(function(line, lineNumber){ lineNumber++; // is the comment starting? if (!inDoc && (match = line.match(/^\s*\/\*\*\s*(.*)$/))) { line = match[1]; inDoc = true; text = []; startingLine = lineNumber; } // are we done? if (inDoc && line.match(/\*\//)) { text = text.join('\n'); text = text.replace(/^\n/, ''); if (text.match(/@ngdoc/)){ callback(text, startingLine); } doc = null; inDoc = false; } // is the comment add text if (inDoc){ text.push(line.replace(/^\s*\*\s?/, '')); } }); callback.done(); })); } exports.collect = collect;