| 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 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
| 7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
| 8 * | 8 * |
| 9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
| 10 * | 10 * |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 }; | 168 }; |
| 169 fromDir.list(recursive: false); | 169 fromDir.list(recursive: false); |
| 170 } | 170 } |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * Compiles the given Dart script to a JavaScript file at [jsPath] using the | 173 * Compiles the given Dart script to a JavaScript file at [jsPath] using the |
| 174 * Dart-to-JS compiler located at [compilerPath]. | 174 * Dart-to-JS compiler located at [compilerPath]. |
| 175 */ | 175 */ |
| 176 void compileScript(String compilerPath, String libDir, | 176 void compileScript(String compilerPath, String libDir, |
| 177 String dartPath, String jsPath) { | 177 String dartPath, String jsPath) { |
| 178 onExit(int exitCode, String stdout, String stderr) { | 178 final process = new Process.start(compilerPath, [ |
| 179 if (exitCode != 0) { | |
| 180 final message = 'Non-zero exit code from $compilerPath'; | |
| 181 print('$message.'); | |
| 182 print(stdout); | |
| 183 print(stderr); | |
| 184 throw message; | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 onError(error) { | |
| 189 final message = 'Error trying to execute $compilerPath. Error: $error'; | |
| 190 print('$message.'); | |
| 191 throw message; | |
| 192 } | |
| 193 | |
| 194 print('Compiling $dartPath to $jsPath'); | |
| 195 new Process.run(compilerPath, [ | |
| 196 '--libdir=$libDir', '--out=$jsPath', | 179 '--libdir=$libDir', '--out=$jsPath', |
| 197 '--compile-only', '--enable-type-checks', '--warnings-as-errors', | 180 '--compile-only', '--enable-type-checks', '--warnings-as-errors', |
| 198 dartPath], null, onExit).onError = onError; | 181 dartPath]); |
| 182 |
| 183 process.stdout.pipe(stdout, close: false); |
| 184 |
| 185 process.onError = (error) { |
| 186 print('Failed to compile $dartPath with $compilerPath. Error:'); |
| 187 print(error); |
| 188 }; |
| 199 } | 189 } |
| 200 | 190 |
| 201 class Dartdoc { | 191 class Dartdoc { |
| 202 | 192 |
| 203 /** Set to `false` to not include the source code in the generated docs. */ | 193 /** Set to `false` to not include the source code in the generated docs. */ |
| 204 bool includeSource = true; | 194 bool includeSource = true; |
| 205 | 195 |
| 206 /** | 196 /** |
| 207 * Dartdoc can generate docs in a few different ways based on how dynamic you | 197 * Dartdoc can generate docs in a few different ways based on how dynamic you |
| 208 * want the client-side behavior to be. The value for this should be one of | 198 * want the client-side behavior to be. The value for this should be one of |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 | 1280 |
| 1291 return new md.Element.text('code', name); | 1281 return new md.Element.text('code', name); |
| 1292 } | 1282 } |
| 1293 | 1283 |
| 1294 // TODO(rnystrom): Move into SourceSpan? | 1284 // TODO(rnystrom): Move into SourceSpan? |
| 1295 int getSpanColumn(SourceSpan span) { | 1285 int getSpanColumn(SourceSpan span) { |
| 1296 final line = span.file.getLine(span.start); | 1286 final line = span.file.getLine(span.start); |
| 1297 return span.file.getColumn(line, span.start); | 1287 return span.file.getColumn(line, span.start); |
| 1298 } | 1288 } |
| 1299 } | 1289 } |
| OLD | NEW |