Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: pkg/dartdoc/dartdoc.dart

Issue 10823390: Full typedef support in dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed null check Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 if (comment != null) { 772 if (comment != null) {
773 writeln('<div class="doc">$comment</div>'); 773 writeln('<div class="doc">$comment</div>');
774 } 774 }
775 775
776 // Document the top-level members. 776 // Document the top-level members.
777 docMembers(library); 777 docMembers(library);
778 778
779 // Document the types. 779 // Document the types.
780 final classes = <InterfaceMirror>[]; 780 final classes = <InterfaceMirror>[];
781 final interfaces = <InterfaceMirror>[]; 781 final interfaces = <InterfaceMirror>[];
782 final typedefs = <TypedefMirror>[];
782 final exceptions = <InterfaceMirror>[]; 783 final exceptions = <InterfaceMirror>[];
783 784
784 for (InterfaceMirror type in orderByName(library.types.getValues())) { 785 for (InterfaceMirror type in orderByName(library.types.getValues())) {
785 if (type.isPrivate) continue; 786 if (type.isPrivate) continue;
786 787
787 if (isException(type)) { 788 if (isException(type)) {
788 exceptions.add(type); 789 exceptions.add(type);
789 } else if (type.isClass) { 790 } else if (type.isClass) {
790 classes.add(type); 791 classes.add(type);
792 } else if (type.isInterface){
793 interfaces.add(type);
791 } else { 794 } else {
792 interfaces.add(type); 795 assert(type is TypedefMirror);
ahe 2012/08/21 08:50:28 This is one of the many places where an assertion
Johnni Winther 2012/08/21 09:30:27 Done.
796 typedefs.add(type);
793 } 797 }
794 } 798 }
795 799
796 docTypes(classes, 'Classes'); 800 docTypes(classes, 'Classes');
797 docTypes(interfaces, 'Interfaces'); 801 docTypes(interfaces, 'Interfaces');
802 docTypes(typedefs, 'Typedefs');
798 docTypes(exceptions, 'Exceptions'); 803 docTypes(exceptions, 'Exceptions');
799 804
800 writeFooter(); 805 writeFooter();
801 endFile(); 806 endFile();
802 807
803 for (final type in library.types.getValues()) { 808 for (final type in library.types.getValues()) {
804 if (type.isPrivate) continue; 809 if (type.isPrivate) continue;
805 810
806 docType(type); 811 docType(type);
807 } 812 }
808 } 813 }
809 814
810 void docTypes(List<InterfaceMirror> types, String header) { 815 void docTypes(List types, String header) {
811 if (types.length == 0) return; 816 if (types.length == 0) return;
812 817
813 writeln('<h3>$header</h3>'); 818 writeln('<h3>$header</h3>');
814 819
815 for (final type in types) { 820 for (final type in types) {
816 writeln( 821 writeln(
817 ''' 822 '''
818 <div class="type"> 823 <div class="type">
819 <h4> 824 <h4>
820 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")} 825 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")}
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 void docTypedef(TypeMirror type) { 987 void docTypedef(TypeMirror type) {
983 if (type is! TypedefMirror) { 988 if (type is! TypedefMirror) {
984 return; 989 return;
985 } 990 }
986 writeln('<div class="method"><h4 id="${type.simpleName}">'); 991 writeln('<div class="method"><h4 id="${type.simpleName}">');
987 992
988 if (includeSource) { 993 if (includeSource) {
989 writeln('<span class="show-code">Code</span>'); 994 writeln('<span class="show-code">Code</span>');
990 } 995 }
991 996
992 if (type.definition !== null) { 997 write('typedef ');
993 // TODO(johnniwinther): Implement [:TypedefMirror.definition():]. 998 annotateType(type, type.definition, type.simpleName);
994 write('typedef ');
995 annotateType(type, type.definition, type.simpleName);
996 999
997 write(''' <a class="anchor-link" href="#${type.simpleName}" 1000 write(''' <a class="anchor-link" href="#${type.simpleName}"
998 title="Permalink to ${type.simpleName}">#</a>'''); 1001 title="Permalink to ${type.simpleName}">#</a>''');
999 }
1000 writeln('</h4>'); 1002 writeln('</h4>');
1001 1003
1002 docCode(type.location, null, showCode: true); 1004 docCode(type.location, null, showCode: true);
1003 1005
1004 writeln('</div>'); 1006 writeln('</div>');
1005 } 1007 }
1006 1008
1007 /** Document the constructors for [Type], if any. */ 1009 /** Document the constructors for [Type], if any. */
1008 void docConstructors(InterfaceMirror type) { 1010 void docConstructors(InterfaceMirror type) {
1009 final constructors = <MethodMirror>[]; 1011 final constructors = <MethodMirror>[];
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1586 }
1585 1587
1586 /** 1588 /**
1587 * Returns [:true:] if [type] should be regarded as an exception. 1589 * Returns [:true:] if [type] should be regarded as an exception.
1588 */ 1590 */
1589 bool isException(TypeMirror type) { 1591 bool isException(TypeMirror type) {
1590 return type.simpleName.endsWith('Exception'); 1592 return type.simpleName.endsWith('Exception');
1591 } 1593 }
1592 } 1594 }
1593 1595
OLDNEW
« no previous file with comments | « no previous file | pkg/dartdoc/mirrors/dart2js_mirror.dart » ('j') | pkg/dartdoc/mirrors/dart2js_mirror.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698