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

Unified Diff: sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart

Issue 12035057: First half of the new HTML json docs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed unneeded file. Created 7 years, 11 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 | sdk/lib/html/html_common/metadata.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
diff --git a/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart b/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
index 8039d0c9c4570f03210725b8f036ecbe6c2dc6f2..bcfdf68dca9d5a4ab20416807253109a39aaae4f 100755
--- a/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
+++ b/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
@@ -19,6 +19,14 @@ String serialize(Object o) {
return printer.toString();
}
+/// Serialize the object with pretty printing.
+String prettySerialize(Object o) {
+ var printer = new JsonPrinter(_prettyPrint: true);
+ _serialize(null, o, printer);
+ return printer.toString();
+}
+
+
void _serialize(String name, Object o, JsonPrinter printer) {
if (o == null) return;
@@ -80,6 +88,10 @@ void _serializeList(String name, List l, JsonPrinter printer) {
}
void _serializeMap(String name, Map m, JsonPrinter printer) {
+ printer.startObject(name);
+ m.forEach((key, value) =>
+ _serialize(key, value, printer));
+ printer.endObject();
}
class JsonPrinter {
@@ -164,7 +176,10 @@ class JsonPrinter {
if (_inSet) {
_sb.add(',');
}
- _newline();
+ // Do not print a newline at the beginning of the file.
+ if (!_sb.isEmpty) {
+ _newline();
+ }
if (name != null) {
_sb.add('"$name": ');
}
« no previous file with comments | « no previous file | sdk/lib/html/html_common/metadata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698