| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 * <params> and <result> have the same form as <object>, as described in | 387 * <params> and <result> have the same form as <object>, as described in |
| 388 * [typeDeclFromHtml]. | 388 * [typeDeclFromHtml]. |
| 389 * | 389 * |
| 390 * Child elements can occur in any order. | 390 * Child elements can occur in any order. |
| 391 */ | 391 */ |
| 392 Request requestFromHtml(dom.Element html, String context) { | 392 Request requestFromHtml(dom.Element html, String context) { |
| 393 String domainName = getAncestor(html, 'domain', context).attributes['name']; | 393 String domainName = getAncestor(html, 'domain', context).attributes['name']; |
| 394 checkName(html, 'request', context); | 394 checkName(html, 'request', context); |
| 395 String method = html.attributes['method']; | 395 String method = html.attributes['method']; |
| 396 context = '$context.${method != null ? method : 'method'}'; | 396 context = '$context.${method != null ? method : 'method'}'; |
| 397 checkAttributes(html, ['method'], context); | 397 checkAttributes(html, ['method'], context, |
| 398 optionalAttributes: ['experimental']); |
| 399 bool experimental = html.attributes['experimental'] == 'true'; |
| 398 TypeDecl params; | 400 TypeDecl params; |
| 399 TypeDecl result; | 401 TypeDecl result; |
| 400 recurse(html, context, { | 402 recurse(html, context, { |
| 401 'params': (dom.Element child) { | 403 'params': (dom.Element child) { |
| 402 params = typeObjectFromHtml(child, '$context.params'); | 404 params = typeObjectFromHtml(child, '$context.params'); |
| 403 }, | 405 }, |
| 404 'result': (dom.Element child) { | 406 'result': (dom.Element child) { |
| 405 result = typeObjectFromHtml(child, '$context.result'); | 407 result = typeObjectFromHtml(child, '$context.result'); |
| 406 } | 408 } |
| 407 }); | 409 }); |
| 408 return new Request(domainName, method, params, result, html); | 410 return new Request(domainName, method, params, result, html, |
| 411 experimental: experimental); |
| 409 } | 412 } |
| 410 | 413 |
| 411 /** | 414 /** |
| 412 * Create a [TypeDefinition] object from an HTML representation such as: | 415 * Create a [TypeDefinition] object from an HTML representation such as: |
| 413 * | 416 * |
| 414 * <type name="typeName"> | 417 * <type name="typeName"> |
| 415 * TYPE | 418 * TYPE |
| 416 * </type> | 419 * </type> |
| 417 * | 420 * |
| 418 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml]. | 421 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml]. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); | 549 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); |
| 547 types[typeDefinition.name] = typeDefinition; | 550 types[typeDefinition.name] = typeDefinition; |
| 548 } | 551 } |
| 549 }); | 552 }); |
| 550 return new Types(types, html); | 553 return new Types(types, html); |
| 551 } | 554 } |
| 552 | 555 |
| 553 typedef void ElementProcessor(dom.Element element); | 556 typedef void ElementProcessor(dom.Element element); |
| 554 | 557 |
| 555 typedef void TextProcessor(dom.Text text); | 558 typedef void TextProcessor(dom.Text text); |
| OLD | NEW |