I thought, for the sake of consistency across my code-base project, it would be an interesting idea to annotate the help messages for the parameters in the docstring for the function instead of in each decorator. Example:
@click.command()
@click.option('--name', default=None)
@click.option('--age', type=int, default=None)
def my_cli(name, age):
"""
Does cli-ish things
:param name: The name of the user.
:param age: The age of the user.
"""
print(f"Hello {name if name is not None else "stranger"}, you were born {age if age is not None else "many"} years ago")
This presents some (small) issues. Docstring special keywords are not stripped from the help menu, for example.
I'd like to gauge people's interest in this before dedicating more time beyond the first prototype.
I would love this feature. Just thought how brittle it is to copy and paste the same information from my docstrings to the help arguments in the decorators.
Docstring parsing can be provided by an existing docstring-parsing package, docstring_parser, supporting ReST-style and Google-style docstrings (with easy extensibility to other styles: see my PR for NumPy-style)
The docstring_parser looks interesting, but I don't want to start maintaining something similar to that in Click core. This seems like a good idea for an extension.
Most helpful comment
Docstring parsing can be provided by an existing docstring-parsing package,
docstring_parser, supporting ReST-style and Google-style docstrings (with easy extensibility to other styles: see my PR for NumPy-style)