@@ -9,48 +9,49 @@ var templates = {
9
9
markdown : require ( '../templates/markdown.hbs' )
10
10
} ;
11
11
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 ) {
18
13
19
- if ( exists ) {
14
+ if ( fs . existsSync ( file ) ) {
20
15
21
- data = dox . parseComments ( fs . readFileSync ( script , 'utf8' ) ) ;
16
+ exports . parseScript ( fs . readFileSync ( file , 'utf8' ) , output , config ) ;
22
17
23
- if ( templates [ config . layout ] ) {
18
+ } else {
24
19
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' ) ;
30
21
31
- if ( output ) {
22
+ }
32
23
33
- fs . writeFileSync ( output , content , 'utf8' ) ;
24
+ }
34
25
35
- } else {
26
+ exports . parseScript = function ( script , output , config ) {
36
27
37
- process . stdout . write ( content ) ;
28
+ var content ,
29
+ data = dox . parseComments ( script ) ;
38
30
39
- }
31
+ if ( templates [ config . layout ] ) {
40
32
41
- } else {
33
+ content = templates [ config . layout ] ( {
34
+ title : config . title ,
35
+ description : config . description ,
36
+ methods : utils . parseData ( data )
37
+ } ) ;
42
38
43
- process . stdout . write ( 'Invalid layout specified.' + '\n' ) ;
39
+ if ( output ) {
44
40
45
- }
41
+ fs . writeFileSync ( output , content , 'utf8' ) ;
46
42
47
43
} else {
48
44
49
- process . stdout . write ( 'File not found.' + '\n' ) ;
45
+ process . stdout . write ( content ) ;
46
+
47
+ return content ;
50
48
51
49
}
52
50
53
- } ) ;
51
+ } else {
54
52
55
- }
53
+ process . stdout . write ( 'Invalid layout specified.' + '\n' ) ;
56
54
55
+ }
56
+
57
+ }
0 commit comments