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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 } | 1598 } |
1599 | 1599 |
1600 /** Creates a linked cross reference to [type]. */ | 1600 /** Creates a linked cross reference to [type]. */ |
1601 typeReference(InterfaceMirror type) { | 1601 typeReference(InterfaceMirror type) { |
1602 // TODO(rnystrom): Do we need to handle ParameterTypes here like | 1602 // TODO(rnystrom): Do we need to handle ParameterTypes here like |
1603 // annotation() does? | 1603 // annotation() does? |
1604 return a(typeUrl(type), typeName(type), css: 'crossref'); | 1604 return a(typeUrl(type), typeName(type), css: 'crossref'); |
1605 } | 1605 } |
1606 | 1606 |
1607 /** Generates a human-friendly string representation for a type. */ | 1607 /** Generates a human-friendly string representation for a type. */ |
1608 typeName(TypeMirror type, [bool showBounds = false]) { | 1608 typeName(TypeMirror type, {bool showBounds: false}) { |
1609 if (type.isVoid) { | 1609 if (type.isVoid) { |
1610 return 'void'; | 1610 return 'void'; |
1611 } | 1611 } |
1612 if (type is TypeVariableMirror) { | 1612 if (type is TypeVariableMirror) { |
1613 return type.simpleName; | 1613 return type.simpleName; |
1614 } | 1614 } |
1615 assert(type is InterfaceMirror); | 1615 assert(type is InterfaceMirror); |
1616 | 1616 |
1617 // See if it's a generic type. | 1617 // See if it's a generic type. |
1618 if (type.isDeclaration) { | 1618 if (type.isDeclaration) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 // Syntax highlight. | 1669 // Syntax highlight. |
1670 return classifySource(code); | 1670 return classifySource(code); |
1671 } | 1671 } |
1672 | 1672 |
1673 /** | 1673 /** |
1674 * This will be called whenever a doc comment hits a `[name]` in square | 1674 * This will be called whenever a doc comment hits a `[name]` in square |
1675 * brackets. It will try to figure out what the name refers to and link or | 1675 * brackets. It will try to figure out what the name refers to and link or |
1676 * style it appropriately. | 1676 * style it appropriately. |
1677 */ | 1677 */ |
1678 md.Node resolveNameReference(String name, | 1678 md.Node resolveNameReference(String name, |
1679 [MemberMirror currentMember = null, | 1679 {MemberMirror currentMember, |
1680 ObjectMirror currentType = null, | 1680 ObjectMirror currentType, |
1681 LibraryMirror currentLibrary = null]) { | 1681 LibraryMirror currentLibrary}) { |
1682 makeLink(String href) { | 1682 makeLink(String href) { |
1683 final anchor = new md.Element.text('a', name); | 1683 final anchor = new md.Element.text('a', name); |
1684 anchor.attributes['href'] = relativePath(href); | 1684 anchor.attributes['href'] = relativePath(href); |
1685 anchor.attributes['class'] = 'crossref'; | 1685 anchor.attributes['class'] = 'crossref'; |
1686 return anchor; | 1686 return anchor; |
1687 } | 1687 } |
1688 | 1688 |
1689 // See if it's a parameter of the current method. | 1689 // See if it's a parameter of the current method. |
1690 if (currentMember is MethodMirror) { | 1690 if (currentMember is MethodMirror) { |
1691 for (final parameter in currentMember.parameters) { | 1691 for (final parameter in currentMember.parameters) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 final InterfaceMirror inheritedFrom; | 1817 final InterfaceMirror inheritedFrom; |
1818 | 1818 |
1819 DocComment(this.text, [this.inheritedFrom = null]) { | 1819 DocComment(this.text, [this.inheritedFrom = null]) { |
1820 assert(text != null && !text.trim().isEmpty()); | 1820 assert(text != null && !text.trim().isEmpty()); |
1821 } | 1821 } |
1822 | 1822 |
1823 String get html => md.markdownToHtml(text); | 1823 String get html => md.markdownToHtml(text); |
1824 | 1824 |
1825 String toString() => text; | 1825 String toString() => text; |
1826 } | 1826 } |
OLD | NEW |