| 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 if (type is! TypedefMirror) { | 974 if (type is! TypedefMirror) { |
| 975 return; | 975 return; |
| 976 } | 976 } |
| 977 writeln('<div class="method"><h4 id="${type.simpleName}">'); | 977 writeln('<div class="method"><h4 id="${type.simpleName}">'); |
| 978 | 978 |
| 979 if (includeSource) { | 979 if (includeSource) { |
| 980 writeln('<button class="show-code">Code</button>'); | 980 writeln('<button class="show-code">Code</button>'); |
| 981 } | 981 } |
| 982 | 982 |
| 983 write('typedef '); | 983 write('typedef '); |
| 984 annotateType(type, type.definition, type.simpleName); | 984 annotateType(type, type.value, type.simpleName); |
| 985 | 985 |
| 986 write(''' <a class="anchor-link" href="#${type.simpleName}" | 986 write(''' <a class="anchor-link" href="#${type.simpleName}" |
| 987 title="Permalink to ${type.simpleName}">#</a>'''); | 987 title="Permalink to ${type.simpleName}">#</a>'''); |
| 988 writeln('</h4>'); | 988 writeln('</h4>'); |
| 989 | 989 |
| 990 writeln('<div class="doc">'); | 990 writeln('<div class="doc">'); |
| 991 docCode(type.location); | 991 docCode(type.location); |
| 992 writeln('</div>'); | 992 writeln('</div>'); |
| 993 | 993 |
| 994 writeln('</div>'); | 994 writeln('</div>'); |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 if (type is TypeVariableMirror) { | 1652 if (type is TypeVariableMirror) { |
| 1653 return type.simpleName; | 1653 return type.simpleName; |
| 1654 } | 1654 } |
| 1655 assert(type is ClassMirror); | 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.isOriginalDeclaration) { | 1658 if (type.isOriginalDeclaration) { |
| 1659 final typeParams = []; | 1659 final typeParams = []; |
| 1660 for (final typeParam in type.originalDeclaration.typeVariables) { | 1660 for (final typeParam in type.originalDeclaration.typeVariables) { |
| 1661 if (showBounds && | 1661 if (showBounds && |
| 1662 (typeParam.bound != null) && | 1662 (typeParam.upperBound != null) && |
| 1663 !typeParam.bound.isObject) { | 1663 !typeParam.upperBound.isObject) { |
| 1664 final bound = typeName(typeParam.bound, showBounds: true); | 1664 final bound = typeName(typeParam.upperBound, showBounds: true); |
| 1665 typeParams.add('${typeParam.simpleName} extends $bound'); | 1665 typeParams.add('${typeParam.simpleName} extends $bound'); |
| 1666 } else { | 1666 } else { |
| 1667 typeParams.add(typeParam.simpleName); | 1667 typeParams.add(typeParam.simpleName); |
| 1668 } | 1668 } |
| 1669 } | 1669 } |
| 1670 if (typeParams.isEmpty) { | 1670 if (typeParams.isEmpty) { |
| 1671 return type.simpleName; | 1671 return type.simpleName; |
| 1672 } | 1672 } |
| 1673 final params = Strings.join(typeParams, ', '); | 1673 final params = Strings.join(typeParams, ', '); |
| 1674 return '${type.simpleName}<$params>'; | 1674 return '${type.simpleName}<$params>'; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 final ClassMirror 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 |