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

Autoprogram with custom Formatter #12

Open
iv3wjr opened this issue Apr 3, 2020 · 2 comments
Open

Autoprogram with custom Formatter #12

iv3wjr opened this issue Apr 3, 2020 · 2 comments

Comments

@iv3wjr
Copy link

iv3wjr commented Apr 3, 2020

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

@langston-barrett
Copy link
Collaborator

@iv3wjr Can you please post a working example of the problem?

@iv3wjr
Copy link
Author

iv3wjr commented Feb 10, 2021

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:

Screenshot_20210210_105719

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

No branches or pull requests

2 participants