Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: pkg/docgen/lib/docgen.dart

Issue 18242010: used lookupInScope(name) to find the qualified names in comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 MemberMirror _currentMember; 48 MemberMirror _currentMember;
49 49
50 /// Resolves reference links in doc comments. 50 /// Resolves reference links in doc comments.
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.
62 * 62 *
63 * Returns true if docgen sucessfuly completes. 63 * Returns `true` if docgen sucessfuly completes.
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
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 [foo] references in comments to <a>libraryName.foo</a>.
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 var reference;
280 var memberScope = currentMember == null ?
281 null : currentMember.lookupInScope(name);
282 if (memberScope != null) reference = memberScope.qualifiedName;
283 else {
284 var classScope = currentClass == null ?
285 null : currentClass.lookupInScope(name);
286 reference = classScope != null ? classScope.qualifiedName : name;
287 }
288 return new markdown.Element.text('a', reference);
282 } 289 }
283 290
284 /** 291 /**
285 * Returns a map of [Variable] objects constructed from inputted mirrors. 292 * Returns a map of [Variable] objects constructed from inputted mirrors.
286 */ 293 */
287 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap, 294 Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
288 bool includePrivate) { 295 bool includePrivate) {
289 var data = {}; 296 var data = {};
290 // TODO(janicejl): When map to map feature is created, replace the below with 297 // TODO(janicejl): When map to map feature is created, replace the below with
291 // a filter. Issue(#9590). 298 // a filter. Issue(#9590).
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 parameterMap['qualifiedname'] = qualifiedName; 577 parameterMap['qualifiedname'] = qualifiedName;
571 parameterMap['optional'] = isOptional.toString(); 578 parameterMap['optional'] = isOptional.toString();
572 parameterMap['named'] = isNamed.toString(); 579 parameterMap['named'] = isNamed.toString();
573 parameterMap['default'] = hasDefaultValue.toString(); 580 parameterMap['default'] = hasDefaultValue.toString();
574 parameterMap['type'] = type; 581 parameterMap['type'] = type;
575 parameterMap['value'] = defaultValue; 582 parameterMap['value'] = defaultValue;
576 parameterMap['annotations'] = new List.from(annotations); 583 parameterMap['annotations'] = new List.from(annotations);
577 return parameterMap; 584 return parameterMap;
578 } 585 }
579 } 586 }
OLDNEW
« no previous file with comments | « no previous file | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698