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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 /** | 219 /** |
220 * Analyzes set of libraries by getting a mirror system and triggers the | 220 * Analyzes set of libraries by getting a mirror system and triggers the |
221 * documentation of the libraries. | 221 * documentation of the libraries. |
222 */ | 222 */ |
223 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, | 223 Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot, |
224 bool parseSdk: false}) { | 224 bool parseSdk: false}) { |
225 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); | 225 var libraries = !parseSdk ? _listLibraries(args) : _listSdk(); |
226 if (libraries.isEmpty) throw new StateError('No Libraries.'); | 226 if (libraries.isEmpty) throw new StateError('No Libraries.'); |
227 // Finds the root of SDK library based off the location of docgen. | 227 // Finds the root of SDK library based off the location of docgen. |
228 var sdkRoot = path.join(path.dirname(path.dirname(path.dirname(path.dirname( | 228 var sdkRoot = path.join(path.dirname(path.dirname(path.dirname(path.dirname( |
229 path.absolute(new Options().script))))), 'sdk'); | 229 path.absolute(Platform.script))))), 'sdk'); |
230 logger.info('SDK Root: ${sdkRoot}'); | 230 logger.info('SDK Root: ${sdkRoot}'); |
231 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); | 231 return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot); |
232 } | 232 } |
233 | 233 |
234 /** | 234 /** |
235 * Analyzes set of libraries and provides a mirror system which can be used | 235 * Analyzes set of libraries and provides a mirror system which can be used |
236 * for static inspection of the source code. | 236 * for static inspection of the source code. |
237 */ | 237 */ |
238 Future<MirrorSystem> _analyzeLibraries(List<String> libraries, | 238 Future<MirrorSystem> _analyzeLibraries(List<String> libraries, |
239 String libraryRoot, {String packageRoot}) { | 239 String libraryRoot, {String packageRoot}) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 444 } |
445 | 445 |
446 /** | 446 /** |
447 * Generates MDN comments from database.json. | 447 * Generates MDN comments from database.json. |
448 */ | 448 */ |
449 void _mdnComment(Indexable item) { | 449 void _mdnComment(Indexable item) { |
450 //Check if MDN is loaded. | 450 //Check if MDN is loaded. |
451 if (_mdn == null) { | 451 if (_mdn == null) { |
452 // Reading in MDN related json file. | 452 // Reading in MDN related json file. |
453 var mdnDir = path.join(path.dirname(path.dirname(path.dirname(path.dirname( | 453 var mdnDir = path.join(path.dirname(path.dirname(path.dirname(path.dirname( |
454 path.absolute(new Options().script))))), 'utils', 'apidoc', 'mdn'); | 454 path.absolute(Platform.script))))), 'utils', 'apidoc', 'mdn'); |
455 _mdn = JSON.decode(new File(path.join(mdnDir, 'database.json')) | 455 _mdn = JSON.decode(new File(path.join(mdnDir, 'database.json')) |
456 .readAsStringSync()); | 456 .readAsStringSync()); |
457 } | 457 } |
458 if (item.comment.isNotEmpty) return; | 458 if (item.comment.isNotEmpty) return; |
459 var domAnnotation = item.annotations.firstWhere( | 459 var domAnnotation = item.annotations.firstWhere( |
460 (e) => e.qualifiedName == 'metadata.DomName', orElse: () => null); | 460 (e) => e.qualifiedName == 'metadata.DomName', orElse: () => null); |
461 if (domAnnotation == null) return; | 461 if (domAnnotation == null) return; |
462 var domName = domAnnotation.parameters.single; | 462 var domName = domAnnotation.parameters.single; |
463 var parts = domName.split('.'); | 463 var parts = domName.split('.'); |
464 if (parts.length == 2) item.comment = _mdnMemberComment(parts[0], parts[1]); | 464 if (parts.length == 2) item.comment = _mdnMemberComment(parts[0], parts[1]); |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 class Annotation { | 1229 class Annotation { |
1230 String qualifiedName; | 1230 String qualifiedName; |
1231 List<String> parameters; | 1231 List<String> parameters; |
1232 | 1232 |
1233 Annotation(this.qualifiedName, this.parameters); | 1233 Annotation(this.qualifiedName, this.parameters); |
1234 | 1234 |
1235 Map toMap() => { | 1235 Map toMap() => { |
1236 'name': qualifiedName, | 1236 'name': qualifiedName, |
1237 'parameters': parameters | 1237 'parameters': parameters |
1238 }; | 1238 }; |
1239 } | 1239 } |
OLD | NEW |