Skip to content

Commit

Permalink
Display 'Available extensions' in more, correct, places (#3852)
Browse files Browse the repository at this point in the history
We weren't displaying them on enums, mixins, or extension types.

Also fixed some capitalization, and margins.
  • Loading branch information
srawlins authored Aug 28, 2024
1 parent dc56630 commit 218e8c1
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 113 deletions.
1 change: 1 addition & 0 deletions lib/resources/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ footer a, footer a:hover {
}

.markdown.desc {
margin-bottom: 1em;
max-width: 700px;
}

Expand Down
227 changes: 127 additions & 100 deletions lib/src/generator/templates.aot_renderers_for_html.dart

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions lib/templates/_available_extensions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ #hasPotentiallyApplicableExtensions }}
<dt>Available extensions</dt>
<dd><ul class="comma-separated clazz-relationships">
{{ #potentiallyApplicableExtensionsSorted }}
<li>{{{ linkedName }}}</li>
{{ /potentiallyApplicableExtensionsSorted }}
</ul></dd>
{{ /hasPotentiallyApplicableExtensions }}
2 changes: 1 addition & 1 deletion lib/templates/_mixed_in_types.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ #hasPublicMixedInTypes }}
<dt>Mixed in types</dt>
<dt>Mixed-in types</dt>
<dd>
<ul class="comma-separated {{ relationshipsClass }}">
{{ #publicMixedInTypes }}
Expand Down
10 changes: 1 addition & 9 deletions lib/templates/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
</ul></dd>
{{ /hasPublicImplementers }}

{{ #hasPotentiallyApplicableExtensions }}
<dt>Available Extensions</dt>
<dd><ul class="comma-separated clazz-relationships">
{{ #potentiallyApplicableExtensionsSorted }}
<li>{{{ linkedName }}}</li>
{{ /potentiallyApplicableExtensionsSorted }}
</ul></dd>
{{ /hasPotentiallyApplicableExtensions }}

{{ >available_extensions }}
{{ >container_annotations }}
</dl>
</section>
Expand Down
1 change: 1 addition & 0 deletions lib/templates/enum.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1>
{{ >super_chain }}
{{ >interfaces }}
{{ >mixed_in_types }}
{{ >available_extensions }}
{{ >container_annotations }}
</dl>
</section>
Expand Down
1 change: 1 addition & 0 deletions lib/templates/extension_type.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{{ /publicImplementersSorted }}
</ul></dd>
{{ /hasPublicImplementers }}
{{ >available_extensions }}
</dl>
{{ >container_annotations }}
</section>
Expand Down
5 changes: 3 additions & 2 deletions lib/templates/mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<section>
<dl class="dl-horizontal">
{{ #hasPublicSuperclassConstraints }}
<dt>Superclass Constraints</dt>
<dt>Superclass constraints</dt>
<dd><ul class="comma-separated dark mixin-relationships">
{{ #publicSuperclassConstraints }}
<li>{{{ linkedName }}}</li>
Expand All @@ -28,7 +28,7 @@
{{ >interfaces }}

{{ #hasPublicImplementers }}
<dt>Mixin Applications</dt>
<dt>Mixin applications</dt>
<dd>
<ul class="comma-separated mixin-relationships">
{{ #publicImplementersSorted }}
Expand All @@ -37,6 +37,7 @@
</ul>
</dd>
{{ /hasPublicImplementers }}
{{ >available_extensions }}

{{ >annotations }}
</dl>
Expand Down
15 changes: 15 additions & 0 deletions test/templates/class_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ mixin M on _M {}
]);
}

void test_availableExtensions_direct() async {
await createPackageWithLibrary('''
class C {}
extension E on C {}
''');
var baseLines = readLines(['lib', 'C-class.html']);

baseLines.expectMainContentContainsAllInOrder([
matches('<dt>Available extensions</dt>'),
matches('<dd><ul class="comma-separated clazz-relationships">'),
matches('<li><a href="../lib/E.html">E</a></li>'),
matches('</ul></dd>'),
]);
}

void test_constructor_named() async {
await createPackageWithLibrary('''
class C {
Expand Down
13 changes: 12 additions & 1 deletion test/templates/enum_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ enum EnumWithDefaultConstructor {
/// Doc comment for [six].
six;
}
extension Ext<T> on E<T> {}
'''),
],
resourceProvider: resourceProvider,
Expand Down Expand Up @@ -158,13 +160,22 @@ enum EnumWithDefaultConstructor {
expect(
eLines,
containsAllInOrder([
matches('<dt>Mixed in types</dt>'),
matches('<dt>Mixed-in types</dt>'),
matches('<a href="../lib/M-mixin.html">M</a>'
'<span class="signature">&lt;<wbr>'
'<span class="type-parameter">T</span>&gt;</span>'),
]));
});

test('enum page contains available extensions', () async {
expect(
eLines,
containsAllInOrder([
matches('<dt>Available extensions</dt>'),
matches('<a href="../lib/E.html">E</a></span>'),
]));
});

test('enum page contains annotations', () async {
eLines.expectMainContentContainsAllInOrder([
matches('<dt>Annotations</dt>'),
Expand Down
15 changes: 15 additions & 0 deletions test/templates/extension_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ extension type Two(List<int> it) implements One<int> {}
]);
}

void test_availableExtensions() async {
await createPackageWithLibrary('''
extension type One(int it) {}
extension E on One {}
''');
var htmlLines = readLines(['lib', 'One-extension-type.html']);

htmlLines.expectMainContentContainsAllInOrder([
matches('<dt>Available extensions</dt>'),
matches('<dd><ul class="comma-separated clazz-relationships">'),
matches('<li><a href="../lib/E.html">E</a></li>'),
matches('</ul></dd>'),
]);
}

void test_constructors() async {
await createPackageWithLibrary('''
extension type One(int it) {
Expand Down

0 comments on commit 218e8c1

Please sign in to comment.