Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (40 sloc) 1.231 kB
#!/usr/bin/env node
/**
* Module dependencies.
*/
var program = require('commander')
, util = require('util')
, dox = require('..');
// options
program
.version(dox.version)
.option('-r, --raw', 'output "raw" comments, leaving the markdown intact')
.option('-a, --api', 'output markdown readme documentation')
.option('-d, --debug', 'output parsed comments for debugging');
// examples
program.on('--help', function(){
console.log(' Examples:');
console.log('');
console.log(' # stdin');
console.log(' $ dox > myfile.json');
console.log('');
console.log(' # operates over stdio');
console.log(' $ dox < myfile.js > myfile.json');
console.log('');
});
// parse argv
program.parse(process.argv);
// process stdin
var buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){ buf += chunk; });
process.stdin.on('end', function(){
var obj = dox.parseComments(buf, { raw: program.raw || program.api });
if (program.debug) {
process.stdout.write(util.inspect(obj, false, Infinity, true) + '\n');
} else if (program.api) {
process.stdout.write(dox.api(obj));
} else {
process.stdout.write(JSON.stringify(obj, null, 2));
}
}).resume();
Jump to Line
Something went wrong with that request. Please try again.