| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (FileSystemEntity.typeSync(files.first) | 76 if (FileSystemEntity.typeSync(files.first) |
| 77 == FileSystemEntityType.DIRECTORY) { | 77 == FileSystemEntityType.DIRECTORY) { |
| 78 packageRoot = _findPackageRoot(files.first); | 78 packageRoot = _findPackageRoot(files.first); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 logger.info('Package Root: ${packageRoot}'); | 81 logger.info('Package Root: ${packageRoot}'); |
| 82 | 82 |
| 83 linkResolver = (name) => | 83 linkResolver = (name) => |
| 84 fixReference(name, _currentLibrary, _currentClass, _currentMember); | 84 fixReference(name, _currentLibrary, _currentClass, _currentMember); |
| 85 | 85 |
| 86 return getMirrorSystem(files, packageRoot, parseSdk: parseSdk) | 86 return getMirrorSystem(files, packageRoot: packageRoot, parseSdk: parseSdk) |
| 87 .then((MirrorSystem mirrorSystem) { | 87 .then((MirrorSystem mirrorSystem) { |
| 88 if (mirrorSystem.libraries.isEmpty) { | 88 if (mirrorSystem.libraries.isEmpty) { |
| 89 throw new StateError('No library mirrors were created.'); | 89 throw new StateError('No library mirrors were created.'); |
| 90 } | 90 } |
| 91 _documentLibraries(mirrorSystem.libraries.values, | 91 _documentLibraries(mirrorSystem.libraries.values, |
| 92 includeSdk: includeSdk, includePrivate: includePrivate, | 92 includeSdk: includeSdk, includePrivate: includePrivate, |
| 93 outputToYaml: outputToYaml); | 93 outputToYaml: outputToYaml); |
| 94 | 94 |
| 95 return true; | 95 return true; |
| 96 }); | 96 }); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 logger.info('Add to SDK: ${sdk.last}'); | 142 logger.info('Add to SDK: ${sdk.last}'); |
| 143 } | 143 } |
| 144 }); | 144 }); |
| 145 return sdk; | 145 return sdk; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Analyzes set of libraries by getting a mirror system and triggers the | 149 * Analyzes set of libraries by getting a mirror system and triggers the |
| 150 * documentation of the libraries. | 150 * documentation of the libraries. |
| 151 */ | 151 */ |
| 152 Future<MirrorSystem> getMirrorSystem(List<String> args, String packageRoot, | 152 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, |
| 153 {bool parseSdk:false}) { | 153 bool parseSdk:false}) { |
| 154 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); | 154 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); |
| 155 if (libraries.isEmpty) throw new StateError('No Libraries.'); | 155 if (libraries.isEmpty) throw new StateError('No Libraries.'); |
| 156 // DART_SDK should be set to the root of the SDK library. | 156 // DART_SDK should be set to the root of the SDK library. |
| 157 var sdkRoot = Platform.environment['DART_SDK']; | 157 var sdkRoot = Platform.environment['DART_SDK']; |
| 158 if (sdkRoot != null) { | 158 if (sdkRoot != null) { |
| 159 logger.info('Using DART_SDK to find SDK at $sdkRoot'); | 159 logger.info('Using DART_SDK to find SDK at $sdkRoot'); |
| 160 } else { | 160 } else { |
| 161 // If DART_SDK is not defined in the environment, | 161 // If DART_SDK is not defined in the environment, |
| 162 // assuming the dart executable is from the Dart SDK folder inside bin. | 162 // assuming the dart executable is from the Dart SDK folder inside bin. |
| 163 sdkRoot = path.dirname(path.dirname(new Options().executable)); | 163 sdkRoot = path.join(path.dirname(path.dirname(path.dirname(path.dirname( |
| 164 path.absolute(new Options().script))))), 'sdk'); |
| 164 logger.info('SDK Root: ${sdkRoot}'); | 165 logger.info('SDK Root: ${sdkRoot}'); |
| 165 } | 166 } |
| 166 | |
| 167 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); | 167 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // TODO(janicejl): Should make docgen fail gracefully, or output a friendly | 170 // TODO(janicejl): Should make docgen fail gracefully, or output a friendly |
| 171 // error message letting them know why it is failing to create a mirror system. | 171 // error message letting them know why it is failing to create a mirror system. |
| 172 // If there is conflicting library names, should modify it with a hash at the | 172 // If there is conflicting library names, should modify it with a hash at the |
| 173 // end of it's library name. | 173 // end of it's library name. |
| 174 /** | 174 /** |
| 175 * Analyzes set of libraries and provides a mirror system which can be used | 175 * Analyzes set of libraries and provides a mirror system which can be used |
| 176 * for static inspection of the source code. | 176 * for static inspection of the source code. |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 660 |
| 661 Generic(this.name, this.type); | 661 Generic(this.name, this.type); |
| 662 | 662 |
| 663 Map toMap() { | 663 Map toMap() { |
| 664 return { | 664 return { |
| 665 'name': name, | 665 'name': name, |
| 666 'type': type | 666 'type': type |
| 667 }; | 667 }; |
| 668 } | 668 } |
| 669 } | 669 } |
| OLD | NEW |