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

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

Issue 158833005: Use reasonable defaults for docgen if invoked on a single package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make options just default the right way. Fix startPage -> start-page Created 6 years, 10 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
« pkg/docgen/bin/docgen.dart ('K') | « pkg/docgen/bin/docgen.dart ('k') | no next file » | 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 9b1e79783f0eef247cea82a934b2a041dc5ba416..d316780fd4e16c639c3e3d74768e2278cbdca542 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -411,7 +411,7 @@ class _Generator {
static void _writeOutputFiles(libraryMap,
Iterable<Indexable> filteredEntities, bool outputToYaml, bool append,
String startPage) {
- if (startPage != null) libraryMap['startPage'] = startPage;
+ if (startPage != null) libraryMap['start-page'] = startPage;
_writeToFile(JSON.encode(libraryMap), 'library_list.json');
@@ -591,7 +591,10 @@ class _Generator {
}
/// All of the directories for our dependent packages
+ /// If this is not a package, return an empty list.
static List<String> _allDependentPackageDirs(String packageDirectory) {
+ var packageName = Library.packageNameFor(packageDirectory);
+ if (packageName == '') return [];
var dependentsJson = Process.runSync('pub', ['list-package-dirs'],
workingDirectory: packageDirectory, runInShell: true);
if (dependentsJson.exitCode != 0) {
@@ -1394,11 +1397,16 @@ class Library extends Indexable {
static String _getRootdir(LibraryMirror mirror) =>
path.dirname(path.dirname(mirror.uri.toFilePath()));
- /// Read a pubspec and return the library name.
+ /// Read a pubspec and return the library name given a [LibraryMirror].
static String _packageName(LibraryMirror mirror) {
if (mirror.uri.scheme != 'file') return '';
var rootdir = _getRootdir(mirror);
- var pubspecName = path.join(rootdir, 'pubspec.yaml');
+ return packageNameFor(rootdir);
+ }
+
+ /// Read a pubspec and return the library name, given a directory
+ static String packageNameFor(String directoryName) {
+ var pubspecName = path.join(directoryName, 'pubspec.yaml');
File pubspec = new File(pubspecName);
if (!pubspec.existsSync()) return '';
var contents = pubspec.readAsStringSync();
« pkg/docgen/bin/docgen.dart ('K') | « pkg/docgen/bin/docgen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698