lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
399 stars 49 forks source link

"Attributes:" Google-style docstring support for automatic help string #166

Closed Conchylicultor closed 1 year ago

Conchylicultor commented 1 year ago

Currently, simple_parsing force to add comments along the attributes they are defined

It would be nice if it was also supporting the google docstring style Attributes field: https://google.github.io/styleguide/pyguide.html#384-classes

@dataclass
class Args:
  """args.

  Attributes:
    user: Username
    verbose: Display logs
  """
  user: str
  verbose: bool = False

Rational: The simple_parsing conventions are not supported by standard tools like:

Screenshot 2022-09-26 at 14 43 57

Currently simple parsing force to document each fields twice (as # comment and inside the cls.__doc__).

lebrice commented 1 year ago

Great suggestion @Conchylicultor ! I'll take a look at existing parsing tools for this, would be nicer than having to write it myself.

Does this problem also arise if you use docstrings under the fields?

brentyi commented 1 year ago

@lebrice as an FYI I've had a really good experience with docstring_parser! Could possibly also be used in #156?

lebrice commented 1 year ago

Sure @brentyi , I'll check it out.

However, do you get the same problem when using docstrings under the fields?

brentyi commented 1 year ago

Hm, my understanding with the triple-quoted attribute docstrings is:

I generally prefer this style over the monolithic Attributes: list.

lebrice commented 1 year ago

Should be fixed by #179 . Let me know if you have other issues :)