Index: sdk/lib/_internal/dartdoc/bin/dartdoc.dart |
diff --git a/sdk/lib/_internal/dartdoc/bin/dartdoc.dart b/sdk/lib/_internal/dartdoc/bin/dartdoc.dart |
index e55424d831888042d258cda58854464834536682..3c906bfc98d840a58eb3ba701faa1111fb566122 100644 |
--- a/sdk/lib/_internal/dartdoc/bin/dartdoc.dart |
+++ b/sdk/lib/_internal/dartdoc/bin/dartdoc.dart |
@@ -16,13 +16,14 @@ |
*/ |
library dartdoc; |
-import 'dart:io'; |
import 'dart:async'; |
+import 'dart:io'; |
-// TODO(rnystrom): Use "package:" URL (#4968). |
import '../lib/dartdoc.dart'; |
-import '../../../../../pkg/pathos/lib/path.dart' as path; |
+ |
+// TODO(rnystrom): Use "package:" URL (#4968). |
import '../../../../../pkg/args/lib/args.dart'; |
+import '../../../../../pkg/pathos/lib/path.dart' as path; |
/** |
* Run this from the `lib/_internal/dartdoc` directory. |
@@ -224,7 +225,7 @@ main() { |
var parts = path.split(dir); |
var libDir = parts.lastIndexOf('lib'); |
if (libDir > 0) { |
- pkgPath = new Path(path.join(path.joinAll(parts.take(libDir - 1)), |
+ pkgPath = new Path(path.join(path.joinAll(parts.take(libDir)), |
'packages')); |
} |
} |
@@ -232,29 +233,27 @@ main() { |
cleanOutputDirectory(dartdoc.outputDir); |
- print('Analyzing sources'); |
- Future documented = dartdoc.documentLibraries(entrypoints, libPath, pkgPath); |
- |
- documented.then((_) { |
- Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); |
- Future filesCopied = copyDirectory(scriptDir.append('../static'), |
- dartdoc.outputDir); |
- |
- Future.wait([compiled, filesCopied]).then((_) { |
- dartdoc.cleanup(); |
- if (dartdoc.totalLibraries + dartdoc.totalTypes + |
- dartdoc.totalMembers == 0) { |
- print('Nothing was documented!'); |
+ // Start the analysis and documentation. |
+ dartdoc.documentLibraries(entrypoints, libPath, pkgPath) |
+ .then((_) { |
+ print('Copying static files...'); |
+ Future.wait([ |
+ // Prepare the dart2js script code and copy static resources. |
+ // TODO(amouravski): move compileScript out and pre-generate the client |
+ // scripts. This takes a long time and the js hardly ever changes. |
+ compileScript(dartdoc.mode, dartdoc.outputDir, libPath), |
+ copyDirectory(scriptDir.append('../static'), dartdoc.outputDir) |
+ ]); |
+ }) |
+ .then((_) { |
+ print(dartdoc.status); |
+ if (dartdoc.totals == 0) { |
exit(1); |
- } else { |
- print('Documented ${dartdoc.totalLibraries} libraries, ' |
- '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} ' |
- 'members.'); |
} |
- }); |
- }, onError: (AsyncError asyncError) { |
- print('Generation failed: ${asyncError.error}'); |
- dartdoc.cleanup(); |
- exit(1); |
- }); |
+ }) |
+ .catchError((e) { |
+ print('Error: generation failed: ${e.error}'); |
+ exit(1); |
+ }) |
+ .whenComplete(() => dartdoc.cleanup()); |
} |