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

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
« no previous file with comments | « tools/dom/docs/docs.status ('k') | tools/dom/docs/test/docs_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
63 final jsonFile = new File.fromPath(jsonPath); 67 return new Future.of(() {
64 var writeJson = prettySerialize(convertedJson); 68 final jsonFile = new File.fromPath(jsonPath);
69 var writeJson = prettySerialize(convertedJson);
65 70
66 var outputStream = jsonFile.openWrite(); 71 var outputStream = jsonFile.openWrite();
67 outputStream.writeln(writeJson); 72 outputStream.writeln(writeJson);
68 73 outputStream.close();
69 return false; 74 return outputStream.done.then((_) => false);
75 });
70 } 76 }
71 77
72 Map _generateJsonFromLibraries(MirrorSystem mirrors) { 78 Map _generateJsonFromLibraries(MirrorSystem mirrors) {
73 var convertedJson = {}; 79 var convertedJson = {};
74 80
75 // Sort the libraries by name (not key). 81 // Sort the libraries by name (not key).
76 var sortedLibraries = new List<LibraryMirror>.from( 82 var sortedLibraries = new List<LibraryMirror>.from(
77 mirrors.libraries.values.where( 83 mirrors.libraries.values.where(
78 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0)) 84 (e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
79 ..sort((x, y) => 85 ..sort((x, y) =>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for (var s in tags.reflectee.split(',')) { 183 for (var s in tags.reflectee.split(',')) {
178 domNames.add(s.trim()); 184 domNames.add(s.trim());
179 } 185 }
180 186
181 if (domNames.length == 1 && domNames[0] == 'none') return <String>[]; 187 if (domNames.length == 1 && domNames[0] == 'none') return <String>[];
182 return domNames; 188 return domNames;
183 } else { 189 } else {
184 return <String>[]; 190 return <String>[];
185 } 191 }
186 } 192 }
OLDNEW
« no previous file with comments | « tools/dom/docs/docs.status ('k') | tools/dom/docs/test/docs_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698