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 // TODO(rnystrom): Use "package:" URL (#4968). |
15 #import('../../pkg/dartdoc/mirrors/mirrors.dart'); | 15 #import('../../pkg/dartdoc/lib/dartdoc.dart'); |
16 #import('../../pkg/dartdoc/mirrors/mirrors_util.dart'); | 16 #import('../../pkg/dartdoc/lib/mirrors.dart'); |
| 17 #import('../../pkg/dartdoc/lib/mirrors_util.dart'); |
17 | 18 |
18 final HTML_LIBRARY_NAME = 'dart:html'; | 19 final HTML_LIBRARY_NAME = 'dart:html'; |
19 | 20 |
20 /** | 21 /** |
21 * A class for computing a many-to-many mapping between the types and | 22 * 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 | 23 * members in `dart:html` and the MDN DOM types. This mapping is |
23 * based on two indicators: | 24 * based on two indicators: |
24 * | 25 * |
25 * 1. Auto-detected wrappers. Most `dart:html` types correspond | 26 * 1. Auto-detected wrappers. Most `dart:html` types correspond |
26 * straightforwardly to a single `@domName` type, and | 27 * straightforwardly to a single `@domName` type, and |
(...skipping 10 matching lines...) Expand all Loading... |
37 * `@domName NAME(, NAME)*`, where the `NAME`s refer to the | 38 * `@domName NAME(, NAME)*`, where the `NAME`s refer to the |
38 * `@domName` types/members that correspond to the | 39 * `@domName` types/members that correspond to the |
39 * annotated `dart:html` type/member. `NAME`s on member annotations | 40 * annotated `dart:html` type/member. `NAME`s on member annotations |
40 * can refer to either fully-qualified member names (e.g. | 41 * can refer to either fully-qualified member names (e.g. |
41 * `Document.createElement`) or unqualified member names | 42 * `Document.createElement`) or unqualified member names |
42 * (e.g. `createElement`). Unqualified member names are assumed to | 43 * (e.g. `createElement`). Unqualified member names are assumed to |
43 * refer to members of one of the corresponding `@domName` | 44 * refer to members of one of the corresponding `@domName` |
44 * types. | 45 * types. |
45 */ | 46 */ |
46 class HtmlDiff { | 47 class HtmlDiff { |
47 /** | 48 /** |
48 * A map from `dart:html` members to the corresponding fully qualified | 49 * A map from `dart:html` members to the corresponding fully qualified |
49 * `@domName` member(s). | 50 * `@domName` member(s). |
50 */ | 51 */ |
51 final Map<String, Set<String>> htmlToDom; | 52 final Map<String, Set<String>> htmlToDom; |
52 | 53 |
53 /** A map from `dart:html` types to corresponding `@domName` types. */ | 54 /** A map from `dart:html` types to corresponding `@domName` types. */ |
54 final Map<String, Set<String>> htmlTypesToDom; | 55 final Map<String, Set<String>> htmlTypesToDom; |
55 | 56 |
56 final CommentMap comments; | 57 final CommentMap comments; |
57 | 58 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 Map<String, String> _getTags(String comment) { | 225 Map<String, String> _getTags(String comment) { |
225 if (comment == null) return const <String, String>{}; | 226 if (comment == null) return const <String, String>{}; |
226 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); | 227 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); |
227 final tags = <String, String>{}; | 228 final tags = <String, String>{}; |
228 for (var m in re.allMatches(comment.trim())) { | 229 for (var m in re.allMatches(comment.trim())) { |
229 tags[m[1]] = m[2]; | 230 tags[m[1]] = m[2]; |
230 } | 231 } |
231 return tags; | 232 return tags; |
232 } | 233 } |
233 } | 234 } |
OLD | NEW |