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

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

Issue 9315026: Cleanup mdn scripts (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 8 years, 10 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 | « client/html/src/DOMWrapperBase.dart ('k') | utils/apidoc/mdn/README.txt » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * Generates the complete set of corelib reference documentation. 6 * Generates the complete set of corelib reference documentation.
7 */ 7 */
8 #library('apidoc'); 8 #library('apidoc');
9 9
10 #import('dart:json'); 10 #import('dart:json');
11 #import('html_diff.dart'); 11 #import('html_diff.dart');
12 #import('../../frog/lang.dart'); 12 #import('../../frog/lang.dart');
13 #import('../../frog/file_system_node.dart'); 13 #import('../../frog/file_system_node.dart');
14 #import('../../frog/file_system.dart'); 14 #import('../../frog/file_system.dart');
15 #import('../dartdoc/dartdoc.dart', prefix: 'doc'); 15 #import('../dartdoc/dartdoc.dart', prefix: 'doc');
16 16
17 HtmlDiff _diff; 17 HtmlDiff _diff;
18 18
19 final GET_PREFIX = 'get:';
20
19 void main() { 21 void main() {
20 var files = new NodeFileSystem(); 22 var files = new NodeFileSystem();
21 parseOptions('../../frog', [] /* args */, files); 23 parseOptions('../../frog', [] /* args */, files);
22 initializeWorld(files); 24 initializeWorld(files);
23 25
24 print('Parsing MDN data...'); 26 print('Parsing MDN data...');
25 final mdn = JSON.parse(files.readAll('mdn/database.json')); 27 final mdn = JSON.parse(files.readAll('mdn/database.json'));
26 28
27 print('Cross-referencing dart:dom and dart:html...'); 29 print('Cross-referencing dart:dom and dart:html...');
28 HtmlDiff.initialize(); 30 HtmlDiff.initialize();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } else if (member.library.name != 'dom') { 273 } else if (member.library.name != 'dom') {
272 // Not a DOM type. 274 // Not a DOM type.
273 return null; 275 return null;
274 } 276 }
275 277
276 // Ignore top-level functions. 278 // Ignore top-level functions.
277 if (member.declaringType.isTop) return null; 279 if (member.declaringType.isTop) return null;
278 280
279 final mdnType = mdn[member.declaringType.name]; 281 final mdnType = mdn[member.declaringType.name];
280 if (mdnType == null) return null; 282 if (mdnType == null) return null;
281 283 var nameToFind = member.name;
284 if (nameToFind.startsWith(GET_PREFIX)) {
285 nameToFind = nameToFind.substring(GET_PREFIX.length);
286 }
282 var mdnMember = null; 287 var mdnMember = null;
283 for (final thisMember in mdnType['members']) { 288 for (final candidateMember in mdnType['members']) {
284 if (thisMember['name'] == member.name) { 289 if (candidateMember['name'] == nameToFind) {
285 mdnMember = thisMember; 290 mdnMember = candidateMember;
286 break; 291 break;
287 } 292 }
288 } 293 }
289 294
290 if (mdnMember == null) return null; 295 if (mdnMember == null) return null;
291 296
292 // Remember which MDN page we're using so we can attribute it. 297 // Remember which MDN page we're using so we can attribute it.
293 mdnUrl = mdnType['srcUrl']; 298 mdnUrl = mdnType['srcUrl'];
294 return mdnMember['help']; 299 return mdnMember['help'];
295 } 300 }
296 301
297 /** 302 /**
298 * Returns a link to [member], relative to a type page that may be in a 303 * Returns a link to [member], relative to a type page that may be in a
299 * different library than [member]. 304 * different library than [member].
300 */ 305 */
301 String _linkMember(Member member) { 306 String _linkMember(Member member) {
302 final GET_PREFIX = 'get:';
303
304 final typeName = member.declaringType.name; 307 final typeName = member.declaringType.name;
305 var memberName = '$typeName.${member.name}'; 308 var memberName = '$typeName.${member.name}';
306 if (member.isConstructor || member.isFactory) { 309 if (member.isConstructor || member.isFactory) {
307 final separator = member.constructorName == '' ? '' : '.'; 310 final separator = member.constructorName == '' ? '' : '.';
308 memberName = 'new $typeName$separator${member.constructorName}'; 311 memberName = 'new $typeName$separator${member.constructorName}';
309 } else if (member.name.startsWith(GET_PREFIX)) { 312 } else if (member.name.startsWith(GET_PREFIX)) {
310 memberName = '$typeName.${member.name.substring(GET_PREFIX.length)}'; 313 memberName = '$typeName.${member.name.substring(GET_PREFIX.length)}';
311 } 314 }
312 315
313 return a(memberUrl(member), memberName); 316 return a(memberUrl(member), memberName);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return 383 return
381 ''' 384 '''
382 <p class="correspond">This corresponds to $domTypesText in the 385 <p class="correspond">This corresponds to $domTypesText in the
383 ${a("dom.html", "dart:dom")} library.</p> 386 ${a("dom.html", "dart:dom")} library.</p>
384 '''; 387 ''';
385 } 388 }
386 389
387 return ''; 390 return '';
388 } 391 }
389 } 392 }
OLDNEW
« no previous file with comments | « client/html/src/DOMWrapperBase.dart ('k') | utils/apidoc/mdn/README.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698