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

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

Issue 11090016: Change core lib, dart2js, and more for new optional parameters syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 1198
1199 if (inOptionals) write(']'); 1199 if (inOptionals) write(']');
1200 write(')'); 1200 write(')');
1201 } 1201 }
1202 1202
1203 /** 1203 /**
1204 * Documents the code contained within [span] with [comment]. If [showCode] 1204 * Documents the code contained within [span] with [comment]. If [showCode]
1205 * is `true` (and [includeSource] is set), also includes the source code. 1205 * is `true` (and [includeSource] is set), also includes the source code.
1206 */ 1206 */
1207 void docCode(ObjectMirror host, Location location, DocComment comment, 1207 void docCode(ObjectMirror host, Location location, DocComment comment,
1208 [bool showCode = false]) { 1208 {bool showCode: false}) {
1209 writeln('<div class="doc">'); 1209 writeln('<div class="doc">');
1210 if (comment != null) { 1210 if (comment != null) {
1211 if (comment.inheritedFrom !== null) { 1211 if (comment.inheritedFrom !== null) {
1212 writeln('<div class="inherited">'); 1212 writeln('<div class="inherited">');
1213 writeln(comment.html); 1213 writeln(comment.html);
1214 write('<div class="docs-inherited-from">docs inherited from '); 1214 write('<div class="docs-inherited-from">docs inherited from ');
1215 annotateType(host, comment.inheritedFrom); 1215 annotateType(host, comment.inheritedFrom);
1216 write('</div>'); 1216 write('</div>');
1217 writeln('</div>'); 1217 writeln('</div>');
1218 } else { 1218 } else {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 } 1420 }
1421 1421
1422 /** Creates a linked cross reference to [type]. */ 1422 /** Creates a linked cross reference to [type]. */
1423 typeReference(InterfaceMirror type) { 1423 typeReference(InterfaceMirror type) {
1424 // TODO(rnystrom): Do we need to handle ParameterTypes here like 1424 // TODO(rnystrom): Do we need to handle ParameterTypes here like
1425 // annotation() does? 1425 // annotation() does?
1426 return a(typeUrl(type), typeName(type), css: 'crossref'); 1426 return a(typeUrl(type), typeName(type), css: 'crossref');
1427 } 1427 }
1428 1428
1429 /** Generates a human-friendly string representation for a type. */ 1429 /** Generates a human-friendly string representation for a type. */
1430 typeName(TypeMirror type, [bool showBounds = false]) { 1430 typeName(TypeMirror type, {bool showBounds: false}) {
1431 if (type.isVoid) { 1431 if (type.isVoid) {
1432 return 'void'; 1432 return 'void';
1433 } 1433 }
1434 if (type is TypeVariableMirror) { 1434 if (type is TypeVariableMirror) {
1435 return type.simpleName; 1435 return type.simpleName;
1436 } 1436 }
1437 assert(type is InterfaceMirror); 1437 assert(type is InterfaceMirror);
1438 1438
1439 // See if it's a generic type. 1439 // See if it's a generic type.
1440 if (type.isDeclaration) { 1440 if (type.isDeclaration) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 // Syntax highlight. 1491 // Syntax highlight.
1492 return classifySource(code); 1492 return classifySource(code);
1493 } 1493 }
1494 1494
1495 /** 1495 /**
1496 * This will be called whenever a doc comment hits a `[name]` in square 1496 * This will be called whenever a doc comment hits a `[name]` in square
1497 * brackets. It will try to figure out what the name refers to and link or 1497 * brackets. It will try to figure out what the name refers to and link or
1498 * style it appropriately. 1498 * style it appropriately.
1499 */ 1499 */
1500 md.Node resolveNameReference(String name, 1500 md.Node resolveNameReference(String name,
1501 [MemberMirror currentMember = null, 1501 {MemberMirror currentMember: null,
Jennifer Messerly 2012/10/12 02:35:58 do we need the null here?
Lasse Reichstein Nielsen 2012/10/12 07:52:19 No (and we didn't before either). I'm usually all
regis 2012/10/12 17:51:51 Lasse is correct, nulls are redundant. This cl doe
1502 ObjectMirror currentType = null, 1502 ObjectMirror currentType: null,
1503 LibraryMirror currentLibrary = null]) { 1503 LibraryMirror currentLibrary: null}) {
1504 makeLink(String href) { 1504 makeLink(String href) {
1505 final anchor = new md.Element.text('a', name); 1505 final anchor = new md.Element.text('a', name);
1506 anchor.attributes['href'] = relativePath(href); 1506 anchor.attributes['href'] = relativePath(href);
1507 anchor.attributes['class'] = 'crossref'; 1507 anchor.attributes['class'] = 'crossref';
1508 return anchor; 1508 return anchor;
1509 } 1509 }
1510 1510
1511 // See if it's a parameter of the current method. 1511 // See if it's a parameter of the current method.
1512 if (currentMember is MethodMirror) { 1512 if (currentMember is MethodMirror) {
1513 for (final parameter in currentMember.parameters) { 1513 for (final parameter in currentMember.parameters) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 final InterfaceMirror inheritedFrom; 1639 final InterfaceMirror inheritedFrom;
1640 1640
1641 DocComment(this.text, [this.inheritedFrom = null]) { 1641 DocComment(this.text, [this.inheritedFrom = null]) {
1642 assert(text != null && !text.trim().isEmpty()); 1642 assert(text != null && !text.trim().isEmpty());
1643 } 1643 }
1644 1644
1645 String get html => md.markdownToHtml(text); 1645 String get html => md.markdownToHtml(text);
1646 1646
1647 String toString() => text; 1647 String toString() => text;
1648 } 1648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698