def func(foo=1, bar=True):
    """Sample function.
        Parameters:
            foo: float
                An example argument.
            bar: bool
                Another argument.
    """
print(foo, bar)
parser = argparse.ArgumentParser(prog='script.py', description=func.__doc__,
    formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-f', '--foo', type=float)
parser.add_argument('-b', '--bar', action='store_false')
parser.print_help()
Python’s argh library: preserve docstring formatting in help message