This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author daves
Recipients GraylinKim, bethard, daves, denilsonsa, eric.araujo, jwilk, paul.j3, perette, rurpy2, ssokolow, zbysz
Date 2019-10-23.00:04:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571789045.31.0.874462557086.issue12806@roundup.psfhosted.org>
In-reply-to
Content
I came across this thread after making a simple argparse formatter for preserving paragraphs. The submissions here look better than that effort. Here is a quick, hacky look at the patches from one perspective.

I wanted to prefer ParagraphFormatterML, but didn't like that it doesn't appear to wrap bullet lines, and it wrapped help and epilogs to different lengths. For all options I found an initial textwrap.dedent() was needed to get the results I expected. When I did the dedent with ParagraphFormatter*, a subsequent textwrap.indent(" ") hack was needed to restore spaces at the wrap point. FlexiFormatter was incomplete - epilogs weren't affected.

Ultimately, I settled on reworking FlexiFormatter. My version has the following changes:

- Refactor the formatting code out a la ParagraphFormatter, and add to _fill_text() as well, so formatting is available for both epilogs and option help
- Add a leading textwrap.dedent(), to get it to feel more like HelpFormatter.

Note
- The result requires line feed escapes within paragraphs.
- I'm not using the "indent" argument for _fill_text(), with no apparent consequences.
- Automated tests show that FlexiFormatter adds a space to each blank line. I decided that was not a problem

Code is at:
https://github.com/davesteele/argparse_formatter
https://pypi.org/project/argparse-formatter/

Regarding licensing, my contributions (and presumably the others') is addressed by the CLA.

I'd very much like to see something from this thread merged. This looks to me to be good enough. Any objections to a pull request?
History
Date User Action Args
2019-10-23 00:04:05davessetrecipients: + daves, bethard, ssokolow, jwilk, eric.araujo, zbysz, denilsonsa, rurpy2, GraylinKim, paul.j3, perette
2019-10-23 00:04:05davessetmessageid: <1571789045.31.0.874462557086.issue12806@roundup.psfhosted.org>
2019-10-23 00:04:05daveslinkissue12806 messages
2019-10-23 00:04:04davescreate