| OLD | NEW |
| 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 * A script to assist in documenting the difference between the dart:html API | 6 * A script to assist in documenting the difference between the dart:html API |
| 7 * and the old DOM API. | 7 * and the old DOM API. |
| 8 */ | 8 */ |
| 9 #library('html_diff'); | 9 #library('html_diff'); |
| 10 | 10 |
| 11 #import('dart:coreimpl'); |
| 11 #import('../../frog/lang.dart'); | 12 #import('../../frog/lang.dart'); |
| 12 #import('../../frog/file_system_node.dart'); | 13 #import('../../frog/file_system_node.dart'); |
| 13 #import('../../frog/file_system.dart'); | 14 #import('../../frog/file_system.dart'); |
| 14 #import('../dartdoc/dartdoc.dart'); | 15 #import('../dartdoc/dartdoc.dart'); |
| 15 | 16 |
| 16 void main() { | |
| 17 var files = new NodeFileSystem(); | |
| 18 parseOptions('../../frog', [] /* args */, files); | |
| 19 initializeWorld(files); | |
| 20 initializeDartDoc(); | |
| 21 HtmlDiff.initialize(); | |
| 22 | |
| 23 var diff = new HtmlDiff(); | |
| 24 diff.run(); | |
| 25 | |
| 26 diff.domToHtml.forEach((domMember, htmlMembers) { | |
| 27 for (var htmlMember in htmlMembers) { | |
| 28 if (diff.sameName(domMember, htmlMember)) continue; | |
| 29 var htmlTypeName = htmlMember.declaringType.name; | |
| 30 var htmlName = '$htmlTypeName.${htmlMember.name}'; | |
| 31 if (htmlMember.isConstructor || htmlMember.isFactory) { | |
| 32 final separator = htmlMember.constructorName == '' ? '' : '.'; | |
| 33 htmlName = 'new $htmlTypeName$separator${htmlMember.constructorName}'; | |
| 34 } | |
| 35 print('${domMember.declaringType.name}.${domMember.name} -> ${htmlName}'); | |
| 36 } | |
| 37 }); | |
| 38 | |
| 39 for (var type in diff.dom.types.getValues()) { | |
| 40 if (type.name == null) continue; | |
| 41 if (type.definition is FunctionTypeDefinition) continue; | |
| 42 for (var member in type.members.getValues()) { | |
| 43 if (!member.isPrivate && member.name != 'typeName' && | |
| 44 !diff.domToHtml.containsKey(member) && | |
| 45 (member is MethodMember || member is PropertyMember)) { | |
| 46 print('No dart:html wrapper for ${type.name}.${member.name}'); | |
| 47 } | |
| 48 } | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 /** | 17 /** |
| 53 * A class for computing a many-to-many mapping between the types and members in | 18 * A class for computing a many-to-many mapping between the types and members in |
| 54 * `dart:dom` and `dart:html`. This mapping is based on two indicators: | 19 * `dart:dom` and `dart:html`. This mapping is based on two indicators: |
| 55 * | 20 * |
| 56 * 1. Auto-detected wrappers. Most `dart:html` types correspond | 21 * 1. Auto-detected wrappers. Most `dart:html` types correspond |
| 57 * straightforwardly to a single `dart:dom` type, and have the same name. | 22 * straightforwardly to a single `dart:dom` type, and have the same name. |
| 58 * In addition, most `dart:htmlimpl` methods just call a single `dart:dom` | 23 * In addition, most `dart:htmlimpl` methods just call a single `dart:dom` |
| 59 * method. This class detects these simple correspondences automatically. | 24 * method. This class detects these simple correspondences automatically. |
| 60 * | 25 * |
| 61 * 2. Manual annotations. When it's not clear which `dart:dom` items a given | 26 * 2. Manual annotations. When it's not clear which `dart:dom` items a given |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 Map<String, String> _getTags(String comment) { | 393 Map<String, String> _getTags(String comment) { |
| 429 if (comment == null) return const <String>{}; | 394 if (comment == null) return const <String>{}; |
| 430 final re = new RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); | 395 final re = new RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); |
| 431 final tags = <String>{}; | 396 final tags = <String>{}; |
| 432 for (var m in re.allMatches(comment.trim())) { | 397 for (var m in re.allMatches(comment.trim())) { |
| 433 tags[m[1]] = m[2]; | 398 tags[m[1]] = m[2]; |
| 434 } | 399 } |
| 435 return tags; | 400 return tags; |
| 436 } | 401 } |
| 437 } | 402 } |
| OLD | NEW |