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

Unified Diff: client/lib/item.dart

Issue 273473002: Display function signatures instead of just "Function". (Closed) Base URL: https://github.com/dart-lang/dartdoc-viewer.git@master
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/lib/components/typedef.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/lib/item.dart
diff --git a/client/lib/item.dart b/client/lib/item.dart
index 7b5e738126b41f2071ce532a632edd3ffbf3c507..02348a3aa6880e9dd990edad11f71438625c51c7 100644
--- a/client/lib/item.dart
+++ b/client/lib/item.dart
@@ -841,6 +841,37 @@ class Method extends Parameterized {
String toString() => decoratedName;
}
+/** The signature for a function that is passed in as a parameter to a method.*/
+class Closure extends Parameterized {
+ List<Parameter> parameters;
+ final NestedType returnType;
+ final String name;
+
+ Closure(String name, Map yaml, [Item owner]) :
+ name = name,
+ returnType = new NestedType(yaml['return'].first),
+ super('closure', null) {
+ parameters = getParameters(yaml['parameters']);
+ _owner = owner;
+ }
+
+ // For a method parameter we use the special anchor @method,parameter
+ // because the parameter name may not be unique on the page
+ DocsLocation get anchorHrefLocation {
+ if (owner == null) return null;
+
+ var ownerLocation = owner.anchorHrefLocation;
+ var ownerAnchor = ownerLocation.anchor;
+ ownerLocation.anchor = ownerAnchor == null ?
+ hashDecoratedName : "$ownerAnchor$hashDecoratedName";
+ return ownerLocation;
+ }
+
+ String get anchorHref => anchorHrefLocation.withAnchor;
+
+ String get hashDecoratedName => "$PARAMETER_SEPARATOR$name";
+}
+
/**
* A single parameter to a [Method].
*/
@@ -852,6 +883,7 @@ class Parameter extends Item {
final NestedType type;
final String defaultValue;
final AnnotationGroup annotations;
+ final Closure functionDeclaration;
Parameter(String name, Map yaml, [Item owner])
: isOptional = _boolFor('optional', yaml),
@@ -860,6 +892,8 @@ class Parameter extends Item {
type = new NestedType(yaml['type'].first),
defaultValue = yaml['value'],
annotations = new AnnotationGroup(yaml['annotations']),
+ functionDeclaration = yaml['functionDeclaration'] == null? null
+ : new Closure(name, yaml['functionDeclaration'], owner),
super(name, null) {
_owner = owner;
}
« no previous file with comments | « client/lib/components/typedef.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698