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

Side by Side Diff: pkg/docgen/lib/dart2yaml.dart

Issue 19220006: Updated the schema of the yaml output. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** 5 /**
6 * This library is used to convert data from a map to a YAML string. 6 * This library is used to convert data from a map to a YAML string.
7 */ 7 */
8 library dart2yaml; 8 library dart2yaml;
9 9
10 /** 10 /**
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } else { 45 } else {
46 yaml.write(_processElement(documentData[key])); 46 yaml.write(_processElement(documentData[key]));
47 } 47 }
48 }); 48 });
49 } 49 }
50 50
51 /** 51 /**
52 * Returns an escaped String form of the inputted element. 52 * Returns an escaped String form of the inputted element.
53 */ 53 */
54 String _processElement(var element) { 54 String _processElement(var element) {
55 return "\"${element.toString().replaceAll('\\', '\\\\') 55 var contents = element.toString()
56 .replaceAll("\"", "\\\"")}\"\n"; 56 .replaceAll('\\', r'\\')
57 .replaceAll('"', r'\"')
58 .replaceAll('\n', r'\n');
59 return '"$contents"\n';
57 } 60 }
58 61
59 /** 62 /**
60 * Based on the depth in the file, this function returns the correct spacing 63 * Based on the depth in the file, this function returns the correct spacing
61 * for an element in the YAML output. 64 * for an element in the YAML output.
62 */ 65 */
63 void _calcSpaces(int spaceLevel, StringBuffer yaml) { 66 void _calcSpaces(int spaceLevel, StringBuffer yaml) {
64 for (int i = 0; i < spaceLevel; i++) { 67 for (int i = 0; i < spaceLevel; i++) {
65 yaml.write(" "); 68 yaml.write(" ");
66 } 69 }
67 } 70 }
OLDNEW
« no previous file with comments | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698