Skip to content

Commit 282daf8

Browse files
committed
Split parseScript into two methods.
1 parent 96cdea9 commit 282daf8

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

bin/doxdox

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ var config = {
1010
layout: 'bootstrap'
1111
};
1212

13-
var script = '',
13+
var file = '',
1414
output = '';
1515

1616
var args = process.argv.slice(2),
1717
value;
1818

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

21-
script = args.shift();
21+
file = args.shift();
2222

2323
}
2424

@@ -76,4 +76,4 @@ while (args.length) {
7676

7777
}
7878

79-
doxdox.parseScript(script, output, config);
79+
doxdox.parseFile(file, output, config);

lib/doxdox.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,49 @@ var templates = {
99
markdown: require('../templates/markdown.hbs')
1010
};
1111

12-
exports.parseScript = function (script, output, config) {
13-
14-
fs.exists(script, function (exists) {
15-
16-
var content,
17-
data;
12+
exports.parseFile = function (file, output, config) {
1813

19-
if (exists) {
14+
if (fs.existsSync(file)) {
2015

21-
data = dox.parseComments(fs.readFileSync(script, 'utf8'));
16+
exports.parseScript(fs.readFileSync(file, 'utf8'), output, config);
2217

23-
if (templates[config.layout]) {
18+
} else {
2419

25-
content = templates[config.layout]({
26-
title: config.title,
27-
description: config.description,
28-
methods: utils.parseData(data)
29-
});
20+
process.stdout.write('File not found.' + '\n');
3021

31-
if (output) {
22+
}
3223

33-
fs.writeFileSync(output, content, 'utf8');
24+
}
3425

35-
} else {
26+
exports.parseScript = function (script, output, config) {
3627

37-
process.stdout.write(content);
28+
var content,
29+
data = dox.parseComments(script);
3830

39-
}
31+
if (templates[config.layout]) {
4032

41-
} else {
33+
content = templates[config.layout]({
34+
title: config.title,
35+
description: config.description,
36+
methods: utils.parseData(data)
37+
});
4238

43-
process.stdout.write('Invalid layout specified.' + '\n');
39+
if (output) {
4440

45-
}
41+
fs.writeFileSync(output, content, 'utf8');
4642

4743
} else {
4844

49-
process.stdout.write('File not found.' + '\n');
45+
process.stdout.write(content);
46+
47+
return content;
5048

5149
}
5250

53-
});
51+
} else {
5452

55-
}
53+
process.stdout.write('Invalid layout specified.' + '\n');
5654

55+
}
56+
57+
}

0 commit comments

Comments
 (0)