@@ -28,6 +28,7 @@ var assert = require('assert'),
28
28
vm = require ( 'vm' ) ;
29
29
30
30
var optparse = require ( './optparse' ) ;
31
+ var gendocs = require ( './gendocs' ) ;
31
32
32
33
33
34
/**
@@ -121,71 +122,6 @@ function copyResources(outputDirPath, resources, exclusions) {
121
122
}
122
123
123
124
124
- function generateDocs ( outputDir , callback ) {
125
- var libDir = path . join ( outputDir , 'lib' ) ;
126
-
127
- var excludedDirs = [
128
- path . join ( outputDir , 'example' ) ,
129
- path . join ( libDir , 'test' ) ,
130
- path . join ( outputDir , 'test' )
131
- ] ;
132
-
133
- var excludedFiles = [
134
- path . join ( libDir , 'safari/client.js' ) ,
135
- ] ;
136
-
137
- var endsWith = function ( str , suffix ) {
138
- var l = str . length - suffix . length ;
139
- return l >= 0 && str . indexOf ( suffix , l ) == l ;
140
- } ;
141
-
142
- var getFiles = function ( dir ) {
143
- var files = [ ] ;
144
- fs . readdirSync ( dir ) . forEach ( function ( file ) {
145
- file = path . join ( dir , file ) ;
146
- if ( fs . statSync ( file ) . isDirectory ( ) &&
147
- excludedDirs . indexOf ( file ) == - 1 ) {
148
- files = files . concat ( getFiles ( file ) ) ;
149
- } else if ( endsWith ( path . basename ( file ) , '.js' ) &&
150
- excludedFiles . indexOf ( file ) == - 1 ) {
151
- files . push ( file ) ;
152
- }
153
- } ) ;
154
- return files ;
155
- } ;
156
-
157
- var moduleFiles = getFiles ( outputDir ) . filter ( function ( file ) {
158
- return file . indexOf ( path . join ( outputDir , 'test' ) ) == - 1 ;
159
- } ) ;
160
-
161
- var output = outputDir + '-docs' ;
162
- var config = {
163
- 'output' : output ,
164
- 'customPages' : [
165
- { 'name' : 'Changes' , 'path' : path . join ( outputDir , 'CHANGES.md' ) }
166
- ] ,
167
- 'readme' : path . join ( outputDir , 'README.md' ) ,
168
- 'language' : 'ES6_STRICT' ,
169
- 'modules' : moduleFiles ,
170
- 'excludes' : [
171
- path . join ( outputDir , 'docs' ) ,
172
- path . join ( outputDir , 'node_modules' )
173
- ] ,
174
- 'typeFilters' : [ 'goog' ]
175
- } ;
176
-
177
- var configFile = output + '.json' ;
178
- fs . writeFileSync ( configFile , JSON . stringify ( config ) , 'utf8' ) ;
179
-
180
- var command = [
181
- 'java -jar' , path . join (
182
- __dirname , '../../third_party/java/dossier/dossier-0.7.2.jar' ) ,
183
- '-c' , configFile
184
- ] . join ( ' ' ) ;
185
- child_process . exec ( command , callback ) ;
186
- }
187
-
188
-
189
125
function main ( ) {
190
126
var parser = new optparse . OptionParser ( ) .
191
127
path ( 'output' , { help : 'Path to the output directory' } ) .
@@ -219,9 +155,8 @@ function main() {
219
155
console . log ( 'Copying resource files...' ) ;
220
156
copyResources ( options . output , options . resource , options . exclude_resource ) ;
221
157
console . log ( 'Generating documentation...' ) ;
222
- generateDocs ( options . output , function ( e ) {
223
- if ( e ) throw e ;
224
- console . log ( 'ALL DONE' ) ;
158
+ gendocs ( ) . then ( ( ) => console . log ( 'ALL DONE' ) , function ( e ) {
159
+ setTimeout ( ( ) => { throw e } , 0 ) ;
225
160
} ) ;
226
161
}
227
162
0 commit comments