Skip to content

Commit af0cfcd

Browse files
committed
Added output flag.
Updated README.
1 parent 13b7d9e commit af0cfcd

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![](https://david-dm.org/neogeek/doxdox.svg)](https://david-dm.org/neogeek/doxdox/) ![](http://img.shields.io/npm/v/doxdox.svg)
1+
[![](https://david-dm.org/neogeek/doxdox.svg)](https://david-dm.org/neogeek/doxdox/) [![](http://img.shields.io/npm/v/doxdox.svg)](https://www.npmjs.org/package/doxdox)
22

33
#doxdox
44

@@ -24,6 +24,7 @@ $ npm install doxdox -g
2424
-t, --title Sets title.
2525
-d, --description Sets description.
2626
-l, --layout Template to render the documentation with.
27+
-o, --output File to save documentation to. Default to stdout.
2728

2829
Available Layouts:
2930

bin/doxdox

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ var templates = {
1515
var title = 'Untitled Project',
1616
description = '',
1717
layout = 'bootstrap',
18-
filename = '';
18+
script = '',
19+
output = '';
1920

2021
var args = process.argv.slice(2),
2122
value;
2223

2324
if (args.length && !args[0].match(/^\-/)) {
2425

25-
filename = args.shift();
26+
script = args.shift();
2627

2728
}
2829

@@ -47,6 +48,11 @@ while (args.length) {
4748
layout = args.shift();
4849
break;
4950

51+
case '-o':
52+
case '--output':
53+
output = args.shift();
54+
break;
55+
5056
case '-v':
5157
case '--version':
5258
process.stdout.write(pkg.version + '\n');
@@ -62,6 +68,7 @@ while (args.length) {
6268
process.stdout.write(' -t, --title\t\tSets title.' + '\n');
6369
process.stdout.write(' -d, --description\tSets description.' + '\n');
6470
process.stdout.write(' -l, --layout\t\tTemplate to render the documentation with.' + '\n');
71+
process.stdout.write(' -o, --output\t\tFile to save documentation to. Default to stdout.' + '\n');
6572
process.stdout.write('\n');
6673
process.stdout.write(' Available Layouts:' + '\n\n');
6774
process.stdout.write(' - Bootstrap (default)\t\t(http://getbootstrap.com/)' + '\n');
@@ -74,21 +81,32 @@ while (args.length) {
7481

7582
}
7683

77-
fs.exists(filename, function (exists) {
84+
fs.exists(script, function (exists) {
7885

79-
var data;
86+
var content,
87+
data;
8088

8189
if (exists) {
8290

83-
data = dox.parseComments(fs.readFileSync(filename, 'utf8'));
91+
data = dox.parseComments(fs.readFileSync(script, 'utf8'));
8492

8593
if (templates[layout]) {
8694

87-
process.stdout.write(templates[layout]({
95+
content = templates[layout]({
8896
title: title,
8997
description: description,
9098
methods: utils.parseData(data)
91-
}));
99+
});
100+
101+
if (output) {
102+
103+
fs.writeFileSync(output, content, 'utf8');
104+
105+
} else {
106+
107+
process.stdout.write(content);
108+
109+
}
92110

93111
} else {
94112

0 commit comments

Comments
 (0)