| 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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 794 |
| 795 void docType(InterfaceMirror type) { | 795 void docType(InterfaceMirror type) { |
| 796 if (verbose) { | 796 if (verbose) { |
| 797 print('- ${type.simpleName}'); | 797 print('- ${type.simpleName}'); |
| 798 } | 798 } |
| 799 _totalTypes++; | 799 _totalTypes++; |
| 800 _currentType = type; | 800 _currentType = type; |
| 801 | 801 |
| 802 startFile(typeUrl(type)); | 802 startFile(typeUrl(type)); |
| 803 | 803 |
| 804 var kind = 'Interface'; | 804 var kind = 'interface'; |
| 805 if (type.isTypedef) { | 805 if (type.isTypedef) { |
| 806 kind = 'Typedef'; | 806 kind = 'typedef'; |
| 807 } else if (type.isClass) { | 807 } else if (type.isClass) { |
| 808 kind = 'Class'; | 808 if (type.isAbstract) { |
| 809 kind = 'abstract class'; |
| 810 } else { |
| 811 kind = 'class'; |
| 812 } |
| 809 } | 813 } |
| 810 | 814 |
| 811 final typeTitle = | 815 final typeTitle = |
| 812 '${typeName(type)} ${kind}'; | 816 '${typeName(type)} ${kind}'; |
| 813 writeHeader('$typeTitle / ${type.library.simpleName} Library', | 817 writeHeader('$typeTitle / ${type.library.simpleName} Library', |
| 814 [type.library.simpleName, libraryUrl(type.library), | 818 [type.library.simpleName, libraryUrl(type.library), |
| 815 typeName(type), typeUrl(type)]); | 819 typeName(type), typeUrl(type)]); |
| 816 writeln( | 820 writeln( |
| 817 ''' | 821 ''' |
| 818 <h2><strong>${typeName(type, showBounds: true)}</strong> | 822 <h2><strong>${typeName(type, showBounds: true)}</strong> |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 } | 1045 } |
| 1042 | 1046 |
| 1043 /** | 1047 /** |
| 1044 * Documents the [method] in type [type]. Handles all kinds of methods | 1048 * Documents the [method] in type [type]. Handles all kinds of methods |
| 1045 * including getters, setters, and constructors. | 1049 * including getters, setters, and constructors. |
| 1046 */ | 1050 */ |
| 1047 void docMethod(ObjectMirror host, MethodMirror method) { | 1051 void docMethod(ObjectMirror host, MethodMirror method) { |
| 1048 _totalMembers++; | 1052 _totalMembers++; |
| 1049 _currentMember = method; | 1053 _currentMember = method; |
| 1050 | 1054 |
| 1055 bool showCode = includeSource && !method.isAbstract; |
| 1056 |
| 1051 writeln('<div class="method"><h4 id="${memberAnchor(method)}">'); | 1057 writeln('<div class="method"><h4 id="${memberAnchor(method)}">'); |
| 1052 | 1058 |
| 1053 if (includeSource) { | 1059 if (showCode) { |
| 1054 writeln('<span class="show-code">Code</span>'); | 1060 writeln('<span class="show-code">Code</span>'); |
| 1055 } | 1061 } |
| 1056 | 1062 |
| 1057 if (method.isConstructor) { | 1063 if (method.isConstructor) { |
| 1058 if (method.isFactory) { | 1064 if (method.isFactory) { |
| 1059 write('factory '); | 1065 write('factory '); |
| 1060 } else { | 1066 } else { |
| 1061 write(method.isConst ? 'const ' : 'new '); | 1067 write(method.isConst ? 'const ' : 'new '); |
| 1062 } | 1068 } |
| 1069 } else if (method.isAbstract) { |
| 1070 write('abstract '); |
| 1063 } | 1071 } |
| 1064 | 1072 |
| 1065 if (method.constructorName == null) { | 1073 if (method.constructorName == null) { |
| 1066 annotateType(host, method.returnType); | 1074 annotateType(host, method.returnType); |
| 1067 } | 1075 } |
| 1068 | 1076 |
| 1069 var name = method.simpleName; | 1077 var name = method.simpleName; |
| 1070 // Translate specially-named methods: getters, setters, operators. | 1078 // Translate specially-named methods: getters, setters, operators. |
| 1071 if (method.isGetter) { | 1079 if (method.isGetter) { |
| 1072 // Getter. | 1080 // Getter. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1086 write(method.constructorName); | 1094 write(method.constructorName); |
| 1087 } | 1095 } |
| 1088 | 1096 |
| 1089 docParamList(host, method.parameters); | 1097 docParamList(host, method.parameters); |
| 1090 | 1098 |
| 1091 var prefix = host is LibraryMirror ? '' : '${typeName(host)}.'; | 1099 var prefix = host is LibraryMirror ? '' : '${typeName(host)}.'; |
| 1092 write(''' <a class="anchor-link" href="#${memberAnchor(method)}" | 1100 write(''' <a class="anchor-link" href="#${memberAnchor(method)}" |
| 1093 title="Permalink to $prefix$name">#</a>'''); | 1101 title="Permalink to $prefix$name">#</a>'''); |
| 1094 writeln('</h4>'); | 1102 writeln('</h4>'); |
| 1095 | 1103 |
| 1096 docCode(method.location, getMethodComment(method), showCode: true); | 1104 docCode(method.location, getMethodComment(method), showCode: showCode); |
| 1097 | 1105 |
| 1098 writeln('</div>'); | 1106 writeln('</div>'); |
| 1099 } | 1107 } |
| 1100 | 1108 |
| 1101 /** Documents the field [field] of type [type]. */ | 1109 /** Documents the field [field] of type [type]. */ |
| 1102 void docField(ObjectMirror host, FieldMirror field) { | 1110 void docField(ObjectMirror host, FieldMirror field) { |
| 1103 _totalMembers++; | 1111 _totalMembers++; |
| 1104 _currentMember = field; | 1112 _currentMember = field; |
| 1105 | 1113 |
| 1106 writeln('<div class="field"><h4 id="${memberAnchor(field)}">'); | 1114 writeln('<div class="field"><h4 id="${memberAnchor(field)}">'); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 | 1575 |
| 1568 /** | 1576 /** |
| 1569 * Used to report an unexpected error in the DartDoc tool or the | 1577 * Used to report an unexpected error in the DartDoc tool or the |
| 1570 * underlying data | 1578 * underlying data |
| 1571 */ | 1579 */ |
| 1572 class InternalError { | 1580 class InternalError { |
| 1573 final String message; | 1581 final String message; |
| 1574 const InternalError(this.message); | 1582 const InternalError(this.message); |
| 1575 String toString() => "InternalError: '$message'"; | 1583 String toString() => "InternalError: '$message'"; |
| 1576 } | 1584 } |
| OLD | NEW |