| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Analyzes set of libraries by getting a mirror system and triggers the | 150 * Analyzes set of libraries by getting a mirror system and triggers the |
| 151 * documentation of the libraries. | 151 * documentation of the libraries. |
| 152 */ | 152 */ |
| 153 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, | 153 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, |
| 154 bool parseSdk:false}) { | 154 bool parseSdk:false}) { |
| 155 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); | 155 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); |
| 156 if (libraries.isEmpty) throw new StateError('No Libraries.'); | 156 if (libraries.isEmpty) throw new StateError('No Libraries.'); |
| 157 // DART_SDK should be set to the root of the SDK library. | 157 // Finds the root of SDK library based off the location of docgen. |
| 158 var sdkRoot = Platform.environment['DART_SDK']; | 158 var sdkRoot = path.join(path.dirname(path.dirname(path.dirname(path.dirname( |
| 159 if (sdkRoot != null) { | |
| 160 logger.info('Using DART_SDK to find SDK at $sdkRoot'); | |
| 161 } else { | |
| 162 // If DART_SDK is not defined in the environment, | |
| 163 // assuming the dart executable is from the Dart SDK folder inside bin. | |
| 164 sdkRoot = path.join(path.dirname(path.dirname(path.dirname(path.dirname( | |
| 165 path.absolute(new Options().script))))), 'sdk'); | 159 path.absolute(new Options().script))))), 'sdk'); |
| 166 logger.info('SDK Root: ${sdkRoot}'); | 160 logger.info('SDK Root: ${sdkRoot}'); |
| 167 } | |
| 168 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); | 161 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); |
| 169 } | 162 } |
| 170 | 163 |
| 171 /** | 164 /** |
| 172 * Analyzes set of libraries and provides a mirror system which can be used | 165 * Analyzes set of libraries and provides a mirror system which can be used |
| 173 * for static inspection of the source code. | 166 * for static inspection of the source code. |
| 174 */ | 167 */ |
| 175 Future<MirrorSystem> _analyzeLibraries(List<String> libraries, | 168 Future<MirrorSystem> _analyzeLibraries(List<String> libraries, |
| 176 String libraryRoot, {String packageRoot}) { | 169 String libraryRoot, {String packageRoot}) { |
| 177 SourceFileProvider provider = new SourceFileProvider(); | 170 SourceFileProvider provider = new SourceFileProvider(); |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 String outer; | 730 String outer; |
| 738 List<Type> inner; | 731 List<Type> inner; |
| 739 | 732 |
| 740 Type(this.outer, this.inner); | 733 Type(this.outer, this.inner); |
| 741 | 734 |
| 742 Map toMap() => { | 735 Map toMap() => { |
| 743 'outer': outer, | 736 'outer': outer, |
| 744 'inner': new List.from(inner.map((e) => e.toMap())) | 737 'inner': new List.from(inner.map((e) => e.toMap())) |
| 745 }; | 738 }; |
| 746 } | 739 } |
| OLD | NEW |