| 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 * **docgen** is a tool for creating machine readable representations of Dart | 6 * **docgen** is a tool for creating machine readable representations of Dart |
| 7 * code metadata, including: classes, members, comments and annotations. | 7 * code metadata, including: classes, members, comments and annotations. |
| 8 * | 8 * |
| 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. | 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 10 * | 10 * |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 logger.info('Package Root: ${packageRoot}'); | 90 logger.info('Package Root: ${packageRoot}'); |
| 91 | 91 |
| 92 linkResolver = (name) => | 92 linkResolver = (name) => |
| 93 fixReference(name, _currentLibrary, _currentClass, _currentMember); | 93 fixReference(name, _currentLibrary, _currentClass, _currentMember); |
| 94 | 94 |
| 95 return getMirrorSystem(files, packageRoot: packageRoot, parseSdk: parseSdk) | 95 return getMirrorSystem(files, packageRoot: packageRoot, parseSdk: parseSdk) |
| 96 .then((MirrorSystem mirrorSystem) { | 96 .then((MirrorSystem mirrorSystem) { |
| 97 if (mirrorSystem.libraries.isEmpty) { | 97 if (mirrorSystem.libraries.isEmpty) { |
| 98 throw new StateError('No library mirrors were created.'); | 98 throw new StateError('No library mirrors were created.'); |
| 99 } | 99 } |
| 100 _documentLibraries(mirrorSystem.libraries.values, | 100 _documentLibraries(mirrorSystem.libraries.values,includeSdk: includeSdk, |
| 101 includeSdk: includeSdk, outputToYaml: outputToYaml, append: append); | 101 outputToYaml: outputToYaml, append: append, parseSdk: parseSdk); |
| 102 | 102 |
| 103 return true; | 103 return true; |
| 104 }); | 104 }); |
| 105 } | 105 } |
| 106 | 106 |
| 107 List<String> _listLibraries(List<String> args) { | 107 List<String> _listLibraries(List<String> args) { |
| 108 if (args.length != 1) throw new UnsupportedError(USAGE); | 108 if (args.length != 1) throw new UnsupportedError(USAGE); |
| 109 var libraries = new List<String>(); | 109 var libraries = new List<String>(); |
| 110 var type = FileSystemEntity.typeSync(args[0]); | 110 var type = FileSystemEntity.typeSync(args[0]); |
| 111 | 111 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Currently, a string is thrown when it fails to create a mirror | 193 // Currently, a string is thrown when it fails to create a mirror |
| 194 // system, and it is not possible to use the stack trace. BUG(#11622) | 194 // system, and it is not possible to use the stack trace. BUG(#11622) |
| 195 // To avoid printing the stack trace. | 195 // To avoid printing the stack trace. |
| 196 exit(1); | 196 exit(1); |
| 197 }); | 197 }); |
| 198 } | 198 } |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * Creates documentation for filtered libraries. | 201 * Creates documentation for filtered libraries. |
| 202 */ | 202 */ |
| 203 void _documentLibraries(List<LibraryMirror> libs, | 203 void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, |
| 204 {bool includeSdk: false, bool outputToYaml: true, bool append: false}) { | 204 bool outputToYaml: true, bool append: false, bool parseSdk: false}) { |
| 205 libs.forEach((lib) { | 205 libs.forEach((lib) { |
| 206 // Files belonging to the SDK have a uri that begins with 'dart:'. | 206 // Files belonging to the SDK have a uri that begins with 'dart:'. |
| 207 if (includeSdk || !lib.uri.toString().startsWith('dart:')) { | 207 if (includeSdk || !lib.uri.toString().startsWith('dart:')) { |
| 208 var library = generateLibrary(lib); | 208 var library = generateLibrary(lib); |
| 209 entityMap[library.qualifiedName] = library; | 209 entityMap[library.qualifiedName] = library; |
| 210 } | 210 } |
| 211 }); | 211 }); |
| 212 // After everything is created, do a pass through all classes to make sure no | 212 // After everything is created, do a pass through all classes to make sure no |
| 213 // intermediate classes created by mixins are included. | 213 // intermediate classes created by mixins are included. |
| 214 entityMap.values.where((e) => e is Class).forEach((c) => c.makeValid()); | 214 entityMap.values.where((e) => e is Class).forEach((c) => c.makeValid()); |
| 215 // Everything is a subclass of Object, therefore empty the list to avoid a | 215 // Everything is a subclass of Object, therefore empty the list to avoid a |
| 216 // giant list of subclasses to be printed out. | 216 // giant list of subclasses to be printed out. |
| 217 entityMap['dart.core.Object'].subclasses.clear(); | 217 if (parseSdk) entityMap['dart.core.Object'].subclasses.clear(); |
| 218 | 218 |
| 219 var filteredEntities = entityMap.values.where(_isVisible); | 219 var filteredEntities = entityMap.values.where(_isVisible); |
| 220 // Output libraries and classes to file after all information is generated. | 220 // Output libraries and classes to file after all information is generated. |
| 221 filteredEntities.where((e) => e is Class || e is Library).forEach((output) { | 221 filteredEntities.where((e) => e is Class || e is Library).forEach((output) { |
| 222 _writeIndexableToFile(output, outputToYaml); | 222 _writeIndexableToFile(output, outputToYaml); |
| 223 }); | 223 }); |
| 224 // Outputs a text file with a list of libraries available after creating all | 224 // Outputs a text file with a list of libraries available after creating all |
| 225 // the libraries. This will help the viewer know what libraries are available | 225 // the libraries. This will help the viewer know what libraries are available |
| 226 // to read in. | 226 // to read in. |
| 227 _writeToFile(filteredEntities.where((e) => e is Library) | 227 _writeToFile(filteredEntities.where((e) => e is Library) |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 String outer; | 937 String outer; |
| 938 List<Type> inner; | 938 List<Type> inner; |
| 939 | 939 |
| 940 Type(this.outer, this.inner); | 940 Type(this.outer, this.inner); |
| 941 | 941 |
| 942 Map toMap() => { | 942 Map toMap() => { |
| 943 'outer': outer, | 943 'outer': outer, |
| 944 'inner': new List.from(inner.map((e) => e.toMap())) | 944 'inner': new List.from(inner.map((e) => e.toMap())) |
| 945 }; | 945 }; |
| 946 } | 946 } |
| OLD | NEW |