Skip to content

Commit c4f304f

Browse files
authored
Write out extension type constructor docs (#3602)
1 parent 7ac2a1c commit c4f304f

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

lib/src/generator/generator_frontend.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ class GeneratorFrontEnd implements Generator {
194194
_generatorBackend.generateExtensionType(
195195
packageGraph, lib, extensionType);
196196

197+
for (var constructor
198+
in filterNonDocumented(extensionType.constructors)) {
199+
if (!constructor.isCanonical) continue;
200+
201+
indexAccumulator.add(constructor);
202+
_generatorBackend.generateConstructor(
203+
packageGraph, lib, extensionType, constructor);
204+
}
205+
197206
for (var constant
198207
in filterNonDocumented(extensionType.constantFields)) {
199208
indexAccumulator.add(constant);

test/templates/extension_type_test.dart

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class FooSub extends Foo<int> {}
8989
9090
extension type One<E>(Foo<E> it) {
9191
/// A named constructor.
92-
MyIterable.named(Foo<E> e);
92+
One.named(Foo<E> e);
9393
9494
/// An instance method.
9595
void m1() {}
@@ -147,6 +147,28 @@ dartdoc:
147147
]);
148148
});
149149

150+
test('primary constructor page is rendered', () async {
151+
var constructorPageLines = resourceProvider
152+
.readLines([packagePath, 'doc', 'lib', 'One', 'One.html']);
153+
constructorPageLines.expectMainContentContainsAllInOrder([
154+
matches(
155+
'<span class="kind-constructor">One&lt;<wbr>'
156+
'<span class="type-parameter">E</span>&gt;</span> constructor',
157+
)
158+
]);
159+
});
160+
161+
test('named constructor page is rendered', () async {
162+
var constructorPageLines = resourceProvider
163+
.readLines([packagePath, 'doc', 'lib', 'One', 'One.named.html']);
164+
constructorPageLines.expectMainContentContainsAllInOrder([
165+
matches(
166+
'<span class="kind-constructor">One&lt;<wbr>'
167+
'<span class="type-parameter">E</span>&gt;.named</span> constructor',
168+
)
169+
]);
170+
});
171+
150172
test('page contains representation type', () async {
151173
oneLines.expectMainContentContainsAllInOrder([
152174
matches('<dt>on</dt>'),
@@ -209,18 +231,13 @@ dartdoc:
209231
]);
210232
});
211233

212-
test(
213-
'page contains (static) constants',
214-
// TODO(srawlins): Implement.
215-
skip: true,
216-
() async {
217-
oneLines.expectMainContentContainsAllInOrder([
218-
matches('<h2>Constants</h2>'),
219-
matches('<a href="../lib/One/c1-constant.html">c1</a>'),
220-
matches('A constant.'),
221-
]);
222-
},
223-
);
234+
test('page contains (static) constants', () async {
235+
oneLines.expectMainContentContainsAllInOrder([
236+
matches('<h2>Constants</h2>'),
237+
matches('<a href="../lib/One/c1-constant.html">c1</a>'),
238+
matches('A constant.'),
239+
]);
240+
});
224241

225242
test('page contains representation field', () async {
226243
oneLines.expectMainContentContainsAllInOrder([

0 commit comments

Comments
 (0)