dart show documentation from another method in another file

669 Views Asked by At

Is it possible to show the documentation of a function in the documentation of another function residing in a different file? Macros are only valid in their own file.

In the Flutter source code, they use something like this, but it does not seem to have any effect:

/// {@macro flutter.widgets.editableText.keyboardType}
2

There are 2 best solutions below

0
Alex Rintt On BEST ANSWER

Macro docs is what you are looking for. They are already explained here but in summary allows you do exactly what you want: copy a documentation from a place to somewhere else without re-write.

0
hacker1024 On

The best you can do is link to the referenced function.

file_a.dart

/// Also see [functionB].
void functionA() {}

file_b.dart

/// Another function.
void functionB() {}

https://dart.dev/guides/language/language-tour#documentation-comments