Chromium Code Reviews| 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 final process = new Process.start(compilerPath, [ | 178 onExit(int exitCode, String stdout, String stderr) { |
| 179 if (exitCode != 0) { | |
| 180 final message = 'Non-zero exit code from $compilerPath'; | |
| 181 print('$message.'); | |
|
Bob Nystrom
2012/04/24 16:03:58
This is a bit strange. Why not just put the "." in
ahe
2012/04/25 08:26:55
I'm not sure how to format exception messages: Sho
Bob Nystrom
2012/04/25 18:03:41
I'd say whatever initially creates the exception m
| |
| 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, [ | |
| 179 '--libdir=$libDir', '--out=$jsPath', | 196 '--libdir=$libDir', '--out=$jsPath', |
| 180 '--compile-only', '--enable-type-checks', '--warnings-as-errors', | 197 '--compile-only', '--enable-type-checks', '--warnings-as-errors', |
| 181 dartPath]); | 198 dartPath], null, onExit).onError = onError; |
| 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 }; | |
| 189 } | 199 } |
| 190 | 200 |
| 191 class Dartdoc { | 201 class Dartdoc { |
| 192 | 202 |
| 193 /** Set to `false` to not include the source code in the generated docs. */ | 203 /** Set to `false` to not include the source code in the generated docs. */ |
| 194 bool includeSource = true; | 204 bool includeSource = true; |
| 195 | 205 |
| 196 /** | 206 /** |
| 197 * Dartdoc can generate docs in a few different ways based on how dynamic you | 207 * Dartdoc can generate docs in a few different ways based on how dynamic you |
| 198 * want the client-side behavior to be. The value for this should be one of | 208 * 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... | |
| 1280 | 1290 |
| 1281 return new md.Element.text('code', name); | 1291 return new md.Element.text('code', name); |
| 1282 } | 1292 } |
| 1283 | 1293 |
| 1284 // TODO(rnystrom): Move into SourceSpan? | 1294 // TODO(rnystrom): Move into SourceSpan? |
| 1285 int getSpanColumn(SourceSpan span) { | 1295 int getSpanColumn(SourceSpan span) { |
| 1286 final line = span.file.getLine(span.start); | 1296 final line = span.file.getLine(span.start); |
| 1287 return span.file.getColumn(line, span.start); | 1297 return span.file.getColumn(line, span.start); |
| 1288 } | 1298 } |
| 1289 } | 1299 } |
| OLD | NEW |