@@ -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