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

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: Updated cf. comments. 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
« no previous file with comments | « no previous file | pkg/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
794 } else if (type is TypedefMirror) {
795 typedefs.add(type);
791 } else { 796 } else {
792 interfaces.add(type); 797 throw new InternalError("internal error: unknown type $type.");
793 } 798 }
794 } 799 }
795 800
796 docTypes(classes, 'Classes'); 801 docTypes(classes, 'Classes');
797 docTypes(interfaces, 'Interfaces'); 802 docTypes(interfaces, 'Interfaces');
803 docTypes(typedefs, 'Typedefs');
798 docTypes(exceptions, 'Exceptions'); 804 docTypes(exceptions, 'Exceptions');
799 805
800 writeFooter(); 806 writeFooter();
801 endFile(); 807 endFile();
802 808
803 for (final type in library.types.getValues()) { 809 for (final type in library.types.getValues()) {
804 if (type.isPrivate) continue; 810 if (type.isPrivate) continue;
805 811
806 docType(type); 812 docType(type);
807 } 813 }
808 } 814 }
809 815
810 void docTypes(List<InterfaceMirror> types, String header) { 816 void docTypes(List types, String header) {
811 if (types.length == 0) return; 817 if (types.length == 0) return;
812 818
813 writeln('<h3>$header</h3>'); 819 writeln('<h3>$header</h3>');
814 820
815 for (final type in types) { 821 for (final type in types) {
816 writeln( 822 writeln(
817 ''' 823 '''
818 <div class="type"> 824 <div class="type">
819 <h4> 825 <h4>
820 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")} 826 ${a(typeUrl(type), "<strong>${typeName(type)}</strong>")}
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 void docTypedef(TypeMirror type) { 988 void docTypedef(TypeMirror type) {
983 if (type is! TypedefMirror) { 989 if (type is! TypedefMirror) {
984 return; 990 return;
985 } 991 }
986 writeln('<div class="method"><h4 id="${type.simpleName}">'); 992 writeln('<div class="method"><h4 id="${type.simpleName}">');
987 993
988 if (includeSource) { 994 if (includeSource) {
989 writeln('<span class="show-code">Code</span>'); 995 writeln('<span class="show-code">Code</span>');
990 } 996 }
991 997
992 if (type.definition !== null) { 998 write('typedef ');
993 // TODO(johnniwinther): Implement [:TypedefMirror.definition():]. 999 annotateType(type, type.definition, type.simpleName);
994 write('typedef ');
995 annotateType(type, type.definition, type.simpleName);
996 1000
997 write(''' <a class="anchor-link" href="#${type.simpleName}" 1001 write(''' <a class="anchor-link" href="#${type.simpleName}"
998 title="Permalink to ${type.simpleName}">#</a>'''); 1002 title="Permalink to ${type.simpleName}">#</a>''');
999 }
1000 writeln('</h4>'); 1003 writeln('</h4>');
1001 1004
1002 docCode(type.location, null, showCode: true); 1005 docCode(type.location, null, showCode: true);
1003 1006
1004 writeln('</div>'); 1007 writeln('</div>');
1005 } 1008 }
1006 1009
1007 /** Document the constructors for [Type], if any. */ 1010 /** Document the constructors for [Type], if any. */
1008 void docConstructors(InterfaceMirror type) { 1011 void docConstructors(InterfaceMirror type) {
1009 final constructors = <MethodMirror>[]; 1012 final constructors = <MethodMirror>[];
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1587 }
1585 1588
1586 /** 1589 /**
1587 * Returns [:true:] if [type] should be regarded as an exception. 1590 * Returns [:true:] if [type] should be regarded as an exception.
1588 */ 1591 */
1589 bool isException(TypeMirror type) { 1592 bool isException(TypeMirror type) {
1590 return type.simpleName.endsWith('Exception'); 1593 return type.simpleName.endsWith('Exception');
1591 } 1594 }
1592 } 1595 }
1593 1596
OLDNEW
« no previous file with comments | « no previous file | pkg/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698