Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unindent multi-line docstrings for command help #81

Open
nithinphilips opened this issue Nov 16, 2014 · 0 comments
Open

Unindent multi-line docstrings for command help #81

nithinphilips opened this issue Nov 16, 2014 · 0 comments

Comments

@nithinphilips
Copy link

When generating help for subcommands the docstring is used verbatim. The indentation used in the code often does not make sense in the context of command help.

Example

Given a command method:

# adding help to `foo` which is in the function signature:
@arg('foo', help='blah')
# these are not in the signature so they go to **kwargs:
@arg('baz')
@arg('-q', '--quux')
# the function itself:
def ting(foo, bar=1, *args, **kwargs):
    """
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud.
    """
    pass

Generated help:

usage: ting [-h] [-b BAR] [-q QUUX]
            foo [args [args ...]] baz

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud.


positional arguments:
  foo                   blah
[...]

Expected:

usage: ting [-h] [-b BAR] [-q QUUX]
            foo [args [args ...]] baz

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud.


positional arguments:
  foo                   blah
[...]

A possible solution may be to use the first line's indentation as a guide and remove that many characters.

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

No branches or pull requests

2 participants