Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: tools/dom/docs/lib/docs.dart

Issue 13116021: Fix docs.dart, which has been sad and neglected. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/dom/docs/bin/docs.dart ('K') | « tools/dom/docs/docs.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/docs/lib/docs.dart
diff --git a/tools/dom/docs/lib/docs.dart b/tools/dom/docs/lib/docs.dart
index 9e89782db6c520a7b429dd863e6593057a703d63..e4606ff259e787af36fb5302b6fb2fc9042cf990 100644
--- a/tools/dom/docs/lib/docs.dart
+++ b/tools/dom/docs/lib/docs.dart
@@ -6,9 +6,10 @@
library docs;
+import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart';
import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
-import '../../../../sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart';
import '../../../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart';
+import '../../../../sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart';
import '../../../../utils/apidoc/lib/metadata.dart';
import 'dart:async';
import 'dart:io';
@@ -43,41 +44,37 @@ const List<String> HTML_LIBRARY_NAMES = const ['dart:html',
* ...
* }
*
- * Returns `true` if any errors were encountered, `false` otherwise.
+ * Completes to `true` if any errors were encountered, `false` otherwise.
*/
-bool convert(Path libPath, Path jsonPath) {
+Future<bool> convert(Path libPath, Path jsonPath) {
var paths = <Path>[];
for (var libraryName in HTML_LIBRARY_NAMES) {
paths.add(new Path(libraryName));
}
- // TODO(amouravski): Account for errors in compilation.
- final compilation = new Compilation.library(paths, libPath, null,
- ['--preserve-comments']);
-
- var convertedJson = _generateJsonFromLibraries(compilation);
-
- var anyErrors = _exportJsonToFile(convertedJson, jsonPath);
-
- return anyErrors;
+ return analyze(paths, libPath, options: ['--preserve-comments'])
+ .then((MirrorSystem mirrors) {
+ var convertedJson = _generateJsonFromLibraries(mirrors);
+ return new Future.immediate(_exportJsonToFile(convertedJson, jsonPath));
+ });
}
bool _exportJsonToFile(Map convertedJson, Path jsonPath) {
final jsonFile = new File.fromPath(jsonPath);
var writeJson = prettySerialize(convertedJson);
- var outputStream = jsonFile.openOutputStream();
- outputStream.writeString(writeJson);
+ var outputStream = jsonFile.openWrite();
+ outputStream.writeln(writeJson);
return false;
}
-Map _generateJsonFromLibraries(Compilation compilation) {
+Map _generateJsonFromLibraries(MirrorSystem mirrors) {
var convertedJson = {};
// Sort the libraries by name (not key).
var sortedLibraries = new List<LibraryMirror>.from(
- compilation.mirrors.libraries.values.where(
+ mirrors.libraries.values.where(
(e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
..sort((x, y) =>
x.uri.toString().toUpperCase().compareTo(
« tools/dom/docs/bin/docs.dart ('K') | « tools/dom/docs/docs.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698