| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
| 7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
| 8 * | 8 * |
| 9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
| 10 * | 10 * |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 421 } |
| 422 content += '<div>${footerItems[i]}</div>'; | 422 content += '<div>${footerItems[i]}</div>'; |
| 423 } | 423 } |
| 424 return content; | 424 return content; |
| 425 } | 425 } |
| 426 | 426 |
| 427 Future documentLibraries(List<Uri> libraryList, Path libPath, | 427 Future documentLibraries(List<Uri> libraryList, Path libPath, |
| 428 String packageRoot) { | 428 String packageRoot) { |
| 429 _packageRoot = packageRoot; | 429 _packageRoot = packageRoot; |
| 430 _exports = new ExportMap.parse(libraryList, packageRoot); | 430 _exports = new ExportMap.parse(libraryList, packageRoot); |
| 431 var librariesToAnalyze = _exports.allExportedFiles.map(pathToFileUri); | 431 var librariesToAnalyze = _exports.allExportedFiles.toList(); |
| 432 librariesToAnalyze.addAll(libraryList.map((uri) { | 432 librariesToAnalyze.addAll(libraryList.map((uri) { |
| 433 if (uri.scheme == 'file') return fileUriToPath(uri); | 433 if (uri.scheme == 'file') return fileUriToPath(uri); |
| 434 // dart2js takes "dart:*" URIs as Path objects for some reason. | 434 // dart2js takes "dart:*" URIs as Path objects for some reason. |
| 435 return uri.toString(); | 435 return uri.toString(); |
| 436 }); | 436 })); |
| 437 | 437 |
| 438 // TODO(amouravski): make all of these print statements into logging | 438 // TODO(amouravski): make all of these print statements into logging |
| 439 // statements. | 439 // statements. |
| 440 print('Analyzing libraries...'); | 440 print('Analyzing libraries...'); |
| 441 return dart2js.analyze( | 441 return dart2js.analyze( |
| 442 librariesToAnalyze.map((path) => new Path(path)).toList(), libPath, | 442 librariesToAnalyze.map((path) => new Path(path)).toList(), libPath, |
| 443 packageRoot: new Path(packageRoot), options: COMPILER_OPTIONS) | 443 packageRoot: new Path(packageRoot), options: COMPILER_OPTIONS) |
| 444 .then((MirrorSystem mirrors) { | 444 .then((MirrorSystem mirrors) { |
| 445 print('Generating documentation...'); | 445 print('Generating documentation...'); |
| 446 _document(mirrors); | 446 _document(mirrors); |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 | 2141 |
| 2142 | 2142 |
| 2143 /** | 2143 /** |
| 2144 * Returns a list of elements in [library], including elements it exports from | 2144 * Returns a list of elements in [library], including elements it exports from |
| 2145 * hidden libraries. [fn] should return the element list for a single library, | 2145 * hidden libraries. [fn] should return the element list for a single library, |
| 2146 * which will then be merged across all exported libraries. | 2146 * which will then be merged across all exported libraries. |
| 2147 */ | 2147 */ |
| 2148 List<DeclarationMirror> _libraryContents(LibraryMirror library, | 2148 List<DeclarationMirror> _libraryContents(LibraryMirror library, |
| 2149 List<DeclarationMirror> fn(LibraryMirror)) { | 2149 List<DeclarationMirror> fn(LibraryMirror)) { |
| 2150 var contents = fn(library).toList(); | 2150 var contents = fn(library).toList(); |
| 2151 contents.addAll(_exports.exports[_libraryPath(library)].expand((export) { | 2151 var path = _libraryPath(library); |
| 2152 if (path == null) return contents; |
| 2153 |
| 2154 contents.addAll(_exports.exports[path].expand((export) { |
| 2152 var exportedLibrary = _librariesByPath[export.path]; | 2155 var exportedLibrary = _librariesByPath[export.path]; |
| 2153 // TODO(nweiz): remove this check when issue 9645 is fixed. | 2156 // TODO(nweiz): remove this check when issue 9645 is fixed. |
| 2154 if (exportedLibrary == null) return []; | 2157 if (exportedLibrary == null) return []; |
| 2155 if (shouldIncludeLibrary(exportedLibrary)) return []; | 2158 if (shouldIncludeLibrary(exportedLibrary)) return []; |
| 2156 return fn(exportedLibrary).where((declaration) => | 2159 return fn(exportedLibrary).where((declaration) => |
| 2157 export.isMemberVisible(declaration.displayName)); | 2160 export.isMemberVisible(declaration.displayName)); |
| 2158 })); | 2161 })); |
| 2159 return contents; | 2162 return contents; |
| 2160 } | 2163 } |
| 2161 | 2164 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2283 return ''' | 2286 return ''' |
| 2284 <div class="mdn"> | 2287 <div class="mdn"> |
| 2285 $mdnComment | 2288 $mdnComment |
| 2286 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 2289 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
| 2287 </div> | 2290 </div> |
| 2288 '''; | 2291 '''; |
| 2289 } | 2292 } |
| 2290 | 2293 |
| 2291 String toString() => mdnComment; | 2294 String toString() => mdnComment; |
| 2292 } | 2295 } |
| OLD | NEW |