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 ## | 7 /// ## Installing ## |
8 /// | 8 /// |
9 /// Use [pub][] to install this package. Add the following to your | 9 /// Use [pub][] to install this package. Add the following to your |
10 /// `pubspec.yaml` file. | 10 /// `pubspec.yaml` file. |
(...skipping 11 matching lines...) Expand all Loading... |
22 /// 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 |
23 /// stream of documents. For example: | 23 /// stream of documents. For example: |
24 /// | 24 /// |
25 /// import 'package:yaml/yaml.dart'; | 25 /// import 'package:yaml/yaml.dart'; |
26 /// main() { | 26 /// main() { |
27 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 27 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
28 /// print(doc['YAML']); | 28 /// print(doc['YAML']); |
29 /// } | 29 /// } |
30 /// | 30 /// |
31 /// 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 |
32 /// `stringify` from `dart:json` instead: | 32 /// `JSON.encode` from `dart:convert` instead: |
33 /// | 33 /// |
34 /// import 'dart:json' as json; | 34 /// import 'dart:convert'; |
35 /// import 'package:yaml/yaml.dart'; | 35 /// import 'package:yaml/yaml.dart'; |
36 /// main() { | 36 /// main() { |
37 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); | 37 /// var doc = loadYaml("YAML: YAML Ain't Markup Language"); |
38 /// print(json.stringify(doc)); | 38 /// print(JSON.encode(doc)); |
39 /// } | 39 /// } |
40 /// | 40 /// |
41 /// [pub]: http://pub.dartlang.org | 41 /// [pub]: http://pub.dartlang.org |
42 /// [pkg]: http://pub.dartlang.org/packages/yaml | 42 /// [pkg]: http://pub.dartlang.org/packages/yaml |
43 library yaml; | 43 library yaml; |
44 | 44 |
45 import 'src/composer.dart'; | 45 import 'src/composer.dart'; |
46 import 'src/constructor.dart'; | 46 import 'src/constructor.dart'; |
47 import 'src/parser.dart'; | 47 import 'src/parser.dart'; |
48 import 'src/yaml_exception.dart'; | 48 import 'src/yaml_exception.dart'; |
(...skipping 22 matching lines...) Expand all Loading... |
71 /// 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 |
72 /// 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 |
73 /// (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 |
74 /// 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 |
75 /// default Map implementation; for details, see the [YamlMap] class. | 75 /// default Map implementation; for details, see the [YamlMap] class. |
76 List loadYamlStream(String yaml) { | 76 List loadYamlStream(String yaml) { |
77 return new Parser(yaml).l_yamlStream() | 77 return new Parser(yaml).l_yamlStream() |
78 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) | 78 .map((doc) => new Constructor(new Composer(doc).compose()).construct()) |
79 .toList(); | 79 .toList(); |
80 } | 80 } |
OLD | NEW |