OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 * Code for reading an HTML API description. | 6 * Code for reading an HTML API description. |
7 */ | 7 */ |
8 library from.html; | 8 library from.html; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 if (!requiredAttributes.contains(name) && | 100 if (!requiredAttributes.contains(name) && |
101 !optionalAttributes.contains(name)) { | 101 !optionalAttributes.contains(name)) { |
102 throw new Exception( | 102 throw new Exception( |
103 '$context: Unexpected attribute in ${element.localName}: $name'); | 103 '$context: Unexpected attribute in ${element.localName}: $name'); |
104 } | 104 } |
105 attributesFound.add(name); | 105 attributesFound.add(name); |
106 }); | 106 }); |
107 for (String expectedAttribute in requiredAttributes) { | 107 for (String expectedAttribute in requiredAttributes) { |
108 if (!attributesFound.contains(expectedAttribute)) { | 108 if (!attributesFound.contains(expectedAttribute)) { |
109 throw new Exception( | 109 throw new Exception( |
110 '$context: ${element.localName} must contain attribute ${expectedAttri
bute}'); | 110 '$context: ${element.localName} must contain attribute $expectedAttrib
ute'); |
111 } | 111 } |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 /** | 115 /** |
116 * Check that the given [element] has the given [expectedName]. | 116 * Check that the given [element] has the given [expectedName]. |
117 */ | 117 */ |
118 void checkName(dom.Element element, String expectedName, [String context]) { | 118 void checkName(dom.Element element, String expectedName, [String context]) { |
119 if (element.localName != expectedName) { | 119 if (element.localName != expectedName) { |
120 if (context == null) { | 120 if (context == null) { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); | 545 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); |
546 types[typeDefinition.name] = typeDefinition; | 546 types[typeDefinition.name] = typeDefinition; |
547 } | 547 } |
548 }); | 548 }); |
549 return new Types(types, html); | 549 return new Types(types, html); |
550 } | 550 } |
551 | 551 |
552 typedef void ElementProcessor(dom.Element element); | 552 typedef void ElementProcessor(dom.Element element); |
553 | 553 |
554 typedef void TextProcessor(dom.Text text); | 554 typedef void TextProcessor(dom.Text text); |
OLD | NEW |