| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 use it, from this directory, run: | 6 * To use it, from this directory, run: |
| 7 * | 7 * |
| 8 * $ ./dartdoc <path to .dart file> | 8 * $ ./dartdoc <path to .dart file> |
| 9 * | 9 * |
| 10 * This will create a "docs" directory with the docs for your libraries. To | 10 * This will create a "docs" directory with the docs for your libraries. To |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 return const RegExp(@'^\w+:').hasMatch(url); | 898 return const RegExp(@'^\w+:').hasMatch(url); |
| 899 } | 899 } |
| 900 | 900 |
| 901 /** Gets the URL to the documentation for [library]. */ | 901 /** Gets the URL to the documentation for [library]. */ |
| 902 String libraryUrl(Library library) { | 902 String libraryUrl(Library library) { |
| 903 return '${sanitize(library.name)}.html'; | 903 return '${sanitize(library.name)}.html'; |
| 904 } | 904 } |
| 905 | 905 |
| 906 /** Gets the URL for the documentation for [type]. */ | 906 /** Gets the URL for the documentation for [type]. */ |
| 907 String typeUrl(Type type) { | 907 String typeUrl(Type type) { |
| 908 if (type.isTop) return '${sanitize(type.library.name)}.html'; |
| 908 // Always get the generic type to strip off any type parameters or | 909 // Always get the generic type to strip off any type parameters or |
| 909 // arguments. If the type isn't generic, genericType returns `this`, so it | 910 // arguments. If the type isn't generic, genericType returns `this`, so it |
| 910 // works for non-generic types too. | 911 // works for non-generic types too. |
| 911 return '${sanitize(type.library.name)}/${type.genericType.name}.html'; | 912 return '${sanitize(type.library.name)}/${type.genericType.name}.html'; |
| 912 } | 913 } |
| 913 | 914 |
| 914 /** Gets the URL for the documentation for [member]. */ | 915 /** Gets the URL for the documentation for [member]. */ |
| 915 String memberUrl(Member member) { | 916 String memberUrl(Member member) { |
| 916 return '${typeUrl(member.declaringType)}#${member.name}'; | 917 final typeUrl = typeUrl(member.declaringType); |
| 918 if (!member.isConstructor) return '$typeUrl#${member.name}'; |
| 919 if (member.constructorName == '') return '$typeUrl#new:${member.name}'; |
| 920 return '$typeUrl#new:${member.name}.${member.constructorName}'; |
| 917 } | 921 } |
| 918 | 922 |
| 919 /** Gets the anchor id for the document for [member]. */ | 923 /** Gets the anchor id for the document for [member]. */ |
| 920 String memberAnchor(Member member) { | 924 String memberAnchor(Member member) { |
| 921 return '${member.name}'; | 925 return '${member.name}'; |
| 922 } | 926 } |
| 923 | 927 |
| 924 /** | 928 /** |
| 925 * Creates a hyperlink. Handles turning the [href] into an appropriate | 929 * Creates a hyperlink. Handles turning the [href] into an appropriate |
| 926 * relative path from the current file. | 930 * relative path from the current file. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 | 1157 |
| 1154 return new md.Element.text('code', name); | 1158 return new md.Element.text('code', name); |
| 1155 } | 1159 } |
| 1156 | 1160 |
| 1157 // TODO(rnystrom): Move into SourceSpan? | 1161 // TODO(rnystrom): Move into SourceSpan? |
| 1158 int getSpanColumn(SourceSpan span) { | 1162 int getSpanColumn(SourceSpan span) { |
| 1159 final line = span.file.getLine(span.start); | 1163 final line = span.file.getLine(span.start); |
| 1160 return span.file.getColumn(line, span.start); | 1164 return span.file.getColumn(line, span.start); |
| 1161 } | 1165 } |
| 1162 } | 1166 } |
| OLD | NEW |