Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index a542195e43aaaae52ff286b23ccfc61d33b027cd..af8540b49827aadeb237727fce58a822b80ea6e9 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -90,6 +90,8 @@ void _setCommandLineArguments(ArgResults argResults) { |
| includePrivate = argResults['include-private']; |
| parseSdk = argResults['parse-sdk']; |
| includeSdk = parseSdk || argResults['include-sdk']; |
| + packageDir = argResults['package-root']; |
| + if (packageDir != null) logger.info('Package Root: ${packageDir}'); |
| } |
| List<String> _listLibraries(List<String> args) { |
| @@ -106,17 +108,21 @@ List<String> _listLibraries(List<String> args) { |
| } else { |
| libraries.addAll(_listDartFromDir(args[0])); |
| } |
| - logger.info('Package Directory: $packageDir'); |
| return libraries; |
| } |
| List<String> _listDartFromDir(String args) { |
| var files = listDir(args, recursive: true); |
| - packageDir = files.firstWhere((f) => |
| - f.endsWith('/pubspec.yaml'), orElse: () => ''); |
| - if (packageDir != '') packageDir = path.dirname(packageDir) + '/packages'; |
| - return files.where((f) => |
| - f.endsWith('.dart') && !f.contains('/packages')).toList() |
| + if (packageDir == null) { |
| + packageDir = files.firstWhere((f) => |
| + f.endsWith('/pubspec.yaml'), orElse: () => ''); |
| + if (packageDir != '') packageDir = path.dirname(packageDir) + '/packages'; |
| + logger.info('Package Directory: $packageDir'); |
| + } |
| + // files with paths not containing '/packages' to avoid analyzing them twice, |
|
Emily Fortuna
2013/07/01 18:51:57
files -> Files
also make this an actual sentence
janicejl
2013/07/01 18:59:23
Done.
|
| + // unless the file to analyze already has a /package in its path. |
| + return files.where((f) => f.endsWith('.dart') && |
| + (!f.contains('/packages') || args.contains('/packages'))).toList() |
| ..forEach((lib) => logger.info('Added to libraries: $lib')); |
| } |
| @@ -152,6 +158,10 @@ Future<MirrorSystem> getMirrorSystem(List<String> args) { |
| return _getMirrorSystemHelper(libraries, sdkRoot, packageRoot: packageDir); |
| } |
| +// TODO(janicejl): Should make docgen fail gracefully, or output a friendly |
| +// error message letting them know why it is failing to create a mirror system. |
| +// If there is conflicting library names, should modify it with a hash at the |
| +// end of it's library name. |
| /** |
| * Analyzes set of libraries and provides a mirror system which can be used |
| * for static inspection of the source code. |