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

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

Issue 141083002: Fixed up some inheritance chains and improved constructor output (to be fully qualified). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | no next file » | 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 /// **docgen** is a tool for creating machine readable representations of Dart 5 /// **docgen** is a tool for creating machine readable representations of Dart
6 /// code metadata, including: classes, members, comments and annotations. 6 /// code metadata, including: classes, members, comments and annotations.
7 /// 7 ///
8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files.
9 /// 9 ///
10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR]
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 result = owner.findElementInScope(name); 1435 result = owner.findElementInScope(name);
1436 return result == null ? super.findElementInScope(name) : result; 1436 return result == null ? super.findElementInScope(name) : result;
1437 } 1437 }
1438 1438
1439 markdown.Node fixReferenceWithScope(String name) => fixReference(name); 1439 markdown.Node fixReferenceWithScope(String name) => fixReference(name);
1440 1440
1441 String get typeName => 'class'; 1441 String get typeName => 'class';
1442 1442
1443 /// Returns a list of all the parent classes. 1443 /// Returns a list of all the parent classes.
1444 List<Class> parentChain() { 1444 List<Class> parentChain() {
1445 // TODO(efortuna): Seems like we can get rid of this method.
1445 var parent = superclass == null ? [] : [superclass]; 1446 var parent = superclass == null ? [] : [superclass];
1446 parent.addAll(interfaces);
1447 return parent; 1447 return parent;
1448 } 1448 }
1449 1449
1450 /// Add all inherited variables and methods from the provided superclass. 1450 /// Add all inherited variables and methods from the provided superclass.
1451 /// If [_includePrivate] is true, it also adds the variables and methods from 1451 /// If [_includePrivate] is true, it also adds the variables and methods from
1452 /// the superclass. 1452 /// the superclass.
1453 void addInherited(Class superclass) { 1453 void addInherited(Class superclass) {
1454 inheritedVariables.addAll(superclass.inheritedVariables); 1454 inheritedVariables.addAll(superclass.inheritedVariables);
1455 inheritedVariables.addAll(_allButStatics(superclass.variables)); 1455 inheritedVariables.addAll(_allButStatics(superclass.variables));
1456 addInheritedMethod(superclass, this); 1456 addInheritedMethod(superclass, this);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 this.parameters = _createParameters(mirror.parameters, owner); 1725 this.parameters = _createParameters(mirror.parameters, owner);
1726 this.annotations = _createAnnotations(mirror, _getOwningLibrary(owner)); 1726 this.annotations = _createAnnotations(mirror, _getOwningLibrary(owner));
1727 this.isConstructor = mirror.isConstructor; 1727 this.isConstructor = mirror.isConstructor;
1728 this.isGetter = mirror.isGetter; 1728 this.isGetter = mirror.isGetter;
1729 this.isSetter = mirror.isSetter; 1729 this.isSetter = mirror.isSetter;
1730 this.isOperator = mirror.isOperator; 1730 this.isOperator = mirror.isOperator;
1731 } 1731 }
1732 1732
1733 String get packagePrefix => owner.packagePrefix; 1733 String get packagePrefix => owner.packagePrefix;
1734 1734
1735 Method get originallyInheritedFrom => methodInheritedFrom == null ?
1736 this : methodInheritedFrom.originallyInheritedFrom;
1737
1735 markdown.Node fixReferenceWithScope(String name) => fixReference(name); 1738 markdown.Node fixReferenceWithScope(String name) => fixReference(name);
1736 1739
1737 /// Look for the specified name starting with the current member, and 1740 /// Look for the specified name starting with the current member, and
1738 /// progressively working outward to the current library scope. 1741 /// progressively working outward to the current library scope.
1739 String findElementInScope(String name) { 1742 String findElementInScope(String name) {
1740 var lookupFunc = Indexable.determineLookupFunc(name); 1743 var lookupFunc = Indexable.determineLookupFunc(name);
1741 1744
1742 var memberScope = lookupFunc(this.mirror, name); 1745 var memberScope = lookupFunc(this.mirror, name);
1743 if (memberScope != null) { 1746 if (memberScope != null) {
1744 // do we check for a dummy mirror returned here and look up with an owner 1747 // do we check for a dummy mirror returned here and look up with an owner
(...skipping 13 matching lines...) Expand all
1758 var result = owner.findElementInScope(name); 1761 var result = owner.findElementInScope(name);
1759 if (result != null) return result; 1762 if (result != null) return result;
1760 } 1763 }
1761 return super.findElementInScope(name); 1764 return super.findElementInScope(name);
1762 } 1765 }
1763 1766
1764 String get docName { 1767 String get docName {
1765 if ((mirror as MethodMirror).isConstructor) { 1768 if ((mirror as MethodMirror).isConstructor) {
1766 // We name constructors specially -- including the class name again and a 1769 // We name constructors specially -- including the class name again and a
1767 // "-" to separate the constructor from its name (if any). 1770 // "-" to separate the constructor from its name (if any).
1768 return '${mirror.owner.simpleName.replaceAll(".", "_")}.' 1771 return '${owner.docName}.${mirror.owner.simpleName}-${mirror.simpleName}';
1769 '${mirror.owner.simpleName}-${mirror.simpleName}';
1770 } 1772 }
1771 return super.docName; 1773 return super.docName;
1772 } 1774 }
1773 1775
1774 /// Makes sure that the method with an inherited equivalent have comments. 1776 /// Makes sure that the method with an inherited equivalent have comments.
1775 void ensureCommentFor(Method inheritedMethod) { 1777 void ensureCommentFor(Method inheritedMethod) {
1776 if (comment.isNotEmpty) return; 1778 if (comment.isNotEmpty) return;
1777 1779
1778 comment = inheritedMethod._commentToHtml(this); 1780 comment = inheritedMethod._commentToHtml(this);
1779 _unresolvedComment = inheritedMethod._unresolvedComment; 1781 _unresolvedComment = inheritedMethod._unresolvedComment;
1780 commentInheritedFrom = inheritedMethod.commentInheritedFrom == '' ? 1782 commentInheritedFrom = inheritedMethod.commentInheritedFrom == '' ?
1781 inheritedMethod.mirror.qualifiedName : 1783 new DummyMirror(inheritedMethod.mirror).docName :
1782 inheritedMethod.commentInheritedFrom; 1784 inheritedMethod.commentInheritedFrom;
1783 } 1785 }
1784 1786
1785 /// Generates a map describing the [Method] object. 1787 /// Generates a map describing the [Method] object.
1786 Map toMap() => { 1788 Map toMap() => {
1787 'name': name, 1789 'name': name,
1788 'qualifiedName': qualifiedName, 1790 'qualifiedName': qualifiedName,
1789 'comment': comment, 1791 'comment': comment,
1790 'commentFrom': (methodInheritedFrom != null && 1792 'commentFrom': (methodInheritedFrom != null &&
1791 commentInheritedFrom == methodInheritedFrom.docName ? '' 1793 commentInheritedFrom == methodInheritedFrom.docName ? ''
1792 : commentInheritedFrom), 1794 : commentInheritedFrom),
1793 'inheritedFrom': (methodInheritedFrom == null? '' : 1795 'inheritedFrom': (methodInheritedFrom == null? '' :
1794 methodInheritedFrom.docName), 1796 originallyInheritedFrom.docName),
1795 'static': isStatic.toString(), 1797 'static': isStatic.toString(),
1796 'abstract': isAbstract.toString(), 1798 'abstract': isAbstract.toString(),
1797 'constant': isConst.toString(), 1799 'constant': isConst.toString(),
1798 'return': new List.filled(1, returnType.toMap()), 1800 'return': new List.filled(1, returnType.toMap()),
1799 'parameters': recurseMap(parameters), 1801 'parameters': recurseMap(parameters),
1800 'annotations': annotations.map((a) => a.toMap()).toList() 1802 'annotations': annotations.map((a) => a.toMap()).toList()
1801 }; 1803 };
1802 1804
1803 String get typeName => isConstructor ? 'constructor' : 1805 String get typeName => isConstructor ? 'constructor' :
1804 isGetter ? 'getter' : isSetter ? 'setter' : 1806 isGetter ? 'getter' : isSetter ? 'setter' :
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 .map((e) => originalMirror.getField(e.simpleName).reflectee) 1944 .map((e) => originalMirror.getField(e.simpleName).reflectee)
1943 .where((e) => e != null) 1945 .where((e) => e != null)
1944 .toList(); 1946 .toList();
1945 } 1947 }
1946 1948
1947 Map toMap() => { 1949 Map toMap() => {
1948 'name': getDocgenObject(mirror, owningLibrary).docName, 1950 'name': getDocgenObject(mirror, owningLibrary).docName,
1949 'parameters': parameters 1951 'parameters': parameters
1950 }; 1952 };
1951 } 1953 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698