jupyter-book
jupyter-book copied to clipboard
Use Rich for the CLI console output
Description
Rich is a Python CLI output tool for rendering more feature-full console output. I think it would let us do things like our output message box but would probably be a lot more well-behaved and extensible. Here is a brief writeup. It also seems to be pretty lightweight.
A few potential benefits:
Error messages
An example could be in our error messages. Right now we're hand-coding some red ansii and generating a little box like this:

With rich we coulda accomplish something similar with one line:
print(Panel("[white]There was an error in building your book. Look above for the cause.", title="error", style="red", expand=False, padding=2))
results in

Message boxes
More generally, any time we display message boxes to people we'd have a lot more control over the formatting and style.
Tracebacks
Rich's Tracebacks are generally more nicely-formatted and easy to read.
Rich allows you to suppress traceback levels at the module level, so we could do something like suppress=[click] and then all of the 5-6 click traceback levels would take up much less space.
Rich printing
We could re-use Rich for printing rich text to the console (though we already do this with click.echo so it may not be a huge improvement)
Example closed PR
We had a PR a while back to demonstrate adding Rich to the package, but didn't have time to finish it. It's here in case others want to re-use or pick it up:
- https://github.com/executablebooks/jupyter-book/pull/1665