-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
✨ Richify, add integrations with Rich everywhere #419
Conversation
…) would benefit more from Rich
📝 Docs preview for commit 691a4c9 at: https://62cd725312cb040c6c4ee782--typertiangolo.netlify.app |
📝 Docs preview for commit 357fb60 at: https://62cd754087c40b05a7e97a66--typertiangolo.netlify.app |
📝 Docs preview for commit b9c45f2 at: https://62cd772e61fef117468c1ea9--typertiangolo.netlify.app |
📝 Docs preview for commit 8f0eaf8 at: https://62cd77d57dfafe181b6e72c1--typertiangolo.netlify.app |
📝 Docs preview for commit 3dcf870 at: https://62cd7aecfe55ee0a8e873b6e--typertiangolo.netlify.app |
📝 Docs preview for commit 67d4d16 at: https://62cd7ec066d54e1fae918824--typertiangolo.netlify.app |
Codecov Report
@@ Coverage Diff @@
## master #419 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 260 280 +20
Lines 5486 6406 +920
==========================================
+ Hits 5486 6406 +920
Continue to review full report at Codecov.
|
…precedence over GITHUB_ACTIONS env var
📝 Docs preview for commit 6c43a9d at: https://62cd9d461347e4404302d8a2--typertiangolo.netlify.app |
📝 Docs preview for commit 8230d2b at: https://62cda00b74b59a40254e415f--typertiangolo.netlify.app |
📝 Docs preview for commit f5d2e47 at: https://62cda21dc1746b422eaac39f--typertiangolo.netlify.app |
@tiangolo Hi! Sorry if this is not the right place to ask this, but how did you generate the html for the Rich terminal outputs for the docs? (as added in this PR, and this commit 501f3a9). I'm interested in adding similar html outputs to the docs of a personal project that uses typer. Thanks! |
✨ Richify, add integrations with Rich everywhere.
This started with a copy of https://github.com/ewels/rich-click, and started evolving from there with several refactors.
Rich is still an optional dependency, but when installed, it's used in several places.
This PR includes several things related to the new deep integration with Rich.
Use standard
print
Now
typer.echo()
is no longer recommended, for the simplest cases, standardprint()
is recommended and documented.And for more complex cases, Rich is recommended. Several places in the docs have been updated to recommend Rich, e.g. the whole section for "Printing and Colors".
Rich for
--help
When Rich is installed, it's used to format all the output of
--help
commands.New docs for
deprecated
New docs for the
deprecated
parameter in commands, it includes special formatting and handling with Rich.Rich Markup and Markdown
Rich Markup and Markdown can be enabled with a new parameter
rich_markup_mode
that can beNone
,"rich"
,"markdown"
.Including a new section in the docs for it.
When using
"rich"
the content inhelp
strings,epilog
and docstrings is parsed with Rich Markup, when"markdown"
is used, then it's parsed with Rich Markdown.Help Panels
There's a new parameter
rich_help_panel
intyper.Typer()
,app.add_typer()
,app.command()
,typer.Argument()
, andtyper.Option()
.Setting it to a name will render that component in a Rich panel in the help from the
--help
option.New docs for that in the sections about help for CLI arguments, CLI options, and commands.
Epilog docs
New docs for using the
epilog
, also rendered with Rich.Tests
Updated tests and many new tests to keep 100% of test coverage with the new Rich utils and integrations.