OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
8 * | 8 * |
9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
10 * | 10 * |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 * This list contains the libraries sorted in by the library name. | 220 * This list contains the libraries sorted in by the library name. |
221 */ | 221 */ |
222 List<LibraryMirror> _sortedLibraries; | 222 List<LibraryMirror> _sortedLibraries; |
223 | 223 |
224 CommentMap _comments; | 224 CommentMap _comments; |
225 | 225 |
226 /** The library that we're currently generating docs for. */ | 226 /** The library that we're currently generating docs for. */ |
227 LibraryMirror _currentLibrary; | 227 LibraryMirror _currentLibrary; |
228 | 228 |
229 /** The type that we're currently generating docs for. */ | 229 /** The type that we're currently generating docs for. */ |
230 InterfaceMirror _currentType; | 230 ClassMirror _currentType; |
231 | 231 |
232 /** The member that we're currently generating docs for. */ | 232 /** The member that we're currently generating docs for. */ |
233 MemberMirror _currentMember; | 233 MemberMirror _currentMember; |
234 | 234 |
235 /** The path to the file currently being written to, relative to [outdir]. */ | 235 /** The path to the file currently being written to, relative to [outdir]. */ |
236 Path _filePath; | 236 Path _filePath; |
237 | 237 |
238 /** The file currently being written to. */ | 238 /** The file currently being written to. */ |
239 StringBuffer _file; | 239 StringBuffer _file; |
240 | 240 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 579 |
580 void docLibraryNavigationJson(LibraryMirror library, List libraryList) { | 580 void docLibraryNavigationJson(LibraryMirror library, List libraryList) { |
581 var libraryInfo = {}; | 581 var libraryInfo = {}; |
582 libraryInfo[NAME] = displayName(library); | 582 libraryInfo[NAME] = displayName(library); |
583 final List members = docMembersJson(library.declaredMembers); | 583 final List members = docMembersJson(library.declaredMembers); |
584 if (!members.isEmpty) { | 584 if (!members.isEmpty) { |
585 libraryInfo[MEMBERS] = members; | 585 libraryInfo[MEMBERS] = members; |
586 } | 586 } |
587 | 587 |
588 final types = []; | 588 final types = []; |
589 for (InterfaceMirror type in orderByName(library.types.values)) { | 589 for (ClassMirror type in orderByName(library.types.values)) { |
590 if (!showPrivate && type.isPrivate) continue; | 590 if (!showPrivate && type.isPrivate) continue; |
591 | 591 |
592 var typeInfo = {}; | 592 var typeInfo = {}; |
593 typeInfo[NAME] = type.displayName; | 593 typeInfo[NAME] = type.displayName; |
594 if (type.isClass) { | 594 if (type.isClass) { |
595 typeInfo[KIND] = CLASS; | 595 typeInfo[KIND] = CLASS; |
596 } else if (type.isInterface) { | 596 } else if (type.isInterface) { |
597 typeInfo[KIND] = INTERFACE; | 597 typeInfo[KIND] = INTERFACE; |
598 } else { | 598 } else { |
599 assert(type.isTypedef); | 599 assert(type.isTypedef); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 if (_currentLibrary == library) docLibraryNavigation(library); | 674 if (_currentLibrary == library) docLibraryNavigation(library); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 writeln('</div>'); | 678 writeln('</div>'); |
679 } | 679 } |
680 | 680 |
681 /** Writes the navigation for the types contained by the given library. */ | 681 /** Writes the navigation for the types contained by the given library. */ |
682 void docLibraryNavigation(LibraryMirror library) { | 682 void docLibraryNavigation(LibraryMirror library) { |
683 // Show the exception types separately. | 683 // Show the exception types separately. |
684 final types = <InterfaceMirror>[]; | 684 final types = <ClassMirror>[]; |
685 final exceptions = <InterfaceMirror>[]; | 685 final exceptions = <ClassMirror>[]; |
686 | 686 |
687 for (InterfaceMirror type in orderByName(library.types.values)) { | 687 for (ClassMirror type in orderByName(library.types.values)) { |
688 if (!showPrivate && type.isPrivate) continue; | 688 if (!showPrivate && type.isPrivate) continue; |
689 | 689 |
690 if (isException(type)) { | 690 if (isException(type)) { |
691 exceptions.add(type); | 691 exceptions.add(type); |
692 } else { | 692 } else { |
693 types.add(type); | 693 types.add(type); |
694 } | 694 } |
695 } | 695 } |
696 | 696 |
697 if ((types.length == 0) && (exceptions.length == 0)) return; | 697 if ((types.length == 0) && (exceptions.length == 0)) return; |
698 | 698 |
699 writeln('<ul class="icon">'); | 699 writeln('<ul class="icon">'); |
700 types.forEach(docTypeNavigation); | 700 types.forEach(docTypeNavigation); |
701 exceptions.forEach(docTypeNavigation); | 701 exceptions.forEach(docTypeNavigation); |
702 writeln('</ul>'); | 702 writeln('</ul>'); |
703 } | 703 } |
704 | 704 |
705 /** Writes a linked navigation list item for the given type. */ | 705 /** Writes a linked navigation list item for the given type. */ |
706 void docTypeNavigation(InterfaceMirror type) { | 706 void docTypeNavigation(ClassMirror type) { |
707 var icon = 'interface'; | 707 var icon = 'interface'; |
708 if (type.simpleName.endsWith('Exception')) { | 708 if (type.simpleName.endsWith('Exception')) { |
709 icon = 'exception'; | 709 icon = 'exception'; |
710 } else if (type.isClass) { | 710 } else if (type.isClass) { |
711 icon = 'class'; | 711 icon = 'class'; |
712 } | 712 } |
713 | 713 |
714 write('<li>'); | 714 write('<li>'); |
715 if (_currentType == type) { | 715 if (_currentType == type) { |
716 write( | 716 write( |
(...skipping 21 matching lines...) Expand all Loading... |
738 // Look for a comment for the entire library. | 738 // Look for a comment for the entire library. |
739 final comment = getLibraryComment(library); | 739 final comment = getLibraryComment(library); |
740 if (comment != null) { | 740 if (comment != null) { |
741 writeln('<div class="doc">${comment.html}</div>'); | 741 writeln('<div class="doc">${comment.html}</div>'); |
742 } | 742 } |
743 | 743 |
744 // Document the top-level members. | 744 // Document the top-level members. |
745 docMembers(library); | 745 docMembers(library); |
746 | 746 |
747 // Document the types. | 747 // Document the types. |
748 final classes = <InterfaceMirror>[]; | 748 final classes = <ClassMirror>[]; |
749 final interfaces = <InterfaceMirror>[]; | 749 final interfaces = <ClassMirror>[]; |
750 final typedefs = <TypedefMirror>[]; | 750 final typedefs = <TypedefMirror>[]; |
751 final exceptions = <InterfaceMirror>[]; | 751 final exceptions = <ClassMirror>[]; |
752 | 752 |
753 for (InterfaceMirror type in orderByName(library.types.values)) { | 753 for (ClassMirror type in orderByName(library.types.values)) { |
754 if (!showPrivate && type.isPrivate) continue; | 754 if (!showPrivate && type.isPrivate) continue; |
755 | 755 |
756 if (isException(type)) { | 756 if (isException(type)) { |
757 exceptions.add(type); | 757 exceptions.add(type); |
758 } else if (type.isClass) { | 758 } else if (type.isClass) { |
759 classes.add(type); | 759 classes.add(type); |
760 } else if (type.isInterface){ | 760 } else if (type.isInterface){ |
761 interfaces.add(type); | 761 interfaces.add(type); |
762 } else if (type is TypedefMirror) { | 762 } else if (type is TypedefMirror) { |
763 typedefs.add(type); | 763 typedefs.add(type); |
(...skipping 29 matching lines...) Expand all Loading... |
793 <div class="type"> | 793 <div class="type"> |
794 <h4> | 794 <h4> |
795 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")} | 795 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")} |
796 </h4> | 796 </h4> |
797 </div> | 797 </div> |
798 '''); | 798 '''); |
799 } | 799 } |
800 writeln('</div>'); | 800 writeln('</div>'); |
801 } | 801 } |
802 | 802 |
803 void docType(InterfaceMirror type) { | 803 void docType(ClassMirror type) { |
804 if (verbose) { | 804 if (verbose) { |
805 print('- ${type.simpleName}'); | 805 print('- ${type.simpleName}'); |
806 } | 806 } |
807 _totalTypes++; | 807 _totalTypes++; |
808 _currentType = type; | 808 _currentType = type; |
809 | 809 |
810 startFile(typeUrl(type)); | 810 startFile(typeUrl(type)); |
811 | 811 |
812 var kind = 'interface'; | 812 var kind = 'interface'; |
813 if (type.isTypedef) { | 813 if (type.isTypedef) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 /** Override this to write additional content at the end of a type's page. */ | 852 /** Override this to write additional content at the end of a type's page. */ |
853 void writeTypeFooter() { | 853 void writeTypeFooter() { |
854 // Do nothing. | 854 // Do nothing. |
855 } | 855 } |
856 | 856 |
857 /** | 857 /** |
858 * Writes an inline type span for the given type. This is a little box with | 858 * Writes an inline type span for the given type. This is a little box with |
859 * an icon and the type's name. It's similar to how types appear in the | 859 * an icon and the type's name. It's similar to how types appear in the |
860 * navigation, but is suitable for inline (as opposed to in a `<ul>`) use. | 860 * navigation, but is suitable for inline (as opposed to in a `<ul>`) use. |
861 */ | 861 */ |
862 void typeSpan(InterfaceMirror type) { | 862 void typeSpan(ClassMirror type) { |
863 var icon = 'interface'; | 863 var icon = 'interface'; |
864 if (type.simpleName.endsWith('Exception')) { | 864 if (type.simpleName.endsWith('Exception')) { |
865 icon = 'exception'; | 865 icon = 'exception'; |
866 } else if (type.isClass) { | 866 } else if (type.isClass) { |
867 icon = 'class'; | 867 icon = 'class'; |
868 } | 868 } |
869 | 869 |
870 write('<span class="type-box"><span class="icon-$icon"></span>'); | 870 write('<span class="type-box"><span class="icon-$icon"></span>'); |
871 if (_currentType == type) { | 871 if (_currentType == type) { |
872 write('<strong>${typeName(type)}</strong>'); | 872 write('<strong>${typeName(type)}</strong>'); |
873 } else { | 873 } else { |
874 write(a(typeUrl(type), typeName(type))); | 874 write(a(typeUrl(type), typeName(type))); |
875 } | 875 } |
876 write('</span>'); | 876 write('</span>'); |
877 } | 877 } |
878 | 878 |
879 /** | 879 /** |
880 * Document the other types that touch [Type] in the inheritance hierarchy: | 880 * Document the other types that touch [Type] in the inheritance hierarchy: |
881 * subclasses, superclasses, subinterfaces, superinferfaces, and default | 881 * subclasses, superclasses, subinterfaces, superinferfaces, and default |
882 * class. | 882 * class. |
883 */ | 883 */ |
884 void docInheritance(InterfaceMirror type) { | 884 void docInheritance(ClassMirror type) { |
885 // Don't show the inheritance details for Object. It doesn't have any base | 885 // Don't show the inheritance details for Object. It doesn't have any base |
886 // class (obviously) and it has too many subclasses to be useful. | 886 // class (obviously) and it has too many subclasses to be useful. |
887 if (type.isObject) return; | 887 if (type.isObject) return; |
888 | 888 |
889 // Writes an unordered list of references to types with an optional header. | 889 // Writes an unordered list of references to types with an optional header. |
890 listTypes(types, header) { | 890 listTypes(types, header) { |
891 if (types == null) return; | 891 if (types == null) return; |
892 | 892 |
893 var publicTypes; | 893 var publicTypes; |
894 if (showPrivate) { | 894 if (showPrivate) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 staticSetters[member.displayName] = member; | 1034 staticSetters[member.displayName] = member; |
1035 } else { | 1035 } else { |
1036 staticMethods.add(member); | 1036 staticMethods.add(member); |
1037 } | 1037 } |
1038 } else if (member is FieldMirror) { | 1038 } else if (member is FieldMirror) { |
1039 staticGetters[member.displayName] = member; | 1039 staticGetters[member.displayName] = member; |
1040 } | 1040 } |
1041 } | 1041 } |
1042 }); | 1042 }); |
1043 | 1043 |
1044 if (host is InterfaceMirror) { | 1044 if (host is ClassMirror) { |
1045 var iterable = new HierarchyIterable(host, includeType: true); | 1045 var iterable = new HierarchyIterable(host, includeType: true); |
1046 for (InterfaceMirror type in iterable) { | 1046 for (ClassMirror type in iterable) { |
1047 if (!host.isObject && !inheritFromObject && type.isObject) continue; | 1047 if (!host.isObject && !inheritFromObject && type.isObject) continue; |
1048 | 1048 |
1049 type.declaredMembers.forEach((_, MemberMirror member) { | 1049 type.declaredMembers.forEach((_, MemberMirror member) { |
1050 if (member.isStatic) return; | 1050 if (member.isStatic) return; |
1051 if (!showPrivate && member.isPrivate) return; | 1051 if (!showPrivate && member.isPrivate) return; |
1052 | 1052 |
1053 bool inherit = true; | 1053 bool inherit = true; |
1054 if (type !== host) { | 1054 if (type !== host) { |
1055 if (member.isPrivate) { | 1055 if (member.isPrivate) { |
1056 // Don't inherit private members. | 1056 // Don't inherit private members. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 * Documents the source code contained within [location]. | 1440 * Documents the source code contained within [location]. |
1441 */ | 1441 */ |
1442 void docCode(Location location) { | 1442 void docCode(Location location) { |
1443 if (includeSource) { | 1443 if (includeSource) { |
1444 writeln('<pre class="source">'); | 1444 writeln('<pre class="source">'); |
1445 writeln(md.escapeHtml(unindentCode(location))); | 1445 writeln(md.escapeHtml(unindentCode(location))); |
1446 writeln('</pre>'); | 1446 writeln('</pre>'); |
1447 } | 1447 } |
1448 } | 1448 } |
1449 | 1449 |
1450 DocComment createDocComment(String text, [InterfaceMirror inheritedFrom]) => | 1450 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => |
1451 new DocComment(text, inheritedFrom); | 1451 new DocComment(text, inheritedFrom); |
1452 | 1452 |
1453 | 1453 |
1454 /** Get the doc comment associated with the given library. */ | 1454 /** Get the doc comment associated with the given library. */ |
1455 DocComment getLibraryComment(LibraryMirror library) { | 1455 DocComment getLibraryComment(LibraryMirror library) { |
1456 // Look for a comment for the entire library. | 1456 // Look for a comment for the entire library. |
1457 final comment = _comments.findLibrary(library.location.source); | 1457 final comment = _comments.findLibrary(library.location.source); |
1458 if (comment == null) return null; | 1458 if (comment == null) return null; |
1459 return createDocComment(comment); | 1459 return createDocComment(comment); |
1460 } | 1460 } |
1461 | 1461 |
1462 /** Get the doc comment associated with the given type. */ | 1462 /** Get the doc comment associated with the given type. */ |
1463 DocComment getTypeComment(TypeMirror type) { | 1463 DocComment getTypeComment(TypeMirror type) { |
1464 String comment = _comments.find(type.location); | 1464 String comment = _comments.find(type.location); |
1465 if (comment == null) return null; | 1465 if (comment == null) return null; |
1466 return createDocComment(comment); | 1466 return createDocComment(comment); |
1467 } | 1467 } |
1468 | 1468 |
1469 /** | 1469 /** |
1470 * Get the doc comment associated with the given member. | 1470 * Get the doc comment associated with the given member. |
1471 * | 1471 * |
1472 * If no comment was found on the member, the hierarchy is traversed to find | 1472 * If no comment was found on the member, the hierarchy is traversed to find |
1473 * an inherited comment, favouring comments inherited from classes over | 1473 * an inherited comment, favouring comments inherited from classes over |
1474 * comments inherited from interfaces. | 1474 * comments inherited from interfaces. |
1475 */ | 1475 */ |
1476 DocComment getMemberComment(MemberMirror member) { | 1476 DocComment getMemberComment(MemberMirror member) { |
1477 String comment = _comments.find(member.location); | 1477 String comment = _comments.find(member.location); |
1478 InterfaceMirror inheritedFrom = null; | 1478 ClassMirror inheritedFrom = null; |
1479 if (comment == null) { | 1479 if (comment == null) { |
1480 if (member.surroundingDeclaration is InterfaceMirror) { | 1480 if (member.surroundingDeclaration is ClassMirror) { |
1481 var iterable = | 1481 var iterable = |
1482 new HierarchyIterable(member.surroundingDeclaration, | 1482 new HierarchyIterable(member.surroundingDeclaration, |
1483 includeType: false); | 1483 includeType: false); |
1484 for (InterfaceMirror type in iterable) { | 1484 for (ClassMirror type in iterable) { |
1485 var inheritedMember = type.declaredMembers[member.simpleName]; | 1485 var inheritedMember = type.declaredMembers[member.simpleName]; |
1486 if (inheritedMember is MemberMirror) { | 1486 if (inheritedMember is MemberMirror) { |
1487 comment = _comments.find(inheritedMember.location); | 1487 comment = _comments.find(inheritedMember.location); |
1488 if (comment != null) { | 1488 if (comment != null) { |
1489 inheritedFrom = type; | 1489 inheritedFrom = type; |
1490 break; | 1490 break; |
1491 } | 1491 } |
1492 } | 1492 } |
1493 } | 1493 } |
1494 } | 1494 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 return; | 1600 return; |
1601 } | 1601 } |
1602 | 1602 |
1603 if (type.isTypeVariable) { | 1603 if (type.isTypeVariable) { |
1604 // If we're using a type parameter within the body of a generic class then | 1604 // If we're using a type parameter within the body of a generic class then |
1605 // just link back up to the class. | 1605 // just link back up to the class. |
1606 write(a(typeUrl(enclosingType), type.simpleName)); | 1606 write(a(typeUrl(enclosingType), type.simpleName)); |
1607 return; | 1607 return; |
1608 } | 1608 } |
1609 | 1609 |
1610 assert(type is InterfaceMirror); | 1610 assert(type is ClassMirror); |
1611 | 1611 |
1612 // Link to the type. | 1612 // Link to the type. |
1613 if (shouldLinkToPublicApi(type.library)) { | 1613 if (shouldLinkToPublicApi(type.library)) { |
1614 write('<a href="$API_LOCATION${typeUrl(type)}">${type.simpleName}</a>'); | 1614 write('<a href="$API_LOCATION${typeUrl(type)}">${type.simpleName}</a>'); |
1615 } else if (shouldIncludeLibrary(type.library)) { | 1615 } else if (shouldIncludeLibrary(type.library)) { |
1616 write(a(typeUrl(type), type.simpleName)); | 1616 write(a(typeUrl(type), type.simpleName)); |
1617 } else { | 1617 } else { |
1618 write(type.simpleName); | 1618 write(type.simpleName); |
1619 } | 1619 } |
1620 | 1620 |
(...skipping 10 matching lines...) Expand all Loading... |
1631 for (final arg in typeArgs) { | 1631 for (final arg in typeArgs) { |
1632 if (!first) write(', '); | 1632 if (!first) write(', '); |
1633 first = false; | 1633 first = false; |
1634 linkToType(enclosingType, arg); | 1634 linkToType(enclosingType, arg); |
1635 } | 1635 } |
1636 write('>'); | 1636 write('>'); |
1637 } | 1637 } |
1638 } | 1638 } |
1639 | 1639 |
1640 /** Creates a linked cross reference to [type]. */ | 1640 /** Creates a linked cross reference to [type]. */ |
1641 typeReference(InterfaceMirror type) { | 1641 typeReference(ClassMirror type) { |
1642 // TODO(rnystrom): Do we need to handle ParameterTypes here like | 1642 // TODO(rnystrom): Do we need to handle ParameterTypes here like |
1643 // annotation() does? | 1643 // annotation() does? |
1644 return a(typeUrl(type), typeName(type), css: 'crossref'); | 1644 return a(typeUrl(type), typeName(type), css: 'crossref'); |
1645 } | 1645 } |
1646 | 1646 |
1647 /** Generates a human-friendly string representation for a type. */ | 1647 /** Generates a human-friendly string representation for a type. */ |
1648 typeName(TypeMirror type, {bool showBounds: false}) { | 1648 typeName(TypeMirror type, {bool showBounds: false}) { |
1649 if (type.isVoid) { | 1649 if (type.isVoid) { |
1650 return 'void'; | 1650 return 'void'; |
1651 } | 1651 } |
1652 if (type is TypeVariableMirror) { | 1652 if (type is TypeVariableMirror) { |
1653 return type.simpleName; | 1653 return type.simpleName; |
1654 } | 1654 } |
1655 assert(type is InterfaceMirror); | 1655 assert(type is ClassMirror); |
1656 | 1656 |
1657 // See if it's a generic type. | 1657 // See if it's a generic type. |
1658 if (type.isDeclaration) { | 1658 if (type.isDeclaration) { |
1659 final typeParams = []; | 1659 final typeParams = []; |
1660 for (final typeParam in type.declaration.typeVariables) { | 1660 for (final typeParam in type.declaration.typeVariables) { |
1661 if (showBounds && | 1661 if (showBounds && |
1662 (typeParam.bound != null) && | 1662 (typeParam.bound != null) && |
1663 !typeParam.bound.isObject) { | 1663 !typeParam.bound.isObject) { |
1664 final bound = typeName(typeParam.bound, showBounds: true); | 1664 final bound = typeName(typeParam.bound, showBounds: true); |
1665 typeParams.add('${typeParam.simpleName} extends $bound'); | 1665 typeParams.add('${typeParam.simpleName} extends $bound'); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 | 1747 |
1748 // See if it's another type or a member of another type in the current | 1748 // See if it's another type or a member of another type in the current |
1749 // library. | 1749 // library. |
1750 if (currentLibrary != null) { | 1750 if (currentLibrary != null) { |
1751 // See if it's a constructor | 1751 // See if it's a constructor |
1752 final constructorLink = (() { | 1752 final constructorLink = (() { |
1753 final match = | 1753 final match = |
1754 new RegExp(r'new ([\w$]+)(?:\.([\w$]+))?').firstMatch(name); | 1754 new RegExp(r'new ([\w$]+)(?:\.([\w$]+))?').firstMatch(name); |
1755 if (match == null) return; | 1755 if (match == null) return; |
1756 String typeName = match[1]; | 1756 String typeName = match[1]; |
1757 InterfaceMirror foundtype = currentLibrary.types[typeName]; | 1757 ClassMirror foundtype = currentLibrary.types[typeName]; |
1758 if (foundtype == null) return; | 1758 if (foundtype == null) return; |
1759 String constructorName = | 1759 String constructorName = |
1760 (match[2] == null) ? typeName : '$typeName.${match[2]}'; | 1760 (match[2] == null) ? typeName : '$typeName.${match[2]}'; |
1761 final constructor = | 1761 final constructor = |
1762 foundtype.constructors[constructorName]; | 1762 foundtype.constructors[constructorName]; |
1763 if (constructor == null) return; | 1763 if (constructor == null) return; |
1764 return makeLink(memberUrl(constructor)); | 1764 return makeLink(memberUrl(constructor)); |
1765 })(); | 1765 })(); |
1766 if (constructorLink != null) return constructorLink; | 1766 if (constructorLink != null) return constructorLink; |
1767 | 1767 |
1768 // See if it's a member of another type | 1768 // See if it's a member of another type |
1769 final foreignMemberLink = (() { | 1769 final foreignMemberLink = (() { |
1770 final match = new RegExp(r'([\w$]+)\.([\w$]+)').firstMatch(name); | 1770 final match = new RegExp(r'([\w$]+)\.([\w$]+)').firstMatch(name); |
1771 if (match == null) return; | 1771 if (match == null) return; |
1772 InterfaceMirror foundtype = currentLibrary.types[match[1]]; | 1772 ClassMirror foundtype = currentLibrary.types[match[1]]; |
1773 if (foundtype == null) return; | 1773 if (foundtype == null) return; |
1774 MemberMirror foundMember = foundtype.declaredMembers[match[2]]; | 1774 MemberMirror foundMember = foundtype.declaredMembers[match[2]]; |
1775 if (foundMember == null) return; | 1775 if (foundMember == null) return; |
1776 return makeLink(memberUrl(foundMember)); | 1776 return makeLink(memberUrl(foundMember)); |
1777 })(); | 1777 })(); |
1778 if (foreignMemberLink != null) return foreignMemberLink; | 1778 if (foreignMemberLink != null) return foreignMemberLink; |
1779 | 1779 |
1780 InterfaceMirror foundType = currentLibrary.types[name]; | 1780 ClassMirror foundType = currentLibrary.types[name]; |
1781 if (foundType != null) { | 1781 if (foundType != null) { |
1782 return makeLink(typeUrl(foundType)); | 1782 return makeLink(typeUrl(foundType)); |
1783 } | 1783 } |
1784 | 1784 |
1785 // See if it's a top-level member in the current library. | 1785 // See if it's a top-level member in the current library. |
1786 MemberMirror foundMember = currentLibrary.declaredMembers[name]; | 1786 MemberMirror foundMember = currentLibrary.declaredMembers[name]; |
1787 if (foundMember != null) { | 1787 if (foundMember != null) { |
1788 return makeLink(memberUrl(foundMember)); | 1788 return makeLink(memberUrl(foundMember)); |
1789 } | 1789 } |
1790 } | 1790 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 const InternalError(this.message); | 1847 const InternalError(this.message); |
1848 String toString() => "InternalError: '$message'"; | 1848 String toString() => "InternalError: '$message'"; |
1849 } | 1849 } |
1850 | 1850 |
1851 class DocComment { | 1851 class DocComment { |
1852 final String text; | 1852 final String text; |
1853 | 1853 |
1854 /** | 1854 /** |
1855 * Non-null if the comment is inherited from another declaration. | 1855 * Non-null if the comment is inherited from another declaration. |
1856 */ | 1856 */ |
1857 final InterfaceMirror inheritedFrom; | 1857 final ClassMirror inheritedFrom; |
1858 | 1858 |
1859 DocComment(this.text, [this.inheritedFrom = null]) { | 1859 DocComment(this.text, [this.inheritedFrom = null]) { |
1860 assert(text != null && !text.trim().isEmpty); | 1860 assert(text != null && !text.trim().isEmpty); |
1861 } | 1861 } |
1862 | 1862 |
1863 String get html => md.markdownToHtml(text); | 1863 String get html => md.markdownToHtml(text); |
1864 | 1864 |
1865 String toString() => text; | 1865 String toString() => text; |
1866 } | 1866 } |
OLD | NEW |