OLD | NEW |
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 * 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('dart:coreimpl'); |
12 #import('dart:io'); | 12 #import('dart:io'); |
13 | 13 |
14 #import('../../pkg/dartdoc/dartdoc.dart'); | 14 #import('../../pkg/dartdoc/dartdoc.dart'); |
15 #import('../../pkg/dartdoc/mirrors/mirrors.dart'); | 15 #import('../../pkg/dartdoc/mirrors/mirrors.dart'); |
16 #import('../../pkg/dartdoc/mirrors/mirrors_util.dart'); | 16 #import('../../pkg/dartdoc/mirrors/mirrors_util.dart'); |
17 | 17 |
18 final HTML_LIBRARY_NAME = 'dart:html'; | 18 const HTML_LIBRARY_NAME = 'dart:html'; |
19 | 19 |
20 /** | 20 /** |
21 * A class for computing a many-to-many mapping between the types and | 21 * A class for computing a many-to-many mapping between the types and |
22 * members in `dart:html` and the MDN DOM types. This mapping is | 22 * members in `dart:html` and the MDN DOM types. This mapping is |
23 * based on two indicators: | 23 * based on two indicators: |
24 * | 24 * |
25 * 1. Auto-detected wrappers. Most `dart:html` types correspond | 25 * 1. Auto-detected wrappers. Most `dart:html` types correspond |
26 * straightforwardly to a single `@domName` type, and | 26 * straightforwardly to a single `@domName` type, and |
27 * have the same name. In addition, most `dart:html` methods | 27 * have the same name. In addition, most `dart:html` methods |
28 * just call a single `@domName` method. This class | 28 * just call a single `@domName` method. This class |
29 * detects these simple correspondences automatically. | 29 * detects these simple correspondences automatically. |
30 * | 30 * |
31 * 2. Manual annotations. When it's not clear which | 31 * 2. Manual annotations. When it's not clear which |
32 * `@domName` items a given `dart:html` item | 32 * `@domName` items a given `dart:html` item |
33 * corresponds to, the `dart:html` item can be annotated in the | 33 * corresponds to, the `dart:html` item can be annotated in the |
34 * documentation comments using the `@domName` annotation. | 34 * documentation comments using the `@domName` annotation. |
35 * | 35 * |
36 * The `@domName` annotations for types and members are of the form | 36 * The `@domName` annotations for types and members are of the form |
37 * `@domName NAME(, NAME)*`, where the `NAME`s refer to the | 37 * `@domName NAME(, NAME)*`, where the `NAME`s refer to the |
38 * `@domName` types/members that correspond to the | 38 * `@domName` types/members that correspond to the |
39 * annotated `dart:html` type/member. `NAME`s on member annotations | 39 * annotated `dart:html` type/member. `NAME`s on member annotations |
40 * can refer to either fully-qualified member names (e.g. | 40 * can refer to either fully-qualified member names (e.g. |
41 * `Document.createElement`) or unqualified member names | 41 * `Document.createElement`) or unqualified member names |
42 * (e.g. `createElement`). Unqualified member names are assumed to | 42 * (e.g. `createElement`). Unqualified member names are assumed to |
43 * refer to members of one of the corresponding `@domName` | 43 * refer to members of one of the corresponding `@domName` |
44 * types. | 44 * types. |
45 */ | 45 */ |
46 class HtmlDiff { | 46 class HtmlDiff { |
47 /** | 47 /** |
48 * A map from `dart:html` members to the corresponding fully qualified | 48 * A map from `dart:html` members to the corresponding fully qualified |
49 * `@domName` member(s). | 49 * `@domName` member(s). |
50 */ | 50 */ |
51 final Map<String, Set<String>> htmlToDom; | 51 final Map<String, Set<String>> htmlToDom; |
52 | 52 |
53 /** A map from `dart:html` types to corresponding `@domName` types. */ | 53 /** A map from `dart:html` types to corresponding `@domName` types. */ |
54 final Map<String, Set<String>> htmlTypesToDom; | 54 final Map<String, Set<String>> htmlTypesToDom; |
55 | 55 |
56 final CommentMap comments; | 56 final CommentMap comments; |
57 | 57 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 Map<String, String> _getTags(String comment) { | 224 Map<String, String> _getTags(String comment) { |
225 if (comment == null) return const <String, String>{}; | 225 if (comment == null) return const <String, String>{}; |
226 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); | 226 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); |
227 final tags = <String, String>{}; | 227 final tags = <String, String>{}; |
228 for (var m in re.allMatches(comment.trim())) { | 228 for (var m in re.allMatches(comment.trim())) { |
229 tags[m[1]] = m[2]; | 229 tags[m[1]] = m[2]; |
230 } | 230 } |
231 return tags; | 231 return tags; |
232 } | 232 } |
233 } | 233 } |
OLD | NEW |