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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 // The entrypoint of the library to generate docs for. | 89 // The entrypoint of the library to generate docs for. |
| 90 final entrypoint = args[args.length - 1]; | 90 final entrypoint = args[args.length - 1]; |
| 91 | 91 |
| 92 final files = new VMFileSystem(); | 92 final files = new VMFileSystem(); |
| 93 | 93 |
| 94 // TODO(rnystrom): Note that the following lines get munged by create-sdk to | 94 // TODO(rnystrom): Note that the following lines get munged by create-sdk to |
| 95 // work with the SDK's different file layout. If you change, be sure to test | 95 // work with the SDK's different file layout. If you change, be sure to test |
| 96 // that dartdoc still works when run from the built SDK directory. | 96 // that dartdoc still works when run from the built SDK directory. |
| 97 final frogPath = joinPaths(scriptDir, '../../frog/'); | 97 final frogPath = joinPaths(scriptDir, '../../frog/'); |
| 98 final libDir = joinPaths(frogPath, 'lib'); | 98 final libDir = joinPaths(frogPath, 'lib'); |
| 99 final compilerPath = joinPaths(frogPath, 'minfrog'); | 99 final compilerPath = joinPaths(frogPath, 'minfrog'); |
|
Jennifer Messerly
2012/04/25 17:32:33
FYI, there's still a reference to minfrog here. Da
| |
| 100 | 100 |
| 101 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); | 101 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); |
| 102 initializeWorld(files); | 102 initializeWorld(files); |
| 103 | 103 |
| 104 final dartdoc = new Dartdoc(); | 104 final dartdoc = new Dartdoc(); |
| 105 | 105 |
| 106 if (includeSource != null) dartdoc.includeSource = includeSource; | 106 if (includeSource != null) dartdoc.includeSource = includeSource; |
| 107 if (mode != null) dartdoc.mode = mode; | 107 if (mode != null) dartdoc.mode = mode; |
| 108 if (outputDir != null) dartdoc.outputDir = outputDir; | 108 if (outputDir != null) dartdoc.outputDir = outputDir; |
| 109 | 109 |
| (...skipping 58 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.'); | |
| 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 |