| 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 /// Support for [:foo:]-style code comments to the markdown parser. |
| 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) { |
| 339 else { | 344 reference = memberScope.qualifiedName; |
| 345 } else { |
| 340 var classScope = currentClass == null ? | 346 var classScope = currentClass == null ? |
| 341 null : currentClass.lookupInScope(name); | 347 null : currentClass.lookupInScope(name); |
| 342 reference = classScope != null ? classScope.qualifiedName : name; | 348 if (classScope != null) { |
| 349 reference = classScope.qualifiedName; |
| 350 } else { |
| 351 var libraryScope = currentLibrary == null ? |
| 352 null : currentLibrary.lookupInScope(name); |
| 353 reference = libraryScope != null ? libraryScope.qualifiedName : name; |
| 354 } |
| 343 } | 355 } |
| 344 return new markdown.Element.text('a', reference); | 356 return new markdown.Element.text('a', reference); |
| 345 } | 357 } |
| 346 | 358 |
| 347 /** | 359 /** |
| 348 * Returns a map of [Variable] objects constructed from [mirrorMap]. | 360 * Returns a map of [Variable] objects constructed from [mirrorMap]. |
| 349 */ | 361 */ |
| 350 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { | 362 Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) { |
| 351 var data = {}; | 363 var data = {}; |
| 352 // TODO(janicejl): When map to map feature is created, replace the below with | 364 // 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 } | 625 } |
| 614 | 626 |
| 615 /** | 627 /** |
| 616 * Check that the class exists in the owner library. | 628 * Check that the class exists in the owner library. |
| 617 * | 629 * |
| 618 * If it does not exist in the owner library, it is a mixin applciation and | 630 * If it does not exist in the owner library, it is a mixin applciation and |
| 619 * should be removed. | 631 * should be removed. |
| 620 */ | 632 */ |
| 621 void makeValid() { | 633 void makeValid() { |
| 622 var library = entityMap[owner]; | 634 var library = entityMap[owner]; |
| 623 if (!library.classes.containsKey(name)) { | 635 if (library != null && !library.classes.containsKey(name)) { |
| 624 this.isPrivate = true; | 636 this.isPrivate = true; |
| 625 // Since we are now making the mixin a private class, make all elements | 637 // Since we are now making the mixin a private class, make all elements |
| 626 // with the mixin as an owner private too. | 638 // with the mixin as an owner private too. |
| 627 entityMap.values.where((e) => e.owner == qualifiedName) | 639 entityMap.values.where((e) => e.owner == qualifiedName) |
| 628 .forEach((element) => element.isPrivate = true); | 640 .forEach((element) => element.isPrivate = true); |
| 629 // Move the subclass up to the next public superclass | 641 // Move the subclass up to the next public superclass |
| 630 subclasses.forEach((subclass) => addSubclass(entityMap[subclass])); | 642 subclasses.forEach((subclass) => addSubclass(entityMap[subclass])); |
| 631 } | 643 } |
| 632 } | 644 } |
| 633 | 645 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 String qualifiedName; | 1019 String qualifiedName; |
| 1008 List<String> parameters; | 1020 List<String> parameters; |
| 1009 | 1021 |
| 1010 Annotation(this.qualifiedName, this.parameters); | 1022 Annotation(this.qualifiedName, this.parameters); |
| 1011 | 1023 |
| 1012 Map toMap() => { | 1024 Map toMap() => { |
| 1013 'name': qualifiedName, | 1025 'name': qualifiedName, |
| 1014 'parameters': parameters | 1026 'parameters': parameters |
| 1015 }; | 1027 }; |
| 1016 } | 1028 } |
| OLD | NEW |