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

Side by Side Diff: tools/html_json_doc/lib/json_to_html.dart

Issue 11413197: Updated json_to_html to be sync. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more try. Created 8 years 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 | « sdk/lib/html/docs/html_docs.json ('k') | no next file » | 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) 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 * Library for taking a JSON file and putting the comments located within into 6 * Library for taking a JSON file and putting the comments located within into
7 * the HTML files the comments are associated with. 7 * the HTML files the comments are associated with.
8 * 8 *
9 * The format of the JSON file is: 9 * The format of the JSON file is:
10 * 10 *
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 _anyErrors = true; 59 _anyErrors = true;
60 completer.complete(false); 60 completer.complete(false);
61 } else { 61 } else {
62 fileJson = JSON.parse(jsonRead); 62 fileJson = JSON.parse(jsonRead);
63 } 63 }
64 64
65 // TODO(amouravski): Refactor to not duplicate code here and in html-to-json. 65 // TODO(amouravski): Refactor to not duplicate code here and in html-to-json.
66 // Find html files. (lister) 66 // Find html files. (lister)
67 final lister = htmlDir.list(recursive: false); 67 final lister = htmlDir.list(recursive: false);
68 68
69 var pathList = <Path>[];
Adam 2012/11/28 00:13:45 Path should be type String since lister.OnFile pas
Andrei Mouravski 2012/11/28 00:28:34 Done.
69 lister.onFile = (String path) { 70 lister.onFile = (String path) {
71 pathList.add(path);
72 };
73
74 getFile(Path path) {
Adam 2012/11/28 00:13:45 Path.fromNative takes a String type not Path
Andrei Mouravski 2012/11/28 00:28:34 Done.
70 final name = new Path.fromNative(path).filename; 75 final name = new Path.fromNative(path).filename;
71 76
72 // Ignore private classes. 77 // Ignore private classes.
73 if (name.startsWith('_')) return; 78 if (name.startsWith('_')) return;
74 79
75 // Ignore non-dart files. 80 // Ignore non-dart files.
76 if (!name.endsWith('.dart')) return; 81 if (!name.endsWith('.dart')) return;
77 82
78 File file = new File(path); 83 File file = new File(path);
79 84
(...skipping 11 matching lines...) Expand all
91 } 96 }
92 97
93 var comments = fileJson[name]; 98 var comments = fileJson[name];
94 99
95 _convertFile(file, comments); 100 _convertFile(file, comments);
96 101
97 fileJson.remove(name); 102 fileJson.remove(name);
98 }; 103 };
99 104
100 lister.onDone = (_) { 105 lister.onDone = (_) {
106 while(!pathList.isEmpty) {
107 getFile(pathList.removeLast());
108 }
101 109
102 fileJson.forEach((key, _) { 110 fileJson.forEach((key, _) {
103 print('WARNING: the following filename was found in the JSON but not in ' 111 print('WARNING: the following filename was found in the JSON but not in '
104 '${htmlDir.path}:\n"$key"'); 112 '${htmlDir.path}:\n"$key"');
105 _anyErrors = true; 113 _anyErrors = true;
106 }); 114 });
107 115
108 completer.complete(_anyErrors); 116 completer.complete(_anyErrors);
109 }; 117 };
110 118
(...skipping 21 matching lines...) Expand all
132 } else { 140 } else {
133 unusedComments.putIfAbsent(key, () => comments); 141 unusedComments.putIfAbsent(key, () => comments);
134 } 142 }
135 }); 143 });
136 144
137 unusedComments.forEach((String key, _) { 145 unusedComments.forEach((String key, _) {
138 print('WARNING: the following key was found in the JSON but not in ' 146 print('WARNING: the following key was found in the JSON but not in '
139 '${new Path(file.fullPathSync()).filename}:\n"$key"'); 147 '${new Path(file.fullPathSync()).filename}:\n"$key"');
140 _anyErrors = true; 148 _anyErrors = true;
141 }); 149 });
142
143 // TODO(amouravski): file.writeAsStringSync('${Strings.join(fileLines, '\n')}\ n');
144 var outputStream = file.openOutputStream();
145 outputStream.writeString(Strings.join(fileLines, '\n'));
146 outputStream.writeString('\n');
147 150
148 outputStream.onNoPendingWrites = () { 151 file.writeAsStringSync('${Strings.join(fileLines, '\n')}\n');
149 outputStream.close();
150 };
151 } 152 }
OLDNEW
« no previous file with comments | « sdk/lib/html/docs/html_docs.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698