Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 18233004: Added a flag package-root for users to define where the package directory is. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/lib/src/dart2js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index a542195e43aaaae52ff286b23ccfc61d33b027cd..b7bfc68c83f1d51c137e02f7fcb7db76e8a8bb05 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,22 @@ 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');
+ }
+ // To avoid anaylzing package files twice, only files with paths not
+ // containing '/packages' will be added. The only exception is if 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 +159,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.
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/lib/src/dart2js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698