| 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // Look for a comment for the entire library. | 737 // Look for a comment for the entire library. |
| 738 final comment = getLibraryComment(library); | 738 final comment = getLibraryComment(library); |
| 739 if (comment != null) { | 739 if (comment != null) { |
| 740 writeln('<div class="doc">${comment.html}</div>'); | 740 writeln('<div class="doc">${comment.html}</div>'); |
| 741 } | 741 } |
| 742 | 742 |
| 743 // Document the top-level members. | 743 // Document the top-level members. |
| 744 docMembers(library); | 744 docMembers(library); |
| 745 | 745 |
| 746 // Document the types. | 746 // Document the types. |
| 747 final interfaces = <ClassMirror>[]; |
| 748 final abstractClasses = <ClassMirror>[]; |
| 747 final classes = <ClassMirror>[]; | 749 final classes = <ClassMirror>[]; |
| 748 final interfaces = <ClassMirror>[]; | |
| 749 final typedefs = <TypedefMirror>[]; | 750 final typedefs = <TypedefMirror>[]; |
| 750 final exceptions = <ClassMirror>[]; | 751 final exceptions = <ClassMirror>[]; |
| 751 | 752 |
| 752 for (ClassMirror type in orderByName(library.classes.values)) { | 753 for (ClassMirror type in orderByName(library.classes.values)) { |
| 753 if (!showPrivate && type.isPrivate) continue; | 754 if (!showPrivate && type.isPrivate) continue; |
| 754 | 755 |
| 755 if (isException(type)) { | 756 if (isException(type)) { |
| 756 exceptions.add(type); | 757 exceptions.add(type); |
| 757 } else if (type.isClass) { | 758 } else if (type.isClass) { |
| 758 classes.add(type); | 759 if (type.isAbstract) { |
| 760 abstractClasses.add(type); |
| 761 } else { |
| 762 classes.add(type); |
| 763 } |
| 759 } else if (type.isInterface){ | 764 } else if (type.isInterface){ |
| 760 interfaces.add(type); | 765 interfaces.add(type); |
| 761 } else if (type is TypedefMirror) { | 766 } else if (type is TypedefMirror) { |
| 762 typedefs.add(type); | 767 typedefs.add(type); |
| 763 } else { | 768 } else { |
| 764 throw new InternalError("internal error: unknown type $type."); | 769 throw new InternalError("internal error: unknown type $type."); |
| 765 } | 770 } |
| 766 } | 771 } |
| 767 | 772 |
| 773 docTypes(interfaces, 'Interfaces'); |
| 774 docTypes(abstractClasses, 'Abstract Classes'); |
| 768 docTypes(classes, 'Classes'); | 775 docTypes(classes, 'Classes'); |
| 769 docTypes(interfaces, 'Interfaces'); | |
| 770 docTypes(typedefs, 'Typedefs'); | 776 docTypes(typedefs, 'Typedefs'); |
| 771 docTypes(exceptions, 'Exceptions'); | 777 docTypes(exceptions, 'Exceptions'); |
| 772 | 778 |
| 773 writeFooter(); | 779 writeFooter(); |
| 774 endFile(); | 780 endFile(); |
| 775 | 781 |
| 776 for (final type in library.classes.values) { | 782 for (final type in library.classes.values) { |
| 777 if (!showPrivate && type.isPrivate) continue; | 783 if (!showPrivate && type.isPrivate) continue; |
| 778 | 784 |
| 779 docType(type); | 785 docType(type); |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 Path relativeFilePath = filePath.relativeTo(outputDir); | 1832 Path relativeFilePath = filePath.relativeTo(outputDir); |
| 1827 write("$relativeFilePath\n"); | 1833 write("$relativeFilePath\n"); |
| 1828 }; | 1834 }; |
| 1829 toCacheLister.onDone = (done) => endFile(); | 1835 toCacheLister.onDone = (done) => endFile(); |
| 1830 } | 1836 } |
| 1831 | 1837 |
| 1832 /** | 1838 /** |
| 1833 * Returns [:true:] if [type] should be regarded as an exception. | 1839 * Returns [:true:] if [type] should be regarded as an exception. |
| 1834 */ | 1840 */ |
| 1835 bool isException(TypeMirror type) { | 1841 bool isException(TypeMirror type) { |
| 1836 return type.simpleName.endsWith('Exception'); | 1842 return type.simpleName.endsWith('Exception') || |
| 1843 type.simpleName.endsWith('Error'); |
| 1837 } | 1844 } |
| 1838 } | 1845 } |
| 1839 | 1846 |
| 1840 /** | 1847 /** |
| 1841 * Used to report an unexpected error in the DartDoc tool or the | 1848 * Used to report an unexpected error in the DartDoc tool or the |
| 1842 * underlying data | 1849 * underlying data |
| 1843 */ | 1850 */ |
| 1844 class InternalError { | 1851 class InternalError { |
| 1845 final String message; | 1852 final String message; |
| 1846 const InternalError(this.message); | 1853 const InternalError(this.message); |
| 1847 String toString() => "InternalError: '$message'"; | 1854 String toString() => "InternalError: '$message'"; |
| 1848 } | 1855 } |
| 1849 | 1856 |
| 1850 class DocComment { | 1857 class DocComment { |
| 1851 final String text; | 1858 final String text; |
| 1852 | 1859 |
| 1853 /** | 1860 /** |
| 1854 * Non-null if the comment is inherited from another declaration. | 1861 * Non-null if the comment is inherited from another declaration. |
| 1855 */ | 1862 */ |
| 1856 final ClassMirror inheritedFrom; | 1863 final ClassMirror inheritedFrom; |
| 1857 | 1864 |
| 1858 DocComment(this.text, [this.inheritedFrom = null]) { | 1865 DocComment(this.text, [this.inheritedFrom = null]) { |
| 1859 assert(text != null && !text.trim().isEmpty); | 1866 assert(text != null && !text.trim().isEmpty); |
| 1860 } | 1867 } |
| 1861 | 1868 |
| 1862 String get html => md.markdownToHtml(text); | 1869 String get html => md.markdownToHtml(text); |
| 1863 | 1870 |
| 1864 String toString() => text; | 1871 String toString() => text; |
| 1865 } | 1872 } |
| OLD | NEW |