Ced
Ced

Reputation: 17327

dart show documentation from another method in another file

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}

Upvotes: 5

Views: 874

Answers (2)

Alex
Alex

Reputation: 2364

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.

Upvotes: 2

hacker1024
hacker1024

Reputation: 3648

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

Upvotes: 0

Related Questions