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

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

Issue 10779010: Parameters with function types supported + Added features in mirrors implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 bool first = true; 1091 bool first = true;
1092 bool inOptionals = false; 1092 bool inOptionals = false;
1093 for (final parameter in parameters) { 1093 for (final parameter in parameters) {
1094 if (!first) write(', '); 1094 if (!first) write(', ');
1095 1095
1096 if (!inOptionals && parameter.isOptional()) { 1096 if (!inOptionals && parameter.isOptional()) {
1097 write('['); 1097 write('[');
1098 inOptionals = true; 1098 inOptionals = true;
1099 } 1099 }
1100 1100
1101 annotateType(enclosingType, parameter.type(), parameter.simpleName()); 1101 var paramName = parameter.simpleName();
1102 if (paramName.startsWith('_') &&
floitsch 2012/07/17 18:53:04 It is probably not that easy. You need to check th
Johnni Winther 2012/07/18 13:32:50 Left out for now.
1103 paramName != "_" &&
1104 parameter.isInitializingFormal()) {
1105 paramName = paramName.substring(1);
1106 }
1107 annotateType(enclosingType, parameter.type(), paramName);
1102 1108
1103 // Show the default value for named optional parameters. 1109 // Show the default value for named optional parameters.
1104 if (parameter.isOptional() && parameter.hasDefaultValue()) { 1110 if (parameter.isOptional() && parameter.hasDefaultValue()) {
1105 write(' = '); 1111 write(' = ');
1106 write(parameter.defaultValue()); 1112 write(parameter.defaultValue());
1107 } 1113 }
1108 1114
1109 first = false; 1115 first = false;
1110 } 1116 }
1111 1117
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 } 1262 }
1257 1263
1258 /** Writes a link to a human-friendly string representation for a type. */ 1264 /** Writes a link to a human-friendly string representation for a type. */
1259 linkToType(ObjectMirror enclosingType, TypeMirror type) { 1265 linkToType(ObjectMirror enclosingType, TypeMirror type) {
1260 if (type.isVoid) { 1266 if (type.isVoid) {
1261 // Do not generate links for void. 1267 // Do not generate links for void.
1262 // TODO(johnniwinter): Generate span for specific style? 1268 // TODO(johnniwinter): Generate span for specific style?
1263 write('void'); 1269 write('void');
1264 return; 1270 return;
1265 } 1271 }
1272 if (type.isDynamic) {
1273 // Do not generate links for Dynamic.
1274 write('Dynamic');
1275 return;
1276 }
1266 1277
1267 if (type.isTypeVariable) { 1278 if (type.isTypeVariable) {
1268 // If we're using a type parameter within the body of a generic class then 1279 // If we're using a type parameter within the body of a generic class then
1269 // just link back up to the class. 1280 // just link back up to the class.
1270 write(a(typeUrl(enclosingType), type.simpleName())); 1281 write(a(typeUrl(enclosingType), type.simpleName()));
1271 return; 1282 return;
1272 } 1283 }
1273 1284
1274 assert(type is InterfaceMirror); 1285 assert(type is InterfaceMirror);
1275 1286
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1489 }
1479 1490
1480 /** 1491 /**
1481 * Returns [:true:] if [type] should be regarded as an exception. 1492 * Returns [:true:] if [type] should be regarded as an exception.
1482 */ 1493 */
1483 bool isException(TypeMirror type) { 1494 bool isException(TypeMirror type) {
1484 return type.simpleName().endsWith('Exception'); 1495 return type.simpleName().endsWith('Exception');
1485 } 1496 }
1486 } 1497 }
1487 1498
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698