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

✨ Richify, add integrations with Rich everywhere #419

Merged
merged 49 commits into from Jul 12, 2022
Merged

✨ Richify, add integrations with Rich everywhere #419

merged 49 commits into from Jul 12, 2022

Conversation

tiangolo
Copy link
Owner

@tiangolo tiangolo commented Jul 12, 2022

✨ 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, standard print() 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 be None, "rich", "markdown".

Including a new section in the docs for it.

When using "rich" the content in help 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 in typer.Typer(),app.add_typer(), app.command(), typer.Argument(), and typer.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.

@github-actions
Copy link

📝 Docs preview for commit 691a4c9 at: https://62cd725312cb040c6c4ee782--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 357fb60 at: https://62cd754087c40b05a7e97a66--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit b9c45f2 at: https://62cd772e61fef117468c1ea9--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 8f0eaf8 at: https://62cd77d57dfafe181b6e72c1--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 3dcf870 at: https://62cd7aecfe55ee0a8e873b6e--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 67d4d16 at: https://62cd7ec066d54e1fae918824--typertiangolo.netlify.app

@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #419 (f5d2e47) into master (8212e73) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            master      #419    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          260       280    +20     
  Lines         5486      6406   +920     
==========================================
+ Hits          5486      6406   +920     
Impacted Files Coverage Δ
tests/test_completion/test_completion_install.py 100.00% <ø> (ø)
tests/test_completion/test_completion_show.py 100.00% <ø> (ø)
...test_parameter_types/test_bool/test_tutorial001.py 100.00% <ø> (ø)
...st_parameter_types/test_number/test_tutorial002.py 100.00% <ø> (ø)
...test_parameter_types/test_uuid/test_tutorial001.py 100.00% <ø> (ø)
typer/params.py 100.00% <ø> (ø)
typer/utils.py 100.00% <ø> (ø)
docs_src/arguments/default/tutorial001.py 100.00% <100.00%> (ø)
docs_src/arguments/default/tutorial002.py 100.00% <100.00%> (ø)
docs_src/arguments/envvar/tutorial001.py 100.00% <100.00%> (ø)
... and 208 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8212e73...f5d2e47. Read the comment docs.

@github-actions
Copy link

📝 Docs preview for commit 6c43a9d at: https://62cd9d461347e4404302d8a2--typertiangolo.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 8230d2b at: https://62cda00b74b59a40254e415f--typertiangolo.netlify.app

@tiangolo tiangolo marked this pull request as ready for review July 12, 2022 16:29
@tiangolo tiangolo enabled auto-merge (squash) July 12, 2022 16:29
@github-actions
Copy link

📝 Docs preview for commit f5d2e47 at: https://62cda21dc1746b422eaac39f--typertiangolo.netlify.app

@tiangolo tiangolo merged commit 6208b5b into master Jul 12, 2022
@tiangolo tiangolo deleted the richify branch July 12, 2022 16:45
@CarlosBergillos
Copy link

@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).
The outputs with <b>, <font color="#F4BF75">, etc.

I'm interested in adding similar html outputs to the docs of a personal project that uses typer.

Thanks!

alexreg added a commit to alexreg/typer-cloup that referenced this pull request Nov 6, 2022
alexreg added a commit to alexreg/typer-cloup that referenced this pull request Nov 11, 2022
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.

None yet

2 participants