Skip to content

Parameter Documentation via Docstring #92

Open

Description

@srkunze

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.

Activity

  1. changed the title [-]Parameter Documentation viaDocstring[/-] [+]Parameter Documentation via Docstring[/+] on Oct 8, 2015
  2. ewerybody commented on May 11, 2016

    @ewerybody

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

    • Sphinx (:tag name:)
    • EpyDoc (@tag name:)

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

  3. joshlk commented on Aug 10, 2016

    @joshlk

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

  4. joshlk commented on Aug 11, 2016

    @joshlk

    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.

  5. neithere commented on Aug 26, 2016

    @neithere
    Owner

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

  6. evanunderscore commented on Sep 29, 2016

    @evanunderscore

    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.

  7. neithere commented on Feb 7, 2023

    @neithere
    Owner

    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.

  8. petergaultney commented on Jan 14, 2025

    @petergaultney

    would you be open to contributions from our team on this issue? We have some experience with argparse and using existing docstring-parsing libraries. I agree that a plugin system seems best; sometimes the best way to design a plugin system is to build the first use case for it and create an experimental plugin API as you go.

  9. martinandrovich commented on Apr 10, 2025

    @martinandrovich

    Any update on adding this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions