| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library docgen.generator; | 5 library docgen.generator; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void _documentLibraries(List<LibraryMirror> libs, bool includeSdk, | 176 void _documentLibraries(List<LibraryMirror> libs, bool includeSdk, |
| 177 bool parseSdk, String introFileName, String startPage, bool indentJson) { | 177 bool parseSdk, String introFileName, String startPage, bool indentJson) { |
| 178 libs.forEach((lib) { | 178 libs.forEach((lib) { |
| 179 // Files belonging to the SDK have a uri that begins with 'dart:'. | 179 // Files belonging to the SDK have a uri that begins with 'dart:'. |
| 180 if (includeSdk || !lib.uri.toString().startsWith('dart:')) { | 180 if (includeSdk || !lib.uri.toString().startsWith('dart:')) { |
| 181 generateLibrary(lib); | 181 generateLibrary(lib); |
| 182 } | 182 } |
| 183 }); | 183 }); |
| 184 | 184 |
| 185 var filteredEntities = new SplayTreeSet<Indexable>(_indexableComparer); | 185 var filteredEntities = new SplayTreeSet<Indexable>(_indexableComparer); |
| 186 for (Map<String, Set<Indexable>> firstLevel in mirrorToDocgen.values) { | 186 for (Indexable item in allIndexables) { |
| 187 for (Set<Indexable> items in firstLevel.values) { | 187 if (isFullChainVisible(item)) { |
| 188 for (Indexable item in items) { | 188 if (item is! Method || |
| 189 if (isFullChainVisible(item)) { | 189 (item is Method && item.methodInheritedFrom == null)) { |
| 190 if (item is! Method || | 190 filteredEntities.add(item); |
| 191 (item is Method && item.methodInheritedFrom == null)) { | |
| 192 filteredEntities.add(item); | |
| 193 } | |
| 194 } | |
| 195 } | 191 } |
| 196 } | 192 } |
| 197 } | 193 } |
| 198 | 194 |
| 199 // Outputs a JSON file with all libraries and their preview comments. | 195 // Outputs a JSON file with all libraries and their preview comments. |
| 200 // This will help the viewer know what libraries are available to read in. | 196 // This will help the viewer know what libraries are available to read in. |
| 201 Map<String, dynamic> libraryMap = { | 197 Map<String, dynamic> libraryMap = { |
| 202 'libraries': filteredEntities.where((e) => e is Library).map((e) => | 198 'libraries': filteredEntities.where((e) => e is Library).map((e) => |
| 203 e.previewMap).toList(), | 199 e.previewMap).toList(), |
| 204 'introduction': _readIntroductionFile(introFileName, includeSdk), | 200 'introduction': _readIntroductionFile(introFileName, includeSdk), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 _writeToFile(buffer.toString(), 'index.txt'); | 234 _writeToFile(buffer.toString(), 'index.txt'); |
| 239 | 235 |
| 240 var index = new SplayTreeMap.fromIterable(filteredEntities, | 236 var index = new SplayTreeMap.fromIterable(filteredEntities, |
| 241 key: (e) => e.qualifiedName, value: (e) => e.typeName); | 237 key: (e) => e.qualifiedName, value: (e) => e.typeName); |
| 242 | 238 |
| 243 _writeToFile(encoder.convert(index), 'index.json'); | 239 _writeToFile(encoder.convert(index), 'index.json'); |
| 244 } | 240 } |
| 245 | 241 |
| 246 /// Helper method to serialize the given Indexable out to a file. | 242 /// Helper method to serialize the given Indexable out to a file. |
| 247 void _writeIndexableToFile(Indexable result, JsonEncoder encoder) { | 243 void _writeIndexableToFile(Indexable result, JsonEncoder encoder) { |
| 248 var outputFile = result.fileName + '.json'; | 244 var outputFile = result.qualifiedName + '.json'; |
| 249 var output = encoder.convert(result.toMap()); | 245 var output = encoder.convert(result.toMap()); |
| 250 _writeToFile(output, outputFile); | 246 _writeToFile(output, outputFile); |
| 251 } | 247 } |
| 252 | 248 |
| 253 /// Set the location of the ouput directory, and ensure that the location is | 249 /// Set the location of the ouput directory, and ensure that the location is |
| 254 /// available on the file system. | 250 /// available on the file system. |
| 255 void _ensureOutputDirectory(String outputDirectory) { | 251 void _ensureOutputDirectory(String outputDirectory) { |
| 256 _outputDirectory = outputDirectory; | 252 _outputDirectory = outputDirectory; |
| 257 var dir = new Directory(_outputDirectory); | 253 var dir = new Directory(_outputDirectory); |
| 258 if (dir.existsSync()) dir.deleteSync(recursive: true); | 254 if (dir.existsSync()) dir.deleteSync(recursive: true); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 * [Samples](http://www.dartlang.org/samples/) | 457 * [Samples](http://www.dartlang.org/samples/) |
| 462 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn
ing/contents/ch03.html) | 458 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn
ing/contents/ch03.html) |
| 463 | 459 |
| 464 This API reference is automatically generated from the source code in the | 460 This API reference is automatically generated from the source code in the |
| 465 [Dart project](https://code.google.com/p/dart/). | 461 [Dart project](https://code.google.com/p/dart/). |
| 466 If you'd like to contribute to this documentation, see | 462 If you'd like to contribute to this documentation, see |
| 467 [Contributing](https://code.google.com/p/dart/wiki/Contributing) | 463 [Contributing](https://code.google.com/p/dart/wiki/Contributing) |
| 468 and | 464 and |
| 469 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume
ntation). | 465 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume
ntation). |
| 470 """; | 466 """; |
| OLD | NEW |