Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to document dart functions/constructors parameters?

Tags:

dart

With dart it is possible to prefix class/function definition by a commentary so that the analyzer will interpret it as documentation:

/// Some documentation for [Foo]
class Foo {

}

But how can I achieve the same behavior, with parameters instead?

I tried the following:

void myFunction(
 /// Some parameter documentation
 String parameter,
) {

}

But this doesn't work.


However, it seems possible because dartanalyzer do contain a property on ParameterElement for documentation.

like image 424
Rémi Rousselet Avatar asked Dec 04 '18 00:12

Rémi Rousselet


1 Answers

https://www.dartlang.org/guides/language/effective-dart/documentation

Here's the offical Dart language guidelines for documentation best practice. It covers most/all cases and has great examples of do's and don't's.

This bit shows the way to include parameters. Basically, wrap the parameters in square brackets and within a sentence explaining it.

like image 117
Aidan Davis Avatar answered Oct 25 '22 17:10

Aidan Davis