Chromium Code Reviews| Index: pkg/dartdoc/lib/dartdoc.dart |
| diff --git a/pkg/dartdoc/lib/dartdoc.dart b/pkg/dartdoc/lib/dartdoc.dart |
| index 96db2d96cf850dbe94bb1c13786ba1a3a3dac07a..4da6de2df845dd0155306b9e60961511e7d0e972 100644 |
| --- a/pkg/dartdoc/lib/dartdoc.dart |
| +++ b/pkg/dartdoc/lib/dartdoc.dart |
| @@ -89,6 +89,12 @@ void cleanOutputDirectory(Path path) { |
| } |
| } |
| +/** Returns the printed name of the library. */ |
| +String printedName(LibraryMirror library) { |
|
Bob Nystrom
2012/10/24 20:52:15
"printed" might be a bit too specific. Maybe "disp
Andrei Mouravski
2012/10/24 21:19:36
Done.
|
| + var uri = library.uri.toString(); |
| + return uri.startsWith('dart:') ? uri.toString() : library.simpleName; |
| +} |
| + |
| /** |
| * Copies all of the files in the directory [from] to [to]. Does *not* |
| * recursively copy subdirectories. |
| @@ -257,7 +263,7 @@ class Dartdoc { |
| return false; |
| } |
| var includeByDefault = true; |
| - String libraryName = library.simpleName; |
| + String libraryName = printedName(library); |
| if (!includedLibraries.isEmpty) { |
| includeByDefault = false; |
| if (includedLibraries.indexOf(libraryName) != -1) { |
| @@ -283,7 +289,7 @@ class Dartdoc { |
| */ |
| bool shouldLinkToPublicApi(LibraryMirror library) { |
| if (linkToApi) { |
| - String libraryName = library.simpleName; |
| + String libraryName = printedName(library); |
| if (libraryName.startsWith('dart:')) { |
| String suffix = libraryName.substring('dart:'.length); |
| LibraryInfo info = LIBRARIES[suffix]; |
| @@ -329,8 +335,8 @@ class Dartdoc { |
| compilation.mirrors.libraries.getValues().filter( |
| shouldIncludeLibrary)); |
| _sortedLibraries.sort((x, y) { |
| - return x.simpleName.toUpperCase().compareTo( |
| - y.simpleName.toUpperCase()); |
| + return printedName(x).toUpperCase().compareTo( |
| + printedName(y).toUpperCase()); |
| }); |
| // Generate the docs. |
| @@ -410,7 +416,7 @@ class Dartdoc { |
| var data = ''; |
| if (_currentLibrary != null) { |
| data = '$data data-library=' |
| - '"${md.escapeHtml(_currentLibrary.simpleName)}"'; |
| + '"${md.escapeHtml(printedName(_currentLibrary))}"'; |
| } |
| if (_currentType != null) { |
| @@ -519,7 +525,7 @@ class Dartdoc { |
| } |
| void docIndexLibrary(LibraryMirror library) { |
| - writeln('<h4>${a(libraryUrl(library), library.simpleName)}</h4>'); |
| + writeln('<h4>${a(libraryUrl(library), printedName(library))}</h4>'); |
| } |
| /** |
| @@ -570,7 +576,7 @@ class Dartdoc { |
| void docLibraryNavigationJson(LibraryMirror library, List libraryList) { |
| var libraryInfo = {}; |
| - libraryInfo[NAME] = library.simpleName; |
| + libraryInfo[NAME] = printedName(library); |
| final List members = docMembersJson(library.declaredMembers); |
| if (!members.isEmpty) { |
| libraryInfo[MEMBERS] = members; |
| @@ -655,9 +661,9 @@ class Dartdoc { |
| write('<h2><div class="icon-library"></div>'); |
| if ((_currentLibrary == library) && (_currentType == null)) { |
| - write('<strong>${library.simpleName}</strong>'); |
| + write('<strong>${printedName(library)}</strong>'); |
| } else { |
| - write('${a(libraryUrl(library), library.simpleName)}'); |
| + write('${a(libraryUrl(library), printedName(library))}'); |
| } |
| write('</h2>'); |
| @@ -715,16 +721,16 @@ class Dartdoc { |
| void docLibrary(LibraryMirror library) { |
| if (verbose) { |
| - print('Library \'${library.simpleName}\':'); |
| + print('Library \'${printedName(library)}\':'); |
| } |
| _totalLibraries++; |
| _currentLibrary = library; |
| _currentType = null; |
| startFile(libraryUrl(library)); |
| - writeHeader('${library.simpleName} Library', |
| - [library.simpleName, libraryUrl(library)]); |
| - writeln('<h2><strong>${library.simpleName}</strong> library</h2>'); |
| + writeHeader('${printedName(library)} Library', |
| + [printedName(library), libraryUrl(library)]); |
| + writeln('<h2><strong>${printedName(library)}</strong> library</h2>'); |
| // Look for a comment for the entire library. |
| final comment = getLibraryComment(library); |
| @@ -813,8 +819,8 @@ class Dartdoc { |
| final typeTitle = |
| '${typeName(type)} ${kind}'; |
| - writeHeader('$typeTitle / ${type.library.simpleName} Library', |
| - [type.library.simpleName, libraryUrl(type.library), |
| + writeHeader('$typeTitle / ${printedName(type.library)} Library', |
| + [printedName(type.library), libraryUrl(type.library), |
| typeName(type), typeUrl(type)]); |
| writeln( |
| ''' |
| @@ -1512,7 +1518,7 @@ class Dartdoc { |
| /** Gets the URL to the documentation for [library]. */ |
| String libraryUrl(LibraryMirror library) { |
| - return '${sanitize(library.simpleName)}.html'; |
| + return '${sanitize(printedName(library))}.html'; |
| } |
| /** Gets the URL for the documentation for [type]. */ |
| @@ -1524,7 +1530,7 @@ class Dartdoc { |
| // Always get the generic type to strip off any type parameters or |
| // arguments. If the type isn't generic, genericType returns `this`, so it |
| // works for non-generic types too. |
| - return '${sanitize(type.library.simpleName)}/' |
| + return '${sanitize(printedName(type.library))}/' |
| '${type.declaration.simpleName}.html'; |
| } |