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

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

Issue 9153010: Naming change for code review. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | utils/dartdoc/test/dartdoc_tests.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) 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 int _totalMembers = 0; 98 int _totalMembers = 0;
99 99
100 Dartdoc() 100 Dartdoc()
101 : _comments = new CommentMap() { 101 : _comments = new CommentMap() {
102 // Patch in support for [:...:]-style code to the markdown parser. 102 // Patch in support for [:...:]-style code to the markdown parser.
103 // TODO(rnystrom): Markdown already has syntax for this. Phase this out? 103 // TODO(rnystrom): Markdown already has syntax for this. Phase this out?
104 md.InlineParser.syntaxes.insertRange(0, 1, 104 md.InlineParser.syntaxes.insertRange(0, 1,
105 new md.CodeSyntax(@'\[\:((?:.|\n)*?)\:\]')); 105 new md.CodeSyntax(@'\[\:((?:.|\n)*?)\:\]'));
106 106
107 md.setImplicitLinkResolver((name) => resolveNameReference(name, 107 md.setImplicitLinkResolver((name) => resolveNameReference(name,
108 currentLibrary: _currentLibrary, currentType: _currentType, 108 library: _currentLibrary, type: _currentType,
109 currentMember: _currentMember)); 109 member: _currentMember));
110 } 110 }
111 111
112 document(String entrypoint) { 112 document(String entrypoint) {
113 var oldDietParse = options.dietParse; 113 var oldDietParse = options.dietParse;
114 try { 114 try {
115 options.dietParse = true; 115 options.dietParse = true;
116 116
117 // Handle the built-in entrypoints. 117 // Handle the built-in entrypoints.
118 switch (entrypoint) { 118 switch (entrypoint) {
119 case 'corelib': 119 case 'corelib':
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 775
776 // Syntax highlight. 776 // Syntax highlight.
777 return classifySource(new SourceFile('', code)); 777 return classifySource(new SourceFile('', code));
778 } 778 }
779 779
780 /** 780 /**
781 * This will be called whenever a doc comment hits a `[name]` in square 781 * This will be called whenever a doc comment hits a `[name]` in square
782 * brackets. It will try to figure out what the name refers to and link or 782 * brackets. It will try to figure out what the name refers to and link or
783 * style it appropriately. 783 * style it appropriately.
784 */ 784 */
785 md.Node resolveNameReference(String name, [Member currentMember = null, 785 md.Node resolveNameReference(String name, [Member member = null,
786 Type currentType = null, Library currentLibrary = null]) { 786 Type type = null, Library library = null]) {
787 makeLink(String href) { 787 makeLink(String href) {
788 final anchor = new md.Element.text('a', name); 788 final anchor = new md.Element.text('a', name);
789 anchor.attributes['href'] = relativePath(href); 789 anchor.attributes['href'] = relativePath(href);
790 anchor.attributes['class'] = 'crossref'; 790 anchor.attributes['class'] = 'crossref';
791 return anchor; 791 return anchor;
792 } 792 }
793 793
794 findMember(Type type) { 794 findMember(Type type) {
795 final member = type.members[name]; 795 final member = type.members[name];
796 if (member == null) return null; 796 if (member == null) return null;
797 797
798 // Special case: if the member we've resolved is a property (i.e. it wraps 798 // Special case: if the member we've resolved is a property (i.e. it wraps
799 // a getter and/or setter then *that* member itself won't be on the docs, 799 // a getter and/or setter then *that* member itself won't be on the docs,
800 // just the getter or setter will be. So pick one of those to link to. 800 // just the getter or setter will be. So pick one of those to link to.
801 if (member.isProperty) { 801 if (member.isProperty) {
802 return member.canGet ? member.getter : member.setter; 802 return member.canGet ? member.getter : member.setter;
803 } 803 }
804 804
805 return member; 805 return member;
806 } 806 }
807 807
808 // See if it's a parameter of the current method. 808 // See if it's a parameter of the current method.
809 if (currentMember != null) { 809 if (member != null) {
810 for (final parameter in currentMember.parameters) { 810 for (final parameter in member.parameters) {
811 if (parameter.name == name) { 811 if (parameter.name == name) {
812 final element = new md.Element.text('span', name); 812 final element = new md.Element.text('span', name);
813 element.attributes['class'] = 'param'; 813 element.attributes['class'] = 'param';
814 return element; 814 return element;
815 } 815 }
816 } 816 }
817 } 817 }
818 818
819 // See if it's another member of the current type. 819 // See if it's another member of the current type.
820 if (currentType != null) { 820 if (type != null) {
821 final member = findMember(currentType); 821 final member = findMember(type);
822 if (member != null) { 822 if (member != null) {
823 return makeLink(memberUrl(member)); 823 return makeLink(memberUrl(member));
824 } 824 }
825 } 825 }
826 826
827 // See if it's another type in the current library. 827 // See if it's another type in the current library.
828 if (currentLibrary != null) { 828 if (library != null) {
829 final type = currentLibrary.types[name]; 829 final type = library.types[name];
830 if (type != null) { 830 if (type != null) {
831 return makeLink(typeUrl(type)); 831 return makeLink(typeUrl(type));
832 } 832 }
833 833
834 // See if it's a top-level member in the current library. 834 // See if it's a top-level member in the current library.
835 final member = findMember(currentLibrary.topType); 835 final member = findMember(library.topType);
836 if (member != null) { 836 if (member != null) {
837 return makeLink(memberUrl(member)); 837 return makeLink(memberUrl(member));
838 } 838 }
839 } 839 }
840 840
841 // TODO(rnystrom): Should also consider: 841 // TODO(rnystrom): Should also consider:
842 // * Names imported by libraries this library imports. 842 // * Names imported by libraries this library imports.
843 // * Type parameters of the enclosing type. 843 // * Type parameters of the enclosing type.
844 844
845 return new md.Element.text('code', name); 845 return new md.Element.text('code', name);
846 } 846 }
847 847
848 // TODO(rnystrom): Move into SourceSpan? 848 // TODO(rnystrom): Move into SourceSpan?
849 int getSpanColumn(SourceSpan span) { 849 int getSpanColumn(SourceSpan span) {
850 final line = span.file.getLine(span.start); 850 final line = span.file.getLine(span.start);
851 return span.file.getColumn(line, span.start); 851 return span.file.getColumn(line, span.start);
852 } 852 }
853 } 853 }
OLDNEW
« no previous file with comments | « no previous file | utils/dartdoc/test/dartdoc_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698