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 /// A parser for [YAML](http://www.yaml.org/). | 5 /// A parser for [YAML](http://www.yaml.org/). |
6 /// | 6 /// |
| 7 /// ## Installing ## |
| 8 /// |
| 9 /// Use [pub][] to install this package. Add the following to your |
| 10 /// `pubspec.yaml` file. |
| 11 /// |
| 12 /// dependencies: |
| 13 /// yaml: any |
| 14 /// |
| 15 /// Then run `pub install`. |
| 16 /// |
| 17 /// For more information, see the |
| 18 /// [yaml package on pub.dartlang.org][pkg]. |
| 19 /// |
| 20 /// ## Using ## |
| 21 /// |
7 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a | 22 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a |
8 /// stream of documents. For example: | 23 /// stream of documents. For example: |
9 /// | 24 /// |
10 /// import 'package:yaml/yaml.dart'; | 25 /// import 'package:yaml/yaml.dart'; |
11 /// main() { | 26 /// main() { |
12 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 27 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
13 /// print(doc['YAML']); | 28 /// print(doc['YAML']); |
14 /// } | 29 /// } |
15 /// | 30 /// |
16 /// This library currently doesn't support dumping to YAML. You should use | 31 /// This library currently doesn't support dumping to YAML. You should use |
17 /// `stringify` from `dart:json` instead: | 32 /// `stringify` from `dart:json` instead: |
18 /// | 33 /// |
19 /// import 'dart:json' as json; | 34 /// import 'dart:json' as json; |
20 /// import 'package:yaml/yaml.dart'; | 35 /// import 'package:yaml/yaml.dart'; |
21 /// main() { | 36 /// main() { |
22 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 37 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
23 /// print(json.stringify(doc)); | 38 /// print(json.stringify(doc)); |
24 /// } | 39 /// } |
| 40 /// |
| 41 /// [pub]: http://pub.dartlang.org |
| 42 /// [pkg]: http://pub.dartlang.org/packages/yaml |
25 library yaml; | 43 library yaml; |
26 | 44 |
27 import 'src/composer.dart'; | 45 import 'src/composer.dart'; |
28 import 'src/constructor.dart'; | 46 import 'src/constructor.dart'; |
29 import 'src/parser.dart'; | 47 import 'src/parser.dart'; |
30 import 'src/yaml_exception.dart'; | 48 import 'src/yaml_exception.dart'; |
31 | 49 |
32 export 'src/yaml_exception.dart'; | 50 export 'src/yaml_exception.dart'; |
33 export 'src/yaml_map.dart'; | 51 export 'src/yaml_map.dart'; |
34 | 52 |
(...skipping 18 matching lines...) Expand all Loading... |
53 /// The return value is mostly normal Dart objects. However, since YAML mappings | 71 /// The return value is mostly normal Dart objects. However, since YAML mappings |
54 /// support some key types that the default Dart map implementation doesn't | 72 /// support some key types that the default Dart map implementation doesn't |
55 /// (null, NaN, booleans, lists, and maps), all maps in the returned document | 73 /// (null, NaN, booleans, lists, and maps), all maps in the returned document |
56 /// are [YamlMap]s. These have a few small behavioral differences from the | 74 /// are [YamlMap]s. These have a few small behavioral differences from the |
57 /// default Map implementation; for details, see the [YamlMap] class. | 75 /// default Map implementation; for details, see the [YamlMap] class. |
58 List loadYamlStream(String yaml) { | 76 List loadYamlStream(String yaml) { |
59 return new Parser(yaml).l_yamlStream() | 77 return new Parser(yaml).l_yamlStream() |
60 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) | 78 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) |
61 .toList(); | 79 .toList(); |
62 } | 80 } |
OLD | NEW |