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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 * | 62 * |
| 63 * Returns true if docgen sucessfuly completes. | 63 * Returns 'true' if docgen sucessfuly completes. |
|
Emily Fortuna
2013/07/09 20:21:36
I think you could use the backtick (`) instead, si
janicejl
2013/07/10 01:16:40
Done.
| |
| 64 */ | 64 */ |
| 65 Future<bool> docgen(List<String> files, {String packageRoot, | 65 Future<bool> docgen(List<String> files, {String packageRoot, |
| 66 bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, | 66 bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, |
| 67 bool parseSdk: false}) { | 67 bool parseSdk: false}) { |
| 68 if (packageRoot == null && !parseSdk) { | 68 if (packageRoot == null && !parseSdk) { |
| 69 // TODO(janicejl): At the moment, if a single file is passed it, it is | 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 | 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 | 71 // the user. In future, find a better way to find the packageRoot and also |
| 72 // fully test finding the packageRoot. | 72 // fully test finding the packageRoot. |
| 73 if (FileSystemEntity.typeSync(files.first) | 73 if (FileSystemEntity.typeSync(files.first) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 }); | 267 }); |
| 268 commentText = commentText == null ? '' : | 268 commentText = commentText == null ? '' : |
| 269 markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver) | 269 markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver) |
| 270 .replaceAll('\n', ' '); | 270 .replaceAll('\n', ' '); |
| 271 return commentText; | 271 return commentText; |
| 272 } | 272 } |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * Converts all [_] references in comments to <code>_</code>. | 275 * Converts all [_] references in comments to <code>_</code>. |
|
Emily Fortuna
2013/07/09 20:21:36
nit: can we change this comment to say "Converts a
janicejl
2013/07/10 01:16:40
Done.
| |
| 276 */ | 276 */ |
| 277 // TODO(tmandel): Create proper links for [_] style markdown based | |
| 278 // on scope once layout of viewer is finished. | |
| 279 markdown.Node fixReference(String name, LibraryMirror currentLibrary, | 277 markdown.Node fixReference(String name, LibraryMirror currentLibrary, |
| 280 ClassMirror currentClass, MemberMirror currentMember) { | 278 ClassMirror currentClass, MemberMirror currentMember) { |
| 281 return new markdown.Element.text('code', name); | 279 |
| 280 var reference; | |
| 281 var memberScope = currentMember == null ? | |
| 282 null : currentMember.lookupInScope(name); | |
| 283 if (memberScope != null) reference = memberScope.qualifiedName; | |
| 284 else { | |
| 285 var classScope = currentClass == null ? | |
| 286 null : currentClass.lookupInScope(name); | |
| 287 if (classScope != null) reference = classScope.qualifiedName; | |
| 288 else { | |
| 289 var libraryScope = currentLibrary.lookupInScope(name); | |
| 290 reference = libraryScope != null ? libraryScope.qualifiedname : name; | |
| 291 } | |
| 292 } | |
| 293 return new markdown.Element.text('a', reference); | |
| 282 } | 294 } |
| 283 | 295 |
| 284 /** | 296 /** |
| 285 * Returns a map of [Variable] objects constructed from inputted mirrors. | 297 * Returns a map of [Variable] objects constructed from inputted mirrors. |
| 286 */ | 298 */ |
| 287 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, | 299 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, |
| 288 bool includePrivate) { | 300 bool includePrivate) { |
| 289 var data = {}; | 301 var data = {}; |
| 290 // TODO(janicejl): When map to map feature is created, replace the below with | 302 // TODO(janicejl): When map to map feature is created, replace the below with |
| 291 // a filter. Issue(#9590). | 303 // a filter. Issue(#9590). |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 parameterMap['qualifiedname'] = qualifiedName; | 582 parameterMap['qualifiedname'] = qualifiedName; |
| 571 parameterMap['optional'] = isOptional.toString(); | 583 parameterMap['optional'] = isOptional.toString(); |
| 572 parameterMap['named'] = isNamed.toString(); | 584 parameterMap['named'] = isNamed.toString(); |
| 573 parameterMap['default'] = hasDefaultValue.toString(); | 585 parameterMap['default'] = hasDefaultValue.toString(); |
| 574 parameterMap['type'] = type; | 586 parameterMap['type'] = type; |
| 575 parameterMap['value'] = defaultValue; | 587 parameterMap['value'] = defaultValue; |
| 576 parameterMap['annotations'] = new List.from(annotations); | 588 parameterMap['annotations'] = new List.from(annotations); |
| 577 return parameterMap; | 589 return parameterMap; |
| 578 } | 590 } |
| 579 } | 591 } |
| OLD | NEW |