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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 markdown.Resolver linkResolver; | 51 markdown.Resolver linkResolver; |
| 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. |
|
Emily Fortuna
2013/07/03 20:24:40
can we add some documentation explaining what a re
janicejl
2013/07/03 21:25:08
Done.
| |
| 62 */ | 62 */ |
| 63 void docgen(List<String> files, {String packageRoot, bool outputToYaml: true, | 63 Future<bool> docgen(List<String> files, {String packageRoot, |
| 64 bool includePrivate: false, bool includeSdk: false, bool parseSdk: false}) { | 64 bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, |
| 65 bool parseSdk: false}) { | |
| 66 var docgenResult = new Completer<bool>(); | |
|
Andrei Mouravski
2013/07/03 20:19:00
You can do this without a completer.
Also, you don
Andrei Mouravski
2013/07/03 21:04:52
Sorry, was trying to reply quickly.
You can just
janicejl
2013/07/03 21:25:08
Done.
| |
| 67 | |
| 65 if (packageRoot == null && !parseSdk) { | 68 if (packageRoot == null && !parseSdk) { |
| 66 packageRoot = _findPackageRoot(files.first); | 69 if (FileSystemEntity.typeSync(files.first) |
|
Andrei Mouravski
2013/07/03 20:19:00
Why do you do this?
janicejl
2013/07/03 21:25:08
To only pass in a directory. Before we were only s
Andrei Mouravski
2013/07/03 21:27:50
Um, okay. This code needs to be tested a bunch (no
janicejl
2013/07/03 21:46:45
Done.
| |
| 70 == FileSystemEntityType.DIRECTORY) { | |
| 71 packageRoot = _findPackageRoot(files.first); | |
| 72 } | |
| 67 } | 73 } |
| 68 logger.info('Package Root: ${packageRoot}'); | 74 logger.info('Package Root: ${packageRoot}'); |
| 69 | 75 |
| 70 linkResolver = (name) => | 76 linkResolver = (name) => |
| 71 fixReference(name, _currentLibrary, _currentClass, _currentMember); | 77 fixReference(name, _currentLibrary, _currentClass, _currentMember); |
| 72 | 78 |
| 73 getMirrorSystem(files, packageRoot, parseSdk: parseSdk) | 79 getMirrorSystem(files, packageRoot, parseSdk: parseSdk) |
| 74 .then((MirrorSystem mirrorSystem) { | 80 .then((MirrorSystem mirrorSystem) { |
| 75 if (mirrorSystem.libraries.isEmpty) { | 81 if (mirrorSystem.libraries.isEmpty) { |
| 76 throw new StateError('No library mirrors were created.'); | 82 throw new StateError('No library mirrors were created.'); |
| 77 } | 83 } |
| 78 _documentLibraries(mirrorSystem.libraries.values, | 84 _documentLibraries(mirrorSystem.libraries.values, |
| 79 includeSdk: includeSdk, includePrivate: includePrivate, | 85 includeSdk: includeSdk, includePrivate: includePrivate, |
| 80 outputToYaml: outputToYaml); | 86 outputToYaml: outputToYaml); |
| 81 }); | 87 }).then((e) => docgenResult.complete(true)) |
| 88 .catchError((e) => docgenResult.complete(false)); | |
| 89 | |
| 90 return docgenResult.future; | |
| 82 } | 91 } |
| 83 | 92 |
| 84 List<String> _listLibraries(List<String> args) { | 93 List<String> _listLibraries(List<String> args) { |
| 85 // TODO(janicejl): At the moment, only have support to have either one file, | 94 // 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 | 95 // or one directory. This is because there can only be one package directory |
| 87 // since only one docgen is created per run. | 96 // since only one docgen is created per run. |
| 88 if (args.length != 1) throw new UnsupportedError(USAGE); | 97 if (args.length != 1) throw new UnsupportedError(USAGE); |
| 89 var libraries = new List<String>(); | 98 var libraries = new List<String>(); |
| 90 var type = FileSystemEntity.typeSync(args[0]); | 99 var type = FileSystemEntity.typeSync(args[0]); |
| 91 | 100 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 parameterMap['qualifiedname'] = qualifiedName; | 567 parameterMap['qualifiedname'] = qualifiedName; |
| 559 parameterMap['optional'] = isOptional.toString(); | 568 parameterMap['optional'] = isOptional.toString(); |
| 560 parameterMap['named'] = isNamed.toString(); | 569 parameterMap['named'] = isNamed.toString(); |
| 561 parameterMap['default'] = hasDefaultValue.toString(); | 570 parameterMap['default'] = hasDefaultValue.toString(); |
| 562 parameterMap['type'] = type; | 571 parameterMap['type'] = type; |
| 563 parameterMap['value'] = defaultValue; | 572 parameterMap['value'] = defaultValue; |
| 564 parameterMap['annotations'] = new List.from(annotations); | 573 parameterMap['annotations'] = new List.from(annotations); |
| 565 return parameterMap; | 574 return parameterMap; |
| 566 } | 575 } |
| 567 } | 576 } |
| OLD | NEW |