David Steele <dste...@gmail.com> added the comment:

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?

----------
nosy: +daves

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue12806>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to