autoprogram
autoprogram copied to clipboard
Autoprogram with custom Formatter
I'm using autoprogram to document a Python script that uses argparse with a custom Formatter class that inherits from argparse.ArgumentDefaultsHelpFormatter and argparse.RawDescriptionHelpFormatter. The RST string returned by the render_rst() function defined in autoprogram.py is not aware of the formatter and therefore the default value (default = xxx) is not added to the help string. I noticed that the parser instance inside the make_rst() method of the AutoprogramDirective class defined in autoprogram.py has a _get_formatter() method that returns the formatter and that the formatter object has a _format_action() method that correctly formats the action. I do not know if this can help in adding this feature to autoprogram.py but your opinion would be very appreciated. Roberto
@iv3wjr Can you please post a working example of the problem?
sphinx.zip I hope the zip contains all the files needed to reproduce the issue. $ python3 myparser.py -h gives:
usage: the_command [-h] [-o OPTION]
This is the description
optional arguments: -h, --help show this help message and exit -o OPTION, --option OPTION This is the 1st line of the help text for the option Follows the second line And the third. (default: default_value)
But the html generated page looses formatting and the default value:
