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 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 /// Current library being documented to be used for comment links. | 41 /// Current library being documented to be used for comment links. |
| 42 LibraryMirror _currentLibrary; | 42 LibraryMirror _currentLibrary; |
| 43 | 43 |
| 44 /// Current class being documented to be used for comment links. | 44 /// Current class being documented to be used for comment links. |
| 45 ClassMirror _currentClass; | 45 ClassMirror _currentClass; |
| 46 | 46 |
| 47 /// Current member being documented to be used for comment links. | 47 /// Current member being documented to be used for comment links. |
| 48 MemberMirror _currentMember; | 48 MemberMirror _currentMember; |
| 49 | 49 |
| 50 /// Add support for [:foo:]-style code to the markdown parser. | |
|
Emily Fortuna
2013/08/02 23:26:55
nit: can we make this comment slightly clearer: su
Tate Mandel
2013/08/02 23:54:36
Done.
| |
| 51 List<markdown.InlineSyntax> markdownSyntaxes = | |
| 52 [new markdown.CodeSyntax(r'\[:\s?((?:.|\n)*?)\s?:\]')]; | |
| 53 | |
| 50 /// Resolves reference links in doc comments. | 54 /// Resolves reference links in doc comments. |
| 51 markdown.Resolver linkResolver; | 55 markdown.Resolver linkResolver; |
| 52 | 56 |
| 53 /// Index of all indexable items. This also ensures that no class is | 57 /// Index of all indexable items. This also ensures that no class is |
| 54 /// created more than once. | 58 /// created more than once. |
| 55 Map<String, Indexable> entityMap = new Map<String, Indexable>(); | 59 Map<String, Indexable> entityMap = new Map<String, Indexable>(); |
| 56 | 60 |
| 57 /// This is set from the command line arguments flag --include-private | 61 /// This is set from the command line arguments flag --include-private |
| 58 bool _includePrivate = false; | 62 bool _includePrivate = false; |
| 59 | 63 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 if (commentText == null) { | 320 if (commentText == null) { |
| 317 commentText = comment.trimmedText; | 321 commentText = comment.trimmedText; |
| 318 } else { | 322 } else { |
| 319 commentText = '$commentText ${comment.trimmedText}'; | 323 commentText = '$commentText ${comment.trimmedText}'; |
| 320 } | 324 } |
| 321 } | 325 } |
| 322 } | 326 } |
| 323 }); | 327 }); |
| 324 | 328 |
| 325 commentText = commentText == null ? '' : | 329 commentText = commentText == null ? '' : |
| 326 markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver); | 330 markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver, |
| 331 inlineSyntaxes: markdownSyntaxes); | |
| 327 return commentText; | 332 return commentText; |
| 328 } | 333 } |
| 329 | 334 |
| 330 /** | 335 /** |
| 331 * Converts all [foo] references in comments to <a>libraryName.foo</a>. | 336 * Converts all [foo] references in comments to <a>libraryName.foo</a>. |
| 332 */ | 337 */ |
| 333 markdown.Node fixReference(String name, LibraryMirror currentLibrary, | 338 markdown.Node fixReference(String name, LibraryMirror currentLibrary, |
| 334 ClassMirror currentClass, MemberMirror currentMember) { | 339 ClassMirror currentClass, MemberMirror currentMember) { |
| 335 var reference; | 340 var reference; |
| 336 var memberScope = currentMember == null ? | 341 var memberScope = currentMember == null ? |
| 337 null : currentMember.lookupInScope(name); | 342 null : currentMember.lookupInScope(name); |
| 338 if (memberScope != null) reference = memberScope.qualifiedName; | 343 if (memberScope != null) reference = memberScope.qualifiedName; |
| 339 else { | 344 else { |
| 340 var classScope = currentClass == null ? | 345 var classScope = currentClass == null ? |
| 341 null : currentClass.lookupInScope(name); | 346 null : currentClass.lookupInScope(name); |
| 342 reference = classScope != null ? classScope.qualifiedName : name; | 347 if (classScope != null) reference = classScope.qualifiedName; |
|
Emily Fortuna
2013/08/02 23:26:55
if you have an else branch, go ahead and put the i
Tate Mandel
2013/08/02 23:54:36
Done.
| |
| 348 else { | |
| 349 var libraryScope = currentLibrary == null ? | |
| 350 null : currentLibrary.lookupInScope(name); | |
| 351 reference = libraryScope != null ? libraryScope.qualifiedName : name; | |
| 352 } | |
| 343 } | 353 } |
| 344 return new markdown.Element.text('a', reference); | 354 return new markdown.Element.text('a', reference); |
| 345 } | 355 } |
| 346 | 356 |
| 347 /** | 357 /** |
| 348 * Returns a map of [Variable] objects constructed from [mirrorMap]. | 358 * Returns a map of [Variable] objects constructed from [mirrorMap]. |
| 349 */ | 359 */ |
| 350 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { | 360 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { |
| 351 var data = {}; | 361 var data = {}; |
| 352 // TODO(janicejl): When map to map feature is created, replace the below with | 362 // TODO(janicejl): When map to map feature is created, replace the below with |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 } | 623 } |
| 614 | 624 |
| 615 /** | 625 /** |
| 616 * Check that the class exists in the owner library. | 626 * Check that the class exists in the owner library. |
| 617 * | 627 * |
| 618 * If it does not exist in the owner library, it is a mixin applciation and | 628 * If it does not exist in the owner library, it is a mixin applciation and |
| 619 * should be removed. | 629 * should be removed. |
| 620 */ | 630 */ |
| 621 void makeValid() { | 631 void makeValid() { |
| 622 var library = entityMap[owner]; | 632 var library = entityMap[owner]; |
| 623 if (!library.classes.containsKey(name)) { | 633 if (library != null && !library.classes.containsKey(name)) { |
| 624 this.isPrivate = true; | 634 this.isPrivate = true; |
| 625 // Since we are now making the mixin a private class, make all elements | 635 // Since we are now making the mixin a private class, make all elements |
| 626 // with the mixin as an owner private too. | 636 // with the mixin as an owner private too. |
| 627 entityMap.values.where((e) => e.owner == qualifiedName) | 637 entityMap.values.where((e) => e.owner == qualifiedName) |
| 628 .forEach((element) => element.isPrivate = true); | 638 .forEach((element) => element.isPrivate = true); |
| 629 // Move the subclass up to the next public superclass | 639 // Move the subclass up to the next public superclass |
| 630 subclasses.forEach((subclass) => addSubclass(entityMap[subclass])); | 640 subclasses.forEach((subclass) => addSubclass(entityMap[subclass])); |
| 631 } | 641 } |
| 632 } | 642 } |
| 633 | 643 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 String qualifiedName; | 1017 String qualifiedName; |
| 1008 List<String> parameters; | 1018 List<String> parameters; |
| 1009 | 1019 |
| 1010 Annotation(this.qualifiedName, this.parameters); | 1020 Annotation(this.qualifiedName, this.parameters); |
| 1011 | 1021 |
| 1012 Map toMap() => { | 1022 Map toMap() => { |
| 1013 'name': qualifiedName, | 1023 'name': qualifiedName, |
| 1014 'parameters': parameters | 1024 'parameters': parameters |
| 1015 }; | 1025 }; |
| 1016 } | 1026 } |
| OLD | NEW |