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 /** | 5 /** |
6 * Library for extracting the documentation comments from files generated by | 6 * Library for extracting the documentation comments from files generated by |
7 * the HTML library. The comments are stored in a JSON file. | 7 * the HTML library. The comments are stored in a JSON file. |
8 * | 8 * |
9 * Comments must be in either the block style with leading *s: | 9 * Comments must be in either the block style with leading *s: |
10 * | 10 * |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 var output; | 292 var output; |
293 | 293 |
294 if (json is List) { | 294 if (json is List) { |
295 var recursiveOutput = | 295 var recursiveOutput = |
296 Strings.join(json.map((e) => | 296 Strings.join(json.map((e) => |
297 prettyPrintJson(e, '$indentation ')), ',\n'); | 297 prettyPrintJson(e, '$indentation ')), ',\n'); |
298 output = '$indentation[\n' | 298 output = '$indentation[\n' |
299 '$recursiveOutput' | 299 '$recursiveOutput' |
300 '\n$indentation]'; | 300 '\n$indentation]'; |
301 } else if (json is Map) { | 301 } else if (json is Map) { |
| 302 var keys = json.keys |
| 303 ..sort(); |
| 304 |
302 // TODO(amouravski): No newline after : | 305 // TODO(amouravski): No newline after : |
303 var mapList = json.keys.map((key) => | 306 var mapList = keys.map((key) => |
304 '$indentation${JSON.stringify(key)}:\n' | 307 '$indentation${JSON.stringify(key)}:\n' |
305 '${prettyPrintJson(json[key], '$indentation ')}'); | 308 '${prettyPrintJson(json[key], '$indentation ')}'); |
306 var recursiveOutput = Strings.join(mapList, ',\n'); | 309 var recursiveOutput = Strings.join(mapList, ',\n'); |
307 output = '$indentation{\n' | 310 output = '$indentation{\n' |
308 '$recursiveOutput' | 311 '$recursiveOutput' |
309 '\n$indentation}'; | 312 '\n$indentation}'; |
310 } else { | 313 } else { |
311 output = '$indentation${JSON.stringify(json)}'; | 314 output = '$indentation${JSON.stringify(json)}'; |
312 } | 315 } |
313 return output; | 316 return output; |
314 } | 317 } |
OLD | NEW |