1 | #!/usr/bin/env node
|
2 |
|
3 | const debug = require('debug');
|
4 | const program = require('commander');
|
5 | const path = require('path');
|
6 | const spawn = require('child_process').spawn;
|
7 | const Firedoc = require('../lib/firedoc').Firedoc;
|
8 |
|
9 | program
|
10 | .option('-l --lint', 'lint the parser')
|
11 | .option('--parse-only', 'only parse')
|
12 | .option('-M --markdown', 'generate markdown docs')
|
13 | .option('-T --theme <dir>', 'specify theme directory')
|
14 | .option('-D --dest <dir>', 'the destination folder to build')
|
15 | .option('-L --lang <language>', 'the i18n language')
|
16 | .option('-v --verbose', 'print all verbose information')
|
17 | .parse(process.argv);
|
18 |
|
19 | if (program.verbose) {
|
20 | debug.enable('firedoc:*');
|
21 | }
|
22 |
|
23 | var doc = new Firedoc({
|
24 | path: program.args[0],
|
25 | lint: program.lint,
|
26 | parseOnly: program.parseOnly,
|
27 | markdown: program.markdown,
|
28 | http: true,
|
29 | dest: program.dest,
|
30 | lang: program.lang,
|
31 | theme: program.theme
|
32 | });
|
33 | doc.build(onbuild);
|
34 |
|
35 | function onbuild () {
|
36 | var serve = path.join(__dirname, '../node_modules/.bin/serve');
|
37 | spawn(serve, [doc.options.dest, '-H'], {
|
38 | 'stdio': 'inherit'
|
39 | });
|
40 | }
|
41 |
|