argh
argh copied to clipboard
Unindent multi-line docstrings for command help
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.