OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
8 * | 8 * |
9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
10 * | 10 * |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 var libDir = parts.lastIndexOf('lib'); | 225 var libDir = parts.lastIndexOf('lib'); |
226 if (libDir > 0) { | 226 if (libDir > 0) { |
227 pkgPath = new Path(path.join(path.joinAll(parts.take(libDir - 1)), | 227 pkgPath = new Path(path.join(path.joinAll(parts.take(libDir - 1)), |
228 'packages')); | 228 'packages')); |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 cleanOutputDirectory(dartdoc.outputDir); | 233 cleanOutputDirectory(dartdoc.outputDir); |
234 | 234 |
235 dartdoc.documentLibraries(entrypoints, libPath, pkgPath); | 235 print('Analyzing sources'); |
| 236 Future documented = dartdoc.documentLibraries(entrypoints, libPath, pkgPath); |
236 | 237 |
237 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); | 238 documented.then((_) { |
238 Future filesCopied = copyDirectory(scriptDir.append('../static'), | 239 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); |
239 dartdoc.outputDir); | 240 Future filesCopied = copyDirectory(scriptDir.append('../static'), |
| 241 dartdoc.outputDir); |
240 | 242 |
241 Future.wait([compiled, filesCopied]).then((futureStatus) { | 243 Future.wait([compiled, filesCopied]).then((_) { |
| 244 dartdoc.cleanup(); |
| 245 if (dartdoc.totalLibraries + dartdoc.totalTypes + |
| 246 dartdoc.totalMembers == 0) { |
| 247 print('Nothing was documented!'); |
| 248 exit(1); |
| 249 } else { |
| 250 print('Documented ${dartdoc.totalLibraries} libraries, ' |
| 251 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} ' |
| 252 'members.'); |
| 253 } |
| 254 }); |
| 255 }, onError: (AsyncError asyncError) { |
| 256 print('Generation failed: ${asyncError.error}'); |
242 dartdoc.cleanup(); | 257 dartdoc.cleanup(); |
243 | |
244 if (dartdoc.totalLibraries + dartdoc.totalTypes + | |
245 dartdoc.totalMembers == 0) { | |
246 print('Nothing was documented!'); | |
247 exit(1); | |
248 } else { | |
249 print('Documented ${dartdoc.totalLibraries} libraries, ' | |
250 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} ' | |
251 'members.'); | |
252 } | |
253 }); | 258 }); |
254 } | 259 } |
OLD | NEW |