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

Make RichHelpFormatter itself renderable with rich #90

Merged
merged 1 commit into from
Sep 24, 2023
Merged

Conversation

hamdanal
Copy link
Owner

This is a new approach that allows the formatter itself to be rendered with rich. The handling of whitespace manipulation and wrapping is now baked into the renderable itself. This also removes the need to use soft_wrap=True when printing the formatted help. The downside is that the code is now very low-level in terms of rich rendering, it needs to do line-by-line handling of Segment objects.

This could help unblock more niche use-cases like #81 and #54.

This is a new approach that allows the formatter itself to be rendered
with rich. The handling of whitespace manipulation and wrapping is now
baked into the renderable itself. This also removes the need to use
`soft_wrap=True` when printing the formatted help. The downside is that
the code is now very low-level in terms of rich rendering, it needs to
do line-by-line handling of `Segment` objects.

This could help unblock more niche use-cases like #81 and #54.
@hamdanal hamdanal merged commit 5347a6b into main Sep 24, 2023
8 checks passed
@hamdanal hamdanal deleted the renderables branch September 24, 2023 08:52
hamdanal added a commit that referenced this pull request Oct 14, 2023
PR #90 changed the internals of `RichHelpFormatter` to use low level
rendering. This lifted some of the restrictions on what can be rendered
without sacrificing parity with the argparse formatters.

This PR officially adds support for arbitrary renderables as descriptions
(both parser and groups description) and epilog.

Co-authored-by: Mosquito <me@mosquito.su>
hamdanal added a commit that referenced this pull request Oct 14, 2023
PR #90 changed the internals of `RichHelpFormatter` to use low level
rendering. This lifted some of the restrictions on what can be rendered
without sacrificing parity with the argparse formatters.

This PR officially adds support for arbitrary renderables as
descriptions (both parser and groups description) and epilog.

Co-authored-by: Mosquito <me@mosquito.su>
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

Successfully merging this pull request may close these issues.

1 participant