Skip to content

Commit 17f1172

Browse files
committed
Merge pull request #1056 from keertip/typedefs
show generics for typedefs
2 parents 7a5ecb7 + 2f68d4e commit 17f1172

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 0.8.4
22
* [enhancement] Only include generator metadata in the package `index.html` file.
33
* [bug] Fixed the display of deprecated properties.
4+
* [bug] show generics for typedefs
5+
* [bug] cleanly unzip docs on Mac
46

57
## 0.8.3
68
* [enhancement] Added `--[no-]include-source` option.

lib/src/html/template_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class TypedefTemplateData extends TemplateData<Typedef> {
308308
String get title =>
309309
'${typeDef.name} typedef - ${library.name} library - Dart API';
310310
String get layoutTitle =>
311-
_layoutTitle(typeDef.name, 'typedef', typeDef.isDeprecated);
311+
_layoutTitle(typeDef.nameWithGenerics, 'typedef', typeDef.isDeprecated);
312312
String get metaDescription =>
313313
'API docs for the ${typeDef.name} property from the '
314314
'${library.name} library, for the Dart programming language.';

lib/src/model.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,16 @@ class Typedef extends ModelElement implements EnclosedElement {
14981498

14991499
String get fileName => '$name.html';
15001500

1501+
String get nameWithGenerics {
1502+
if (!modelType.isParameterizedType) return name;
1503+
String n = '$name&lt;${_typeParameters.map((t) => t.name).join(', ')}&gt;';
1504+
return '$name&lt;${_typeParameters.map((t) => t.name).join(', ')}&gt;';
1505+
}
1506+
1507+
List<TypeParameter> get _typeParameters => _typedef.typeParameters.map((f) {
1508+
return new TypeParameter(f, library);
1509+
}).toList();
1510+
15011511
String get linkedReturnType => modelType != null
15021512
? modelType.createLinkedReturnTypeName()
15031513
: _typedef.returnType.name;

test_package/lib/example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const String COLOR_ORANGE = 'orange';
1919
const String COMPLEX_COLOR = 'red' + '-' + 'green' + '-' + 'blue';
2020
const ConstantCat MY_CAT = const ConstantCat('tabby');
2121

22-
typedef String processMessage(String msg);
22+
typedef String processMessage<T>(String msg);
2323

2424
/// This should [not work].
2525
const incorrectDocReferenceFromEx = 'doh';

test_package_docs/ex/processMessage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</ol>
5454
<div class="title-description">
5555
<h1 class="title">
56-
<span class="kind">typedef</span> processMessage
56+
<span class="kind">typedef</span> processMessage&lt;T&gt;
5757
</h1>
5858
</div>
5959
</div> <!-- /col -->

0 commit comments

Comments
 (0)