You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked for something like this in the issues but couldn't find anything.
Problem
Currently, if you have an interface A with a member a documented with doc(a), an interface B implementing A will inherit the documentation doc(a) for its a implementation unless it explicitly document the method.
For instance:
// foo.dartclassFoo {
/// Bars the foo.voidbar() {}
/// Quxes the foo.voidqux() {}
}
In this case, Baz.bar will have the same documentation as Foo.bar, but Baz.qux will have the documentation it specified instead of Foo.qux's one.
However, sometimes we want to add to the superclass documentation instead of overwriting it. If you own the library that defines the interface you are implementing, you can use a template:
// my_library.dartimport'library_that_i_own.dart';
classBazextendsFoo {
/// {@macro foo.bar} /// /// After barring, also bazes the Foo.@overridevoidbar() {}
}
This is not possible, however, if you are implementing an interface that you don't own.
Suggestion
Implement a built-in macro that refers to the documentation of the supertype. For instance, {@macro super} or make it a different "command", like {@super} (so it's not breaking if someone ever defined a template called super).
The aforementioned would then be implemented like this:
// library_that_i_dont_own.dartclassFoo {
/// Bars the foo.voidbar() {}
}
// my_library.dartimport'library_that_i_dont_own.dart';
classBazextendsFoo {
/// {@super} /// /// After barring, also bazes the Foo.@overridevoidbar() {}
}
The text was updated successfully, but these errors were encountered:
If we implement this feature (or accept a PR for it), it will take place in the analyzer, so that it is supported in IDEs as well.
Let me bring this up in an analyzer team meeting, and I'll post back here on whether we like it (personally I like it; I'm surprised it hasn't come up before, that I've seen).
I looked for something like this in the issues but couldn't find anything.
Problem
Currently, if you have an interface
A
with a membera
documented withdoc(a)
, an interfaceB
implementingA
will inherit the documentationdoc(a)
for itsa
implementation unless it explicitly document the method.For instance:
In this case,
Baz.bar
will have the same documentation asFoo.bar
, butBaz.qux
will have the documentation it specified instead ofFoo.qux
's one.However, sometimes we want to add to the superclass documentation instead of overwriting it. If you own the library that defines the interface you are implementing, you can use a template:
This is not possible, however, if you are implementing an interface that you don't own.
Suggestion
Implement a built-in macro that refers to the documentation of the supertype. For instance,
{@macro super}
or make it a different "command", like{@super}
(so it's not breaking if someone ever defined a template calledsuper
).The aforementioned would then be implemented like this:
The text was updated successfully, but these errors were encountered: