1

I'm developing a package for flutter and i am trying to add documentation for it, problem is i have a couple of factory methods and i want to document the individual parameters that go into them just like we do for constructors

But i am out finding that a limitation is in place where you have to reference method parameters in the method's own doc comments which works for regular functions but i find that single parameter comments are helpful when working with widgets that other people wrote (such as the built-in flutter widgets) and i think that not having documentation for the parameters of my factory methods is detrimental to the ease of use of my package

  • How is documenting parameters any different for `factory` constructors than from ordinary constructors? How is it different from documenting parameters to any function or method? – jamesdlin Jul 16 '22 at 20:43
  • @jamesdlin the parameters of an ordinary constructor get their documentation from the doc-comments that belong to the respective member attribute `MyClass({this.attribute, ...})` the documentation for `attribute` is derived from it's definition, factory methods like any regular methods can't have `this.attribute` as a parameter thus it seems to me that there's no way to of adding documentation to any sort of method parameters (including factory methods, and my point is that they are very useful for factory methods just as much as for constructors) – Mekni_Wassime Jul 17 '22 at 06:53
  • Can you show me an example where such documentation is automatically generated for an ordinary constructor? I have never seen that. I don't see it in dartdoc-generated documentation for my classes with constructors that use the `this.member` shorthand. – jamesdlin Jul 17 '22 at 09:24
  • 1
    @jamesdlin if you go to any flutter widget for example a container `Container(child: ...)` if you hover over `child` in vscode you can read the doc-comments that belong to `final Widget? child` that's defined in the code for the `Container` widget, if you check the constructor you will find that they used `this.child` just like the example i gave you – Mekni_Wassime Jul 20 '22 at 08:52

1 Answers1

0

This is not supported by Dart. There is an open feature request for it though. If this is something you want to see supported, you can express interest for it on that feature request.

https://github.com/dart-lang/dartdoc/issues/1259

Jordan Nelson
  • 1,162
  • 2
  • 8
  • 9