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

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

Issue 73893006: Don't rely on a package having a library by the same name in order to associate a readme (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove debug statements Created 7 years, 1 month 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 | « no previous file | 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 8f48f5f53e3aadab4eb24df5ebd85d34e203ad33..9dc9c8939dbd5b46369f3ac1c9288751cd601721 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -143,6 +143,13 @@ Future<bool> docgen(List<String> files, {String packageRoot,
/// If [library] is specified, we set the packageName field. If no package could
/// be determined, we return an empty string.
String _findPackage(LibraryMirror mirror, [Library library]) {
+ if (library == null) {
+ library = entityMap[mirror.simpleName];
+ }
+ if (library != null) {
+ if (library.hasBeenCheckedForPackage) return library.packageName;
+ library.hasBeenCheckedForPackage = true;
+ }
if (mirror.uri.scheme != 'file') return '';
var filePath = mirror.uri.toFilePath();
// We assume that we are documenting only libraries under package/lib
@@ -151,13 +158,10 @@ String _findPackage(LibraryMirror mirror, [Library library]) {
var packageName = _packageName(pubspec);
if (library != null) {
library.packageName = packageName;
- // If we are the main library in a package, associate the package readme
- // with us.
- // TODO(alanknight): We can't really rely on all packages having a library
- // that matches the package name. Need a better way to store this.
- if (library.packageName == library.name) {
- library.packageIntro = _packageIntro(rootdir);
- }
+ // Associate the package readme with all the libraries. This is a bit
+ // wasteful, but easier than trying to figure out which partial match
+ // is best.
+ library.packageIntro = _packageIntro(rootdir);
}
return packageName;
}
@@ -178,7 +182,6 @@ String _packageIntro(packageDir) {
return contents;
}
-
List<String> _listLibraries(List<String> args) {
var libraries = new List<String>();
for (var arg in args) {
@@ -868,6 +871,7 @@ class Library extends Indexable {
ClassGroup classes;
String packageName = '';
+ bool hasBeenCheckedForPackage = false;
String get packagePrefix => packageName == null || packageName.isEmpty
? ''
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698