Chromium Code Reviews| 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 library docgen.generator; | 5 library docgen.generator; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 /// available on the file system. | 259 /// available on the file system. |
| 260 void _ensureOutputDirectory(String outputDirectory) { | 260 void _ensureOutputDirectory(String outputDirectory) { |
| 261 _outputDirectory = outputDirectory; | 261 _outputDirectory = outputDirectory; |
| 262 var dir = new Directory(_outputDirectory); | 262 var dir = new Directory(_outputDirectory); |
| 263 if (dir.existsSync()) dir.deleteSync(recursive: true); | 263 if (dir.existsSync()) dir.deleteSync(recursive: true); |
| 264 } | 264 } |
| 265 | 265 |
| 266 /// Analyzes set of libraries and provides a mirror system which can be used | 266 /// Analyzes set of libraries and provides a mirror system which can be used |
| 267 /// for static inspection of the source code. | 267 /// for static inspection of the source code. |
| 268 Future<MirrorSystem> analyzeLibraries(List<Uri> libraries, String | 268 Future<MirrorSystem> analyzeLibraries(List<Uri> libraries, String |
| 269 libraryRoot, {String packageRoot}) { | 269 libraryRoot, {String packageRoot}) async { |
| 270 SourceFileProvider provider = new CompilerSourceFileProvider(); | 270 SourceFileProvider provider = new CompilerSourceFileProvider(); |
| 271 api.DiagnosticHandler diagnosticHandler = new FormattingDiagnosticHandler( | 271 api.DiagnosticHandler diagnosticHandler = new FormattingDiagnosticHandler( |
| 272 provider) | 272 provider) |
| 273 ..showHints = false | 273 ..showHints = false |
| 274 ..showWarnings = false; | 274 ..showWarnings = false; |
| 275 Uri libraryUri = new Uri.file(appendSlash(libraryRoot)); | 275 Uri libraryUri = new Uri.file(appendSlash(libraryRoot)); |
| 276 Uri packageUri = null; | 276 Uri packageUri = null; |
| 277 if (packageRoot == null) { | 277 if (packageRoot != null) { |
| 278 packageRoot = Platform.packageRoot; | 278 packageUri = new Uri.file(appendSlash(packageRoot)); |
| 279 } else { | |
| 280 packageUri = await Platform.packageRoot; | |
| 279 } | 281 } |
| 280 packageUri = new Uri.file(appendSlash(packageRoot)); | 282 try { |
| 281 return dart2js.analyze(libraries, libraryUri, packageUri, | 283 return await dart2js.analyze(libraries, libraryUri, packageUri, |
| 282 provider.readStringFromUri, diagnosticHandler, ['--preserve-comments', | 284 provider.readStringFromUri, diagnosticHandler, ['--preserve-comments', |
| 283 '--categories=Client,Server'])..catchError((error) { | 285 '--categories=Client,Server']); |
|
Lasse Reichstein Nielsen
2015/09/22 09:48:25
I'm not sure what the ".." does here. It's ... sus
| |
| 284 logger.severe('Error: Failed to create mirror system. '); | 286 } catch (error) { |
| 285 // TODO(janicejl): Use the stack trace package when bug is resolved. | 287 logger.severe('Error: Failed to create mirror system. '); |
| 286 // Currently, a string is thrown when it fails to create a mirror | 288 // TODO(janicejl): Use the stack trace package when bug is resolved. |
| 287 // system, and it is not possible to use the stack trace. BUG(#11622) | 289 // Currently, a string is thrown when it fails to create a mirror |
| 288 // To avoid printing the stack trace. | 290 // system, and it is not possible to use the stack trace. BUG(#11622) |
| 289 exit(1); | 291 // To avoid printing the stack trace. |
| 290 }); | 292 exit(1); |
| 293 } | |
|
Lasse Reichstein Nielsen
2015/09/22 09:48:25
This is slightly different from the original becau
| |
| 291 } | 294 } |
| 292 | 295 |
| 293 /// For this run of docgen, determine the packageRoot value. | 296 /// For this run of docgen, determine the packageRoot value. |
| 294 /// | 297 /// |
| 295 /// If packageRoot is not explicitly passed, we examine the files we're | 298 /// If packageRoot is not explicitly passed, we examine the files we're |
| 296 /// documenting to attempt to find a package root. | 299 /// documenting to attempt to find a package root. |
| 297 String _obtainPackageRoot(String packageRoot, bool parseSdk, | 300 String _obtainPackageRoot(String packageRoot, bool parseSdk, |
| 298 List<String> files) { | 301 List<String> files) { |
| 299 if (packageRoot == null && !parseSdk) { | 302 if (packageRoot == null && !parseSdk) { |
| 300 var type = FileSystemEntity.typeSync(files.first); | 303 var type = FileSystemEntity.typeSync(files.first); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 * [Samples](http://www.dartlang.org/samples/) | 481 * [Samples](http://www.dartlang.org/samples/) |
| 479 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html) | 482 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html) |
| 480 | 483 |
| 481 This API reference is automatically generated from the source code in the | 484 This API reference is automatically generated from the source code in the |
| 482 [Dart project](https://code.google.com/p/dart/). | 485 [Dart project](https://code.google.com/p/dart/). |
| 483 If you'd like to contribute to this documentation, see | 486 If you'd like to contribute to this documentation, see |
| 484 [Contributing](https://code.google.com/p/dart/wiki/Contributing) | 487 [Contributing](https://code.google.com/p/dart/wiki/Contributing) |
| 485 and | 488 and |
| 486 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation). | 489 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation). |
| 487 """; | 490 """; |
| OLD | NEW |