neithere / argh

An argparse wrapper that doesn't make you say "argh" each time you deal with it.
http://argh.rtfd.org
GNU Lesser General Public License v3.0
369 stars 55 forks source link

Parameter Documentation via Docstring #92

Open srkunze opened 8 years ago

srkunze commented 8 years ago

Would you find it reasonable to include something like https://www.chromium.org/chromium-os/python-style-guidelines#TOC-Describing-arguments-in-docstrings into argh?

def cmd(param):
    """
    Executes the cmd.

    param: very important parameter
    """

Internally, we still need to use Python 2, so I would love to have this kind of help-text generation in order to reduce usage of the @arg decorator. Btw. it's a great package.

ewerybody commented 8 years ago

I just thought about that!! :D Shit is there are different formats within the docstring. for instance

But yeah! Doesn't seem impossible to do :]

joshlk commented 8 years ago

This would be a really nice feature. Otherwise your just repeating yourself in the docstring

joshlk commented 8 years ago

I've made a pull request #109 which adds a decorator which parses the Sphinx docstring to add type and description information.

It hasn't got tests yet but wanted it out there to see if there is an appetite to merge in.

Any comments? It would be great if someone added to it so it could also parse Google and Numpy style docstrings.

neithere commented 8 years ago

Thanks guys, I've commented in PR #109 for now.

evanunderscore commented 7 years ago

Hi guys,

I tackled a similar problem with defopt. I thought I had done my homework before writing yet another argument parser, but apparently I missed argh at the time. In retrospect I think it would have been better as an addition to argh instead of a standalone library.

If you would like to take inspiration from it or want me to help out in some way, I'd be happy to. Ideally it would be great if argh ended up with a superset of defopt's functionality and then I wouldn't need to maintain a separate project.

Note that defopt handles Google/Numpy formats using sphinxcontrib-napoleon, and also a limited set of typing annotations as described in #107.

neithere commented 1 year ago

It seems that this should be configurable, perhaps an extension. I'll try to gather all plugin-ish issues under the appropriate label and see if it makes sense to add such mechanism to Argh.