|
|
@ -9,32 +9,37 @@ var doc = [ |
|
|
' docast (-h | --help)', |
|
|
' docast (-h | --help)', |
|
|
' docast (-v | --version)', |
|
|
' docast (-v | --version)', |
|
|
' docast extract [-o <output>] <input_files>...', |
|
|
' docast extract [-o <output>] <input_files>...', |
|
|
' docast generate <formatter> <input_files>...', |
|
|
|
|
|
|
|
|
' docast generate [-f <formatter>] [-b <output>] <input_files>...', |
|
|
'', |
|
|
'', |
|
|
'Options:', |
|
|
'Options:', |
|
|
' -h --help Show this help text', |
|
|
|
|
|
' -v --version Show docast version information', |
|
|
|
|
|
|
|
|
' -h --help Show this help text', |
|
|
|
|
|
' -v --version Show docast version information', |
|
|
'Extract:', |
|
|
'Extract:', |
|
|
' Parse docs from javascript files and output as json to a file', |
|
|
' Parse docs from javascript files and output as json to a file', |
|
|
' -o --output <output> File to output to [default: out.json]', |
|
|
|
|
|
' <input_files> List of javascript files to fetch docs from', |
|
|
|
|
|
|
|
|
' -o --output <output> File to output to [default: out.json]', |
|
|
|
|
|
' <input_files> List of javascript files to fetch docs from', |
|
|
'Generate:', |
|
|
'Generate:', |
|
|
' Provide a script used to generate documentation from the parsed docs', |
|
|
' Provide a script used to generate documentation from the parsed docs', |
|
|
' <formatter> Script which exports a `function(comments)` used to generate docs from comments', |
|
|
|
|
|
' <input_files> List of javascript files to fetch docs from', |
|
|
|
|
|
|
|
|
' -b --build <output> Folderto output to [default: build]', |
|
|
|
|
|
' -f --formatter <formatter> Script to import as formatter, default uses internal', |
|
|
|
|
|
' <input_files> List of javascript files to fetch docs from', |
|
|
].join('\r\n'); |
|
|
].join('\r\n'); |
|
|
|
|
|
|
|
|
var args = docopt.docopt(doc, {version: require('../package.json').version}); |
|
|
var args = docopt.docopt(doc, {version: require('../package.json').version}); |
|
|
|
|
|
|
|
|
var comments = []; |
|
|
|
|
|
|
|
|
var comments = {}; |
|
|
args['<input_files>'].forEach(function(file){ |
|
|
args['<input_files>'].forEach(function(file){ |
|
|
comments = comments.concat(docast.parse(file)); |
|
|
|
|
|
|
|
|
comments[file] = docast.parse(file); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if(args.extract){ |
|
|
if(args.extract){ |
|
|
fs.writeFileSync(args['--output'], JSON.stringify(comments)); |
|
|
fs.writeFileSync(args['--output'], JSON.stringify(comments)); |
|
|
} else if(args.generate){ |
|
|
} else if(args.generate){ |
|
|
var loc = path.join(process.cwd(), args['<formatter>']); |
|
|
|
|
|
var formatter = require(loc); |
|
|
|
|
|
formatter(comments); |
|
|
|
|
|
|
|
|
var options = {build: args['--build']}; |
|
|
|
|
|
var formatter = new docast.formatter(options); |
|
|
|
|
|
if(args['--formatter']){ |
|
|
|
|
|
var loc = path.join(process.cwd(), args['--formatter']); |
|
|
|
|
|
formatter = new (require(loc))(options); |
|
|
|
|
|
} |
|
|
|
|
|
formatter.format(comments); |
|
|
} |
|
|
} |