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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 */ | 882 */ |
883 void docInheritance(ClassMirror type) { | 883 void docInheritance(ClassMirror type) { |
884 // Don't show the inheritance details for Object. It doesn't have any base | 884 // Don't show the inheritance details for Object. It doesn't have any base |
885 // class (obviously) and it has too many subclasses to be useful. | 885 // class (obviously) and it has too many subclasses to be useful. |
886 if (type.isObject) return; | 886 if (type.isObject) return; |
887 | 887 |
888 // Writes an unordered list of references to types with an optional header. | 888 // Writes an unordered list of references to types with an optional header. |
889 listTypes(types, header) { | 889 listTypes(types, header) { |
890 if (types == null) return; | 890 if (types == null) return; |
891 | 891 |
| 892 // Filter out injected types. (JavaScriptIndexingBehavior) |
| 893 types = new List.from(types.filter((t) => t.library != null)); |
| 894 |
892 var publicTypes; | 895 var publicTypes; |
893 if (showPrivate) { | 896 if (showPrivate) { |
894 publicTypes = types; | 897 publicTypes = types; |
895 } else { | 898 } else { |
896 // Skip private types. | 899 // Skip private types. |
897 publicTypes = new List.from(types.filter((t) => !t.isPrivate)); | 900 publicTypes = new List.from(types.filter((t) => !t.isPrivate)); |
898 } | 901 } |
899 if (publicTypes.length == 0) return; | 902 if (publicTypes.length == 0) return; |
900 | 903 |
901 writeln('<h3>$header</h3>'); | 904 writeln('<h3>$header</h3>'); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 /** Gets the URL to the documentation for [library]. */ | 1524 /** Gets the URL to the documentation for [library]. */ |
1522 String libraryUrl(LibraryMirror library) { | 1525 String libraryUrl(LibraryMirror library) { |
1523 return '${sanitize(displayName(library))}.html'; | 1526 return '${sanitize(displayName(library))}.html'; |
1524 } | 1527 } |
1525 | 1528 |
1526 /** Gets the URL for the documentation for [type]. */ | 1529 /** Gets the URL for the documentation for [type]. */ |
1527 String typeUrl(ContainerMirror type) { | 1530 String typeUrl(ContainerMirror type) { |
1528 if (type is LibraryMirror) { | 1531 if (type is LibraryMirror) { |
1529 return '${sanitize(type.simpleName)}.html'; | 1532 return '${sanitize(type.simpleName)}.html'; |
1530 } | 1533 } |
1531 assert (type is TypeMirror); | 1534 if (type.library == null) { |
| 1535 return ''; |
| 1536 } |
1532 // Always get the generic type to strip off any type parameters or | 1537 // Always get the generic type to strip off any type parameters or |
1533 // arguments. If the type isn't generic, genericType returns `this`, so it | 1538 // arguments. If the type isn't generic, genericType returns `this`, so it |
1534 // works for non-generic types too. | 1539 // works for non-generic types too. |
1535 return '${sanitize(displayName(type.library))}/' | 1540 return '${sanitize(displayName(type.library))}/' |
1536 '${type.originalDeclaration.simpleName}.html'; | 1541 '${type.originalDeclaration.simpleName}.html'; |
1537 } | 1542 } |
1538 | 1543 |
1539 /** Gets the URL for the documentation for [member]. */ | 1544 /** Gets the URL for the documentation for [member]. */ |
1540 String memberUrl(MemberMirror member) { | 1545 String memberUrl(MemberMirror member) { |
1541 String url = typeUrl(member.owner); | 1546 String url = typeUrl(member.owner); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 final ClassMirror inheritedFrom; | 1861 final ClassMirror inheritedFrom; |
1857 | 1862 |
1858 DocComment(this.text, [this.inheritedFrom = null]) { | 1863 DocComment(this.text, [this.inheritedFrom = null]) { |
1859 assert(text != null && !text.trim().isEmpty); | 1864 assert(text != null && !text.trim().isEmpty); |
1860 } | 1865 } |
1861 | 1866 |
1862 String get html => md.markdownToHtml(text); | 1867 String get html => md.markdownToHtml(text); |
1863 | 1868 |
1864 String toString() => text; | 1869 String toString() => text; |
1865 } | 1870 } |
OLD | NEW |