| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 * Tools for code generation. | 6 * Tools for code generation. |
| 7 */ | 7 */ |
| 8 library codegen.tools; | 8 library codegen.tools; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 */ | 108 */ |
| 109 int get indentWidth => _state.nextIndent.length; | 109 int get indentWidth => _state.nextIndent.length; |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Generate a doc comment based on the HTML in [docs]. | 112 * Generate a doc comment based on the HTML in [docs]. |
| 113 * | 113 * |
| 114 * If [javadocStyle] is true, then the output is compatable with Javadoc, | 114 * If [javadocStyle] is true, then the output is compatable with Javadoc, |
| 115 * which understands certain HTML constructs. | 115 * which understands certain HTML constructs. |
| 116 */ | 116 */ |
| 117 void docComment(List<dom.Node> docs, {int width: 79, bool javadocStyle: false}
) { | 117 void docComment(List<dom.Node> docs, {int width: 79, bool javadocStyle: false}
) { |
| 118 if (containsOnlyWhitespace(docs)) { |
| 119 return; |
| 120 } |
| 118 writeln('/**'); | 121 writeln('/**'); |
| 119 indentBy(' * ', () { | 122 indentBy(' * ', () { |
| 120 write(nodesToText(docs, width - _state.indent.length, javadocStyle)); | 123 write(nodesToText(docs, width - _state.indent.length, javadocStyle)); |
| 121 }); | 124 }); |
| 122 writeln(' */'); | 125 writeln(' */'); |
| 123 } | 126 } |
| 124 | 127 |
| 125 void outputHeader({bool javaStyle: false}) { | 128 void outputHeader({bool javaStyle: false}) { |
| 126 String header; | 129 String header; |
| 127 if (javaStyle) { | 130 if (javaStyle) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 @override | 401 @override |
| 399 void generate() { | 402 void generate() { |
| 400 // TODO (jwren) Delete contents in the directory first. | 403 // TODO (jwren) Delete contents in the directory first. |
| 401 Map<String, FileContentsComputer> map = directoryContentsComputer(); | 404 Map<String, FileContentsComputer> map = directoryContentsComputer(); |
| 402 map.forEach((String file, FileContentsComputer fileContentsComputer) { | 405 map.forEach((String file, FileContentsComputer fileContentsComputer) { |
| 403 File outputFile = new File(joinAll(posix.split(outputDirPath + file))); | 406 File outputFile = new File(joinAll(posix.split(outputDirPath + file))); |
| 404 outputFile.writeAsStringSync(fileContentsComputer()); | 407 outputFile.writeAsStringSync(fileContentsComputer()); |
| 405 }); | 408 }); |
| 406 } | 409 } |
| 407 } | 410 } |
| OLD | NEW |