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

Side by Side Diff: utils/apidoc/mdn/prettyPrint.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /** 1 /**
2 * Creates database.html, examples.html, and obsolete.html. 2 * Creates database.html, examples.html, and obsolete.html.
3 */ 3 */
4 4
5 library prettyPrint; 5 library prettyPrint;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:json' as json; 8 import 'dart:json' as json;
9 import 'util.dart'; 9 import 'util.dart';
10 10
(...skipping 13 matching lines...) Expand all
24 /** 24 /**
25 * Add all missing members to the string output and return the number of 25 * Add all missing members to the string output and return the number of
26 * missing members. 26 * missing members.
27 */ 27 */
28 void addMissingHelper(String propType) { 28 void addMissingHelper(String propType) {
29 Map expected = allProps[type][propType]; 29 Map expected = allProps[type][propType];
30 if (expected != null) { 30 if (expected != null) {
31 for(final name in sortStringCollection(expected.keys)) { 31 for(final name in sortStringCollection(expected.keys)) {
32 if (!members.containsKey(name)) { 32 if (!members.containsKey(name)) {
33 total++; 33 total++;
34 sb.add(""" 34 sb.write("""
35 <tr class="missing"> 35 <tr class="missing">
36 <td>$name</td> 36 <td>$name</td>
37 <td></td> 37 <td></td>
38 <td>Could not find documentation for $propType</td> 38 <td>Could not find documentation for $propType</td>
39 </tr> 39 </tr>
40 """); 40 """);
41 } 41 }
42 } 42 }
43 } 43 }
44 } 44 }
(...skipping 19 matching lines...) Expand all
64 final sbSkipped = new StringBuffer(); 64 final sbSkipped = new StringBuffer();
65 final sbAllExamples = new StringBuffer(); 65 final sbAllExamples = new StringBuffer();
66 66
67 // Table rows for all obsolete members. 67 // Table rows for all obsolete members.
68 final sbObsolete = new StringBuffer(); 68 final sbObsolete = new StringBuffer();
69 // Main documentation file. 69 // Main documentation file.
70 final sb = new StringBuffer(); 70 final sb = new StringBuffer();
71 71
72 // TODO(jacobr): switch to using a real template system instead of string 72 // TODO(jacobr): switch to using a real template system instead of string
73 // interpolation combined with StringBuffers. 73 // interpolation combined with StringBuffers.
74 sb.add(""" 74 sb.write("""
75 <html> 75 <html>
76 <head> 76 <head>
77 <style type="text/css"> 77 <style type="text/css">
78 body { 78 body {
79 background-color: #eee; 79 background-color: #eee;
80 margin: 10px; 80 margin: 10px;
81 font: 14px/1.428 "Lucida Grande", "Lucida Sans Unicode", Lucida, 81 font: 14px/1.428 "Lucida Grande", "Lucida Sans Unicode", Lucida,
82 Arial, Helvetica, sans-serif; 82 Arial, Helvetica, sans-serif;
83 } 83 }
84 84
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 <body> 149 <body>
150 <h1>Doc Dump</h1> 150 <h1>Doc Dump</h1>
151 <ul> 151 <ul>
152 <li><a href="#dart_summary">Summary</a></li> 152 <li><a href="#dart_summary">Summary</a></li>
153 </li> 153 </li>
154 """); 154 """);
155 for (String type in sortStringCollection(database.keys)) { 155 for (String type in sortStringCollection(database.keys)) {
156 final entry = database[type]; 156 final entry = database[type];
157 if (entry == null || entry.containsKey('skipped')) { 157 if (entry == null || entry.containsKey('skipped')) {
158 numSkipped++; 158 numSkipped++;
159 sbSkipped.add(""" 159 sbSkipped.write("""
160 <li id="$type"> 160 <li id="$type">
161 <a target="_blank" href="http://www.google.com/cse?cx=01719397256594783026 6%3Awpqsk6dy6ee&ie=UTF-8&q=$type"> 161 <a target="_blank" href="http://www.google.com/cse?cx=01719397256594783026 6%3Awpqsk6dy6ee&ie=UTF-8&q=$type">
162 $type 162 $type
163 </a> 163 </a>
164 -- 164 --
165 Title: ${entry == null ? "???" : entry["title"]} -- Issue: 165 Title: ${entry == null ? "???" : entry["title"]} -- Issue:
166 ${entry == null ? "???" : entry['cause']} 166 ${entry == null ? "???" : entry['cause']}
167 -- 167 --
168 <a target="_blank" href="${entry == null ? "???" : entry["srcUrl"]}"> 168 <a target="_blank" href="${entry == null ? "???" : entry["srcUrl"]}">
169 scraped url 169 scraped url
170 </a> 170 </a>
171 </li>"""); 171 </li>""");
172 continue; 172 continue;
173 } 173 }
174 matchedTypes.add(type); 174 matchedTypes.add(type);
175 numGen++; 175 numGen++;
176 StringBuffer sbSections = new StringBuffer(); 176 StringBuffer sbSections = new StringBuffer();
177 StringBuffer sbMembers = new StringBuffer(); 177 StringBuffer sbMembers = new StringBuffer();
178 StringBuffer sbExamples = new StringBuffer(); 178 StringBuffer sbExamples = new StringBuffer();
179 if (entry.containsKey("members")) { 179 if (entry.containsKey("members")) {
180 Map members = getMembersMap(entry); 180 Map members = getMembersMap(entry);
181 sbMembers.add(""" 181 sbMembers.write("""
182 <div class="members"> 182 <div class="members">
183 <h3><span class="debug">[dart]</span> Members</h3> 183 <h3><span class="debug">[dart]</span> Members</h3>
184 <table> 184 <table>
185 <tbody> 185 <tbody>
186 <tr> 186 <tr>
187 <th>Name</th><th>Description</th><th>IDL</th><th>Status</th> 187 <th>Name</th><th>Description</th><th>IDL</th><th>Status</th>
188 </tr> 188 </tr>
189 """); 189 """);
190 for (String name in sortStringCollection(members.keys)) { 190 for (String name in sortStringCollection(members.keys)) {
191 Map memberData = members[name]; 191 Map memberData = members[name];
192 bool unknown = !hasAny(type, name); 192 bool unknown = !hasAny(type, name);
193 StringBuffer classes = new StringBuffer(); 193 StringBuffer classes = new StringBuffer();
194 if (unknown) classes.add("unknown "); 194 if (unknown) classes.write("unknown ");
195 if (unknown) { 195 if (unknown) {
196 numExtraMethods++; 196 numExtraMethods++;
197 } else { 197 } else {
198 numFoundMethods++; 198 numFoundMethods++;
199 } 199 }
200 200
201 final sbMember = new StringBuffer(); 201 final sbMember = new StringBuffer();
202 202
203 if (memberData.containsKey('url')) { 203 if (memberData.containsKey('url')) {
204 sbMember.add(""" 204 sbMember.write("""
205 <td><a href="${memberData['url']}">$name</a></td> 205 <td><a href="${memberData['url']}">$name</a></td>
206 """); 206 """);
207 } else { 207 } else {
208 sbMember.add(""" 208 sbMember.write("""
209 <td>$name</td> 209 <td>$name</td>
210 """); 210 """);
211 } 211 }
212 sbMember.add(""" 212 sbMember.write("""
213 <td>${memberData['help']}</td> 213 <td>${memberData['help']}</td>
214 <td> 214 <td>
215 <pre>${orEmpty(memberData['idl'])}</pre> 215 <pre>${orEmpty(memberData['idl'])}</pre>
216 </td> 216 </td>
217 <td>${memberData['obsolete'] == true ? "Obsolete" : ""}</td> 217 <td>${memberData['obsolete'] == true ? "Obsolete" : ""}</td>
218 """); 218 """);
219 if (memberData['obsolete'] == true) { 219 if (memberData['obsolete'] == true) {
220 sbObsolete.add("<tr class='$classes'><td>$type</td>$sbMember</tr>"); 220 sbObsolete.write("<tr class='$classes'><td>$type</td>$sbMember</tr>");
221 } 221 }
222 sbMembers.add("<tr class='$classes'>$sbMember</tr>"); 222 sbMembers.write("<tr class='$classes'>$sbMember</tr>");
223 } 223 }
224 224
225 numMissingMethods += addMissing(sbMembers, type, members); 225 numMissingMethods += addMissing(sbMembers, type, members);
226 226
227 sbMembers.add(""" 227 sbMembers.write("""
228 </tbody> 228 </tbody>
229 </table> 229 </table>
230 </div> 230 </div>
231 """); 231 """);
232 } 232 }
233 for (String sectionName in 233 for (String sectionName in
234 ["summary", "constructor", "compatibility", "specification", 234 ["summary", "constructor", "compatibility", "specification",
235 "seeAlso"]) { 235 "seeAlso"]) {
236 if (entry.containsKey(sectionName)) { 236 if (entry.containsKey(sectionName)) {
237 sbSections.add(""" 237 sbSections.write("""
238 <div class="$sectionName"> 238 <div class="$sectionName">
239 <h3><span class="debug">[Dart]</span> $sectionName</h3> 239 <h3><span class="debug">[Dart]</span> $sectionName</h3>
240 ${entry[sectionName]} 240 ${entry[sectionName]}
241 </div> 241 </div>
242 """); 242 """);
243 } 243 }
244 } 244 }
245 if (entry.containsKey("links")) { 245 if (entry.containsKey("links")) {
246 sbSections.add(""" 246 sbSections.write("""
247 <div class="links"> 247 <div class="links">
248 <h3><span class="debug">[Dart]</span> Specification</h3> 248 <h3><span class="debug">[Dart]</span> Specification</h3>
249 <ul> 249 <ul>
250 """); 250 """);
251 List links = entry["links"]; 251 List links = entry["links"];
252 for (Map link in links) { 252 for (Map link in links) {
253 » sbSections.add(""" 253 » sbSections.write("""
254 <li><a href="${link['href']}">${link['title']}</a></li> 254 <li><a href="${link['href']}">${link['title']}</a></li>
255 """); 255 """);
256 } 256 }
257 sbSections.add(""" 257 sbSections.write("""
258 </ul> 258 </ul>
259 </div> 259 </div>
260 """); 260 """);
261 } 261 }
262 if (entry.containsKey("examples")) { 262 if (entry.containsKey("examples")) {
263 for (String example in entry["examples"]) { 263 for (String example in entry["examples"]) {
264 » sbExamples.add(""" 264 » sbExamples.write("""
265 <div class="example"> 265 <div class="example">
266 <h3><span class="debug">[Dart]</span> Example</h3> 266 <h3><span class="debug">[Dart]</span> Example</h3>
267 $example 267 $example
268 </div> 268 </div>
269 """); 269 """);
270 } 270 }
271 } 271 }
272 272
273 String title = entry['title']; 273 String title = entry['title'];
274 if (title != type) { 274 if (title != type) {
275 title = '<h4>Dart type: $type</h4><h2>$title</h2>'; 275 title = '<h4>Dart type: $type</h4><h2>$title</h2>';
276 } else { 276 } else {
277 title = '<h2>$title</h2>'; 277 title = '<h2>$title</h2>';
278 } 278 }
279 sb.add(""" 279 sb.write("""
280 <div class='type' id="$type"> 280 <div class='type' id="$type">
281 <a href='${entry['srcUrl']}'>$title</a> 281 <a href='${entry['srcUrl']}'>$title</a>
282 $sbSections 282 $sbSections
283 $sbExamples 283 $sbExamples
284 $sbMembers 284 $sbMembers
285 </div> 285 </div>
286 """); 286 """);
287 if (sbExamples.length > 0) { 287 if (sbExamples.length > 0) {
288 sbAllExamples.add(""" 288 sbAllExamples.write("""
289 <div class='type' id="$type"> 289 <div class='type' id="$type">
290 <a href='${entry['srcUrl']}'>$title</a> 290 <a href='${entry['srcUrl']}'>$title</a>
291 $sbExamples 291 $sbExamples
292 </div> 292 </div>
293 """); 293 """);
294 } 294 }
295 } 295 }
296 296
297 for (String type in sortStringCollection(allProps.keys)) { 297 for (String type in sortStringCollection(allProps.keys)) {
298 if (!matchedTypes.contains(type) && 298 if (!matchedTypes.contains(type) &&
299 !database.containsKey(type)) { 299 !database.containsKey(type)) {
300 numSkipped++; 300 numSkipped++;
301 sbSkipped.add(""" 301 sbSkipped.write("""
302 <li class="unknown" id="$type"> 302 <li class="unknown" id="$type">
303 <a target="_blank" href="http://www.google.com/cse?cx=01719397256594783026 6%3Awpqsk6dy6ee&ie=UTF-8&q=$type"> 303 <a target="_blank" href="http://www.google.com/cse?cx=01719397256594783026 6%3Awpqsk6dy6ee&ie=UTF-8&q=$type">
304 $type 304 $type
305 </a> 305 </a>
306 </li> 306 </li>
307 """); 307 """);
308 } 308 }
309 } 309 }
310 310
311 sb.add(""" 311 sb.write("""
312 <div id="#dart_summary"> 312 <div id="#dart_summary">
313 <h2>Summary</h2> 313 <h2>Summary</h2>
314 <h3> 314 <h3>
315 Generated docs for $numGen classes out of a possible 315 Generated docs for $numGen classes out of a possible
316 ${allProps.keys.length} 316 ${allProps.keys.length}
317 </h3> 317 </h3>
318 <h3>Found documentation for $numFoundMethods methods listed in WebKit</h3> 318 <h3>Found documentation for $numFoundMethods methods listed in WebKit</h3>
319 <h3> 319 <h3>
320 Found documentation for $numExtraMethods methods not listed in WebKit 320 Found documentation for $numExtraMethods methods not listed in WebKit
321 </h3> 321 </h3>
322 <h3> 322 <h3>
323 Unable to find documentation for $numMissingMethods methods present in 323 Unable to find documentation for $numMissingMethods methods present in
324 WebKit 324 WebKit
325 </h3> 325 </h3>
326 <h3> 326 <h3>
327 Skipped generating documentation for $numSkipped classes due to no 327 Skipped generating documentation for $numSkipped classes due to no
328 plausible matching files 328 plausible matching files
329 </h3> 329 </h3>
330 <ul> 330 <ul>
331 $sbSkipped 331 $sbSkipped
332 </ul> 332 </ul>
333 </div> 333 </div>
334 """); 334 """);
335 sb.add(""" 335 sb.write("""
336 </body> 336 </body>
337 </html> 337 </html>
338 """); 338 """);
339 339
340 writeFileSync("output/database.html", sb.toString()); 340 writeFileSync("output/database.html", sb.toString());
341 341
342 writeFileSync("output/examples.html", """ 342 writeFileSync("output/examples.html", """
343 <html> 343 <html>
344 <head> 344 <head>
345 <style type="text/css"> 345 <style type="text/css">
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 <th>IDL</th> 421 <th>IDL</th>
422 <th>Status</th> 422 <th>Status</th>
423 </tr> 423 </tr>
424 $sbObsolete 424 $sbObsolete
425 </tbody> 425 </tbody>
426 </table> 426 </table>
427 </body> 427 </body>
428 </html> 428 </html>
429 """); 429 """);
430 } 430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698