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 `pubspec.yaml ` | |
Andrei Mouravski
2013/04/19 20:13:35
Line too long.
sethladd
2013/04/19 20:32:43
Done.
| |
10 /// file. | |
11 /// | |
12 /// dependencies: | |
13 /// yaml: any | |
14 /// | |
15 /// And then run `pub install`. | |
16 /// | |
17 /// ## Using ## | |
18 /// | |
7 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a | 19 /// Use [loadYaml] to load a single document, or [loadYamlStream] to load a |
8 /// stream of documents. For example: | 20 /// stream of documents. For example: |
9 /// | 21 /// |
10 /// import 'package:yaml/yaml.dart'; | 22 /// import 'package:yaml/yaml.dart'; |
11 /// main() { | 23 /// main() { |
12 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 24 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
13 /// print(doc['YAML']); | 25 /// print(doc['YAML']); |
14 /// } | 26 /// } |
15 /// | 27 /// |
16 /// This library currently doesn't support dumping to YAML. You should use | 28 /// This library currently doesn't support dumping to YAML. You should use |
17 /// `stringify` from `dart:json` instead: | 29 /// `stringify` from `dart:json` instead: |
18 /// | 30 /// |
19 /// import 'dart:json' as json; | 31 /// import 'dart:json' as json; |
20 /// import 'package:yaml/yaml.dart'; | 32 /// import 'package:yaml/yaml.dart'; |
21 /// main() { | 33 /// main() { |
22 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 34 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
23 /// print(json.stringify(doc)); | 35 /// print(json.stringify(doc)); |
24 /// } | 36 /// } |
37 /// | |
38 /// [pub]: http://pub.dartlang.org | |
25 library yaml; | 39 library yaml; |
26 | 40 |
27 import 'src/composer.dart'; | 41 import 'src/composer.dart'; |
28 import 'src/constructor.dart'; | 42 import 'src/constructor.dart'; |
29 import 'src/parser.dart'; | 43 import 'src/parser.dart'; |
30 import 'src/yaml_exception.dart'; | 44 import 'src/yaml_exception.dart'; |
31 | 45 |
32 export 'src/yaml_exception.dart'; | 46 export 'src/yaml_exception.dart'; |
33 export 'src/yaml_map.dart'; | 47 export 'src/yaml_map.dart'; |
34 | 48 |
(...skipping 18 matching lines...) Expand all Loading... | |
53 /// The return value is mostly normal Dart objects. However, since YAML mappings | 67 /// 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 | 68 /// 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 | 69 /// (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 | 70 /// are [YamlMap]s. These have a few small behavioral differences from the |
57 /// default Map implementation; for details, see the [YamlMap] class. | 71 /// default Map implementation; for details, see the [YamlMap] class. |
58 List loadYamlStream(String yaml) { | 72 List loadYamlStream(String yaml) { |
59 return new Parser(yaml).l_yamlStream() | 73 return new Parser(yaml).l_yamlStream() |
60 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) | 74 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) |
61 .toList(); | 75 .toList(); |
62 } | 76 } |
OLD | NEW |