| Index: sdk/lib/_internal/dartdoc/lib/dartdoc.dart
|
| diff --git a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
|
| index cf35cd9cd01dab76e413066406468fbb63abd1fc..f258f1d989308be7abbd9ffcd357119873bc14c0 100644
|
| --- a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
|
| +++ b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
|
| @@ -293,26 +293,20 @@ class Dartdoc {
|
| /** The package root for `package:` imports. */
|
| String _packageRoot;
|
|
|
| - /** The map containing all the exports for each library. */
|
| - ExportMap _exports;
|
| -
|
| /**
|
| * This list contains the libraries sorted in by the library name.
|
| */
|
| List<LibraryMirror> _sortedLibraries;
|
|
|
| - /** A map from absolute paths of libraries to the libraries at those paths. */
|
| - Map<String, LibraryMirror> _librariesByPath;
|
| -
|
| /**
|
| - * A map from absolute paths of hidden libraries to lists of [Export]s that
|
| - * export those libraries from visible libraries. This is used to determine
|
| - * what public library any given entity belongs to.
|
| + * A map from hidden libraries to lists of [Export]s that export those
|
| + * libraries from visible libraries. This is used to determine what public
|
| + * library any given entity belongs to.
|
| *
|
| * The lists of exports are sorted so that exports that hide the fewest number
|
| * of members come first.
|
| */
|
| - Map<String, List<Export>> _hiddenLibraryExports;
|
| + Map<LibraryMirror, List<Export>> _hiddenLibraryExports;
|
|
|
| /** The library that we're currently generating docs for. */
|
| LibraryMirror _currentLibrary;
|
| @@ -454,13 +448,6 @@ class Dartdoc {
|
| Future documentLibraries(List<Uri> libraryList, Path libPath,
|
| String packageRoot) {
|
| _packageRoot = packageRoot;
|
| - _exports = new ExportMap.parse(libraryList, packageRoot);
|
| - var librariesToAnalyze = _exports.allExportedFiles.toList();
|
| - librariesToAnalyze.addAll(libraryList.map((uri) {
|
| - if (uri.scheme == 'file') return fileUriToPath(uri);
|
| - // dart2js takes "dart:*" URIs as Path objects for some reason.
|
| - return uri.toString();
|
| - }));
|
|
|
| var packageRootPath = packageRoot == null ? null : new Path(packageRoot);
|
|
|
| @@ -468,8 +455,8 @@ class Dartdoc {
|
| // statements.
|
| print('Analyzing libraries...');
|
| return dart2js.analyze(
|
| - librariesToAnalyze.map((path) => new Path(path)).toList(), libPath,
|
| - packageRoot: packageRootPath, options: COMPILER_OPTIONS)
|
| + libraryList.map((Uri path) => new Path(path.toString())).toList(),
|
| + libPath, packageRoot: packageRootPath, options: COMPILER_OPTIONS)
|
| .then((MirrorSystem mirrors) {
|
| print('Generating documentation...');
|
| _document(mirrors);
|
| @@ -487,14 +474,6 @@ class Dartdoc {
|
| displayName(y).toUpperCase());
|
| });
|
|
|
| - _librariesByPath = <String, LibraryMirror>{};
|
| - for (var library in mirrors.libraries.values) {
|
| - var path = _libraryPath(library);
|
| - if (path == null) continue;
|
| - path = pathos.normalize(pathos.absolute(path));
|
| - _librariesByPath[path] = library;
|
| - }
|
| -
|
| _hiddenLibraryExports = _generateHiddenLibraryExports();
|
|
|
| // Generate the docs.
|
| @@ -555,39 +534,37 @@ class Dartdoc {
|
| /**
|
| * Generate [_hiddenLibraryExports] from [_exports] and [_librariesByPath].
|
| */
|
| - Map<String, List<Export>> _generateHiddenLibraryExports() {
|
| + Map<LibraryMirror, List<Export>> _generateHiddenLibraryExports() {
|
| // First generate a map `exported path => exporter path => Export`. The
|
| // inner map makes it easier to merge multiple exports of the same library
|
| // by the same exporter.
|
| - var hiddenLibraryExportMaps = <String, Map<String, Export>>{};
|
| - _exports.exports.forEach((exporter, exports) {
|
| - var library = _librariesByPath[exporter];
|
| - // TODO(nweiz): remove this check when issue 9645 is fixed.
|
| - if (library == null) return;
|
| - if (!shouldIncludeLibrary(library)) return;
|
| - for (var export in exports) {
|
| - var library = _librariesByPath[export.path];
|
| - // TODO(nweiz): remove this check when issue 9645 is fixed.
|
| - if (library == null) continue;
|
| - if (shouldIncludeLibrary(library)) continue;
|
| -
|
| - var hiddenExports = _exports.transitiveExports(export.path)
|
| + var hiddenLibraryExportMaps =
|
| + new Map<LibraryMirror, Map<LibraryMirror, Export>>();
|
| +
|
| + for (LibraryMirror exportingLibrary in _sortedLibraries) {
|
| + if (!shouldIncludeLibrary(exportingLibrary)) continue;
|
| + for (var mirror in exportingLibrary.libraryDependencies) {
|
| + if (!mirror.isExport) continue;
|
| + if (shouldIncludeLibrary(mirror.targetLibrary)) continue;
|
| + Export export = new Export(mirror);
|
| + List<Export> hiddenExports = getExports(mirror.targetLibrary)
|
| + .map((mirror) => new Export(mirror))
|
| .map((transitiveExport) => export.compose(transitiveExport))
|
| .toList();
|
| hiddenExports.add(export);
|
|
|
| - for (var hiddenExport in hiddenExports) {
|
| - var exportsByExporterPath = hiddenLibraryExportMaps
|
| - .putIfAbsent(hiddenExport.path, () => <String, Export>{});
|
| - addOrMergeExport(exportsByExporterPath, exporter, hiddenExport);
|
| + for (Export hiddenExport in hiddenExports) {
|
| + var exportsByExporter = hiddenLibraryExportMaps.putIfAbsent(
|
| + hiddenExport.exported, () => new Map<LibraryMirror, Export>());
|
| + addOrMergeExport(exportsByExporter, exportingLibrary, hiddenExport);
|
| }
|
| }
|
| - });
|
| + }
|
|
|
| // Now sort the values of the inner maps of `hiddenLibraryExportMaps` to get
|
| // the final value of `_hiddenLibraryExports`.
|
| - var hiddenLibraryExports = <String, List<Export>>{};
|
| - hiddenLibraryExportMaps.forEach((exporteePath, exportsByExporterPath) {
|
| + var hiddenLibraryExports = new Map<LibraryMirror, List<Export>>();
|
| + hiddenLibraryExportMaps.forEach((exportee, exportsByExporter) {
|
| int rank(Export export) {
|
| if (export.show.isEmpty && export.hide.isEmpty) return 0;
|
| if (export.show.isEmpty) return export.hide.length;
|
| @@ -595,16 +572,16 @@ class Dartdoc {
|
| return 1000 * export.show.length;
|
| }
|
|
|
| - var exports = exportsByExporterPath.values.toList();
|
| + var exports = exportsByExporter.values.toList();
|
| exports.sort((export1, export2) {
|
| var comparison = Comparable.compare(rank(export1), rank(export2));
|
| if (comparison != 0) return comparison;
|
|
|
| - var library1 = _librariesByPath[export1.exporter];
|
| - var library2 = _librariesByPath[export2.exporter];
|
| + var library1 = export1.exporter;
|
| + var library2 = export2.exporter;
|
| return Comparable.compare(library1.displayName, library2.displayName);
|
| });
|
| - hiddenLibraryExports[exporteePath] = exports;
|
| + hiddenLibraryExports[exportee] = exports;
|
| });
|
| return hiddenLibraryExports;
|
| }
|
| @@ -1279,15 +1256,13 @@ class Dartdoc {
|
| }();
|
|
|
| void docExports(LibraryMirror library) {
|
| - // TODO(nweiz): show `dart:` library exports.
|
| - var exportLinks = _exports.transitiveExports(_libraryPath(library))
|
| - .map((export) {
|
| - var library = _librariesByPath[export.path];
|
| - // TODO(nweiz): remove this check when issue 9645 is fixed.
|
| - if (library == null) return null;
|
| + var exportLinks = getExports(library)
|
| + .map((LibraryDependencyMirror mirror) {
|
| + LibraryMirror library = mirror.targetLibrary;
|
| // Only link to publically visible libraries.
|
| if (!shouldIncludeLibrary(library)) return null;
|
|
|
| + Export export = new Export(mirror);
|
| var memberNames = export.show.isEmpty ? export.hide : export.show;
|
| var memberLinks = memberNames.map((name) {
|
| return md.renderToHtml([resolveNameReference(
|
| @@ -1301,7 +1276,7 @@ class Dartdoc {
|
| }
|
|
|
| return '<ul>${a(libraryUrl(library), displayName(library))}'
|
| - '$combinator</ul>';
|
| + '$combinator</ul>';
|
| }).where((link) => link != null);
|
|
|
| if (!exportLinks.isEmpty) {
|
| @@ -2177,14 +2152,13 @@ class Dartdoc {
|
| List<DeclarationMirror> _libraryContents(LibraryMirror library,
|
| List<DeclarationMirror> fn(LibraryMirror)) {
|
| var contents = fn(library).toList();
|
| - var path = _libraryPath(library);
|
| - if (path == null || _exports.exports[path] == null) return contents;
|
| + var exports = getExports(library);
|
| + if (exports.isEmpty) return contents;
|
|
|
|
|
| - contents.addAll(_exports.exports[path].expand((export) {
|
| - var exportedLibrary = _librariesByPath[export.path];
|
| - // TODO(nweiz): remove this check when issue 9645 is fixed.
|
| - if (exportedLibrary == null) return [];
|
| + contents.addAll(
|
| + exports.map((mirror) => new Export(mirror)).expand((export) {
|
| + var exportedLibrary = export.exported;
|
| if (shouldIncludeLibrary(exportedLibrary)) return [];
|
| return fn(exportedLibrary).where((declaration) =>
|
| export.isMemberVisible(declaration.displayName));
|
| @@ -2217,14 +2191,14 @@ class Dartdoc {
|
| LibraryMirror _visibleLibrary(LibraryMirror library, String name) {
|
| if (library == null) return null;
|
|
|
| - var exports = _hiddenLibraryExports[_libraryPath(library)];
|
| + var exports = _hiddenLibraryExports[library];
|
| if (exports == null) return library;
|
|
|
| var export = exports.firstWhere(
|
| (exp) => exp.isMemberVisible(name),
|
| orElse: () => null);
|
| if (export == null) return library;
|
| - return _librariesByPath[export.exporter];
|
| + return export.exporter;
|
| }
|
| }
|
|
|
|
|