Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Unified Diff: pkg/docgen/lib/dart2yaml.dart

Issue 20162006: Fixed YAML output for a list of maps (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/dart2yaml.dart
diff --git a/pkg/docgen/lib/dart2yaml.dart b/pkg/docgen/lib/dart2yaml.dart
index cccb8eb084cec52be21ec3ee46de633dbd7f6e61..8ad16047e5afb58b250a6346bb1e833f22a3b19d 100644
--- a/pkg/docgen/lib/dart2yaml.dart
+++ b/pkg/docgen/lib/dart2yaml.dart
@@ -20,28 +20,29 @@ String getYamlString(Map documentData) {
* This recursive function adds to its input StringBuffer and builds
* a YAML string from the input Map.
*/
Alan Knight 2013/07/25 17:46:42 This could use some documentation for the paramete
Tate Mandel 2013/07/25 22:01:53 Done.
-// TODO(tmandel): Fix quotes with String objects.
-void _addLevel(StringBuffer yaml, Map documentData, int level) {
- documentData.keys.forEach( (key) {
+void _addLevel(StringBuffer yaml, Map documentData, int level,
+ {bool isList: false}) {
+ documentData.keys.forEach((key) {
_calcSpaces(level, yaml);
+ if (isList && key == documentData.keys.first) {
Alan Knight 2013/07/25 17:46:42 Since the order of keys is non-deterministic, I as
Tate Mandel 2013/07/25 22:01:53 documentData can have many elements, but the first
Alan Knight 2013/07/25 23:25:04 I think the ordering is actually quite messy. If I
Tate Mandel 2013/07/26 20:33:04 Done.
+ yaml.write("- ");
+ level++;
+ }
yaml.write("\"$key\" : ");
-
if (documentData[key] is Map) {
yaml.write("\n");
_addLevel(yaml, documentData[key], level + 1);
-
} else if (documentData[key] is List) {
var elements = documentData[key];
yaml.write("\n");
elements.forEach( (element) {
if (element is Map) {
- _addLevel(yaml, element, level + 1);
+ _addLevel(yaml, element, level + 1, isList: true);
} else {
_calcSpaces(level + 1, yaml);
yaml.write("- ${_processElement(element)}");
}
});
-
} else {
yaml.write(_processElement(documentData[key]));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698