Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Docgen constructor initializes the link resolver for markdown parsing. | 54 * Docgen constructor initializes the link resolver for markdown parsing. |
| 55 * Also initializes the command line arguments. | 55 * Also initializes the command line arguments. |
| 56 * | 56 * |
| 57 * [packageRoot] is the packages directory of the directory being analyzed. | 57 * [packageRoot] is the packages directory of the directory being analyzed. |
| 58 * If [includeSdk] is 'true', then any SDK libraries explicitly imported will | 58 * If [includeSdk] is 'true', then any SDK libraries explicitly imported will |
| 59 * also be documented. | 59 * also be documented. |
| 60 * If [parseSdk] is 'true', then all Dart SDK libraries will be documented. | 60 * If [parseSdk] is 'true', then all Dart SDK libraries will be documented. |
| 61 * This option is useful when only the SDK libraries are needed. | 61 * This option is useful when only the SDK libraries are needed. |
| 62 * | |
| 63 * Returns true if docgen sucessfuly completes. | |
|
Andrei Mouravski
2013/07/03 23:41:38
Just for the future, we wrap "true" and "false" wi
| |
| 62 */ | 64 */ |
| 63 void docgen(List<String> files, {String packageRoot, bool outputToYaml: true, | 65 Future<bool> docgen(List<String> files, {String packageRoot, |
| 64 bool includePrivate: false, bool includeSdk: false, bool parseSdk: false}) { | 66 bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, |
| 67 bool parseSdk: false}) { | |
| 65 if (packageRoot == null && !parseSdk) { | 68 if (packageRoot == null && !parseSdk) { |
| 66 packageRoot = _findPackageRoot(files.first); | 69 // TODO(janicejl): At the moment, if a single file is passed it, it is |
| 70 // assumed that it does not have a package root unless it is passed in by | |
| 71 // the user. In future, find a better way to find the packageRoot and also | |
| 72 // fully test finding the packageRoot. | |
| 73 if (FileSystemEntity.typeSync(files.first) | |
| 74 == FileSystemEntityType.DIRECTORY) { | |
| 75 packageRoot = _findPackageRoot(files.first); | |
| 76 } | |
| 67 } | 77 } |
| 68 logger.info('Package Root: ${packageRoot}'); | 78 logger.info('Package Root: ${packageRoot}'); |
| 69 | 79 |
| 70 linkResolver = (name) => | 80 linkResolver = (name) => |
| 71 fixReference(name, _currentLibrary, _currentClass, _currentMember); | 81 fixReference(name, _currentLibrary, _currentClass, _currentMember); |
| 72 | 82 |
| 73 getMirrorSystem(files, packageRoot, parseSdk: parseSdk) | 83 return getMirrorSystem(files, packageRoot, parseSdk: parseSdk) |
| 74 .then((MirrorSystem mirrorSystem) { | 84 .then((MirrorSystem mirrorSystem) { |
| 75 if (mirrorSystem.libraries.isEmpty) { | 85 if (mirrorSystem.libraries.isEmpty) { |
| 76 throw new StateError('No library mirrors were created.'); | 86 throw new StateError('No library mirrors were created.'); |
| 77 } | 87 } |
| 78 _documentLibraries(mirrorSystem.libraries.values, | 88 _documentLibraries(mirrorSystem.libraries.values, |
| 79 includeSdk: includeSdk, includePrivate: includePrivate, | 89 includeSdk: includeSdk, includePrivate: includePrivate, |
| 80 outputToYaml: outputToYaml); | 90 outputToYaml: outputToYaml); |
| 91 | |
| 92 return true; | |
| 81 }); | 93 }); |
| 82 } | 94 } |
| 83 | 95 |
| 84 List<String> _listLibraries(List<String> args) { | 96 List<String> _listLibraries(List<String> args) { |
| 85 // TODO(janicejl): At the moment, only have support to have either one file, | 97 // TODO(janicejl): At the moment, only have support to have either one file, |
| 86 // or one directory. This is because there can only be one package directory | 98 // or one directory. This is because there can only be one package directory |
| 87 // since only one docgen is created per run. | 99 // since only one docgen is created per run. |
| 88 if (args.length != 1) throw new UnsupportedError(USAGE); | 100 if (args.length != 1) throw new UnsupportedError(USAGE); |
| 89 var libraries = new List<String>(); | 101 var libraries = new List<String>(); |
| 90 var type = FileSystemEntity.typeSync(args[0]); | 102 var type = FileSystemEntity.typeSync(args[0]); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 parameterMap['qualifiedname'] = qualifiedName; | 570 parameterMap['qualifiedname'] = qualifiedName; |
| 559 parameterMap['optional'] = isOptional.toString(); | 571 parameterMap['optional'] = isOptional.toString(); |
| 560 parameterMap['named'] = isNamed.toString(); | 572 parameterMap['named'] = isNamed.toString(); |
| 561 parameterMap['default'] = hasDefaultValue.toString(); | 573 parameterMap['default'] = hasDefaultValue.toString(); |
| 562 parameterMap['type'] = type; | 574 parameterMap['type'] = type; |
| 563 parameterMap['value'] = defaultValue; | 575 parameterMap['value'] = defaultValue; |
| 564 parameterMap['annotations'] = new List.from(annotations); | 576 parameterMap['annotations'] = new List.from(annotations); |
| 565 return parameterMap; | 577 return parameterMap; |
| 566 } | 578 } |
| 567 } | 579 } |
| OLD | NEW |