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

Side by Side Diff: tools/dom/docs/lib/docs.dart

Issue 13000005: Added tests for docs.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
1 /** 5 /**
2 * A library for extracting the documentation from the various HTML libraries 6 * A library for extracting the documentation from the various HTML libraries
3 * ([dart:html], [dart:svg], [dart:web_audio], [dart:indexed_db]) and saving 7 * ([dart:html], [dart:svg], [dart:web_audio], [dart:indexed_db]) and saving
4 * those documentation comments to a JSON file. 8 * those documentation comments to a JSON file.
5 */ 9 */
6 10
7 library docs; 11 library docs;
8 12
9 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mi rror.dart'; 13 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mi rror.dart';
10 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.da rt'; 14 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.da rt';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 */ 52 */
49 Future<bool> convert(Path libPath, Path jsonPath) { 53 Future<bool> convert(Path libPath, Path jsonPath) {
50 var paths = <Path>[]; 54 var paths = <Path>[];
51 for (var libraryName in HTML_LIBRARY_NAMES) { 55 for (var libraryName in HTML_LIBRARY_NAMES) {
52 paths.add(new Path(libraryName)); 56 paths.add(new Path(libraryName));
53 } 57 }
54 58
55 return analyze(paths, libPath, options: ['--preserve-comments']) 59 return analyze(paths, libPath, options: ['--preserve-comments'])
56 .then((MirrorSystem mirrors) { 60 .then((MirrorSystem mirrors) {
57 var convertedJson = _generateJsonFromLibraries(mirrors); 61 var convertedJson = _generateJsonFromLibraries(mirrors);
58 return new Future.immediate(_exportJsonToFile(convertedJson, jsonPath)); 62 return _exportJsonToFile(convertedJson, jsonPath);
59 }); 63 });
60 } 64 }
61 65
62 bool _exportJsonToFile(Map convertedJson, Path jsonPath) { 66 Future<bool> _exportJsonToFile(Map convertedJson, Path jsonPath) {
Bob Nystrom 2013/03/28 14:18:40 This method does both sync and async IO, which mea
Andrei Mouravski 2013/03/28 17:01:14 Done.
63 final jsonFile = new File.fromPath(jsonPath); 67 final jsonFile = new File.fromPath(jsonPath);
64 var writeJson = prettySerialize(convertedJson); 68 var writeJson = prettySerialize(convertedJson);
65 69
66 var outputStream = jsonFile.openWrite(); 70 var outputStream = jsonFile.openWrite();
67 outputStream.writeln(writeJson); 71 outputStream.writeln(writeJson);
68 72 outputStream.close();
69 return false; 73 return outputStream.done.then((_) => false);
70 } 74 }
71 75
72 Map _generateJsonFromLibraries(MirrorSystem mirrors) { 76 Map _generateJsonFromLibraries(MirrorSystem mirrors) {
73 var convertedJson = {}; 77 var convertedJson = {};
74 78
75 // Sort the libraries by name (not key). 79 // Sort the libraries by name (not key).
76 var sortedLibraries = new List<LibraryMirror>.from( 80 var sortedLibraries = new List<LibraryMirror>.from(
77 mirrors.libraries.values.where( 81 mirrors.libraries.values.where(
78 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0)) 82 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
79 ..sort((x, y) => 83 ..sort((x, y) =>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for (var s in tags.reflectee.split(',')) { 181 for (var s in tags.reflectee.split(',')) {
178 domNames.add(s.trim()); 182 domNames.add(s.trim());
179 } 183 }
180 184
181 if (domNames.length == 1 && domNames[0] == 'none') return <String>[]; 185 if (domNames.length == 1 && domNames[0] == 'none') return <String>[];
182 return domNames; 186 return domNames;
183 } else { 187 } else {
184 return <String>[]; 188 return <String>[];
185 } 189 }
186 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698