mirror of https://github.com/Textualize/rich.git
add ipython extension for rich
This commit is contained in:
parent
ce4f18cc47
commit
81215323f0
|
@ -69,8 +69,8 @@ If you would rather not shadow Python's builtin print, you can import ``rich.pri
|
|||
|
||||
Continue reading to learn about the more advanced features of Rich.
|
||||
|
||||
Python in the REPL
|
||||
------------------
|
||||
Rich in the REPL
|
||||
----------------
|
||||
|
||||
Rich may be installed in the REPL so that Python data structures are automatically pretty printed with syntax highlighting. Here's how::
|
||||
|
||||
|
@ -85,6 +85,15 @@ You can also use this feature to try out Rich *renderables*. Here's an example::
|
|||
|
||||
Read on to learn more about Rich renderables.
|
||||
|
||||
IPython Extension
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Rich also includes an IPython extension that will do this same pretty install + pretty tracebacks. Here's how to load it::
|
||||
|
||||
In [1]: %load_ext rich
|
||||
|
||||
You can also have it load by default by adding `"rich"` to the ``c.InteractiveShellApp.extension`` variable in
|
||||
`IPython Configuration <https://ipython.readthedocs.io/en/stable/config/intro.html>`_.
|
||||
|
||||
Rich Inspect
|
||||
------------
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
"""Rich text and beautiful formatting in the terminal."""
|
||||
|
||||
import os
|
||||
from typing import Any, IO, Optional, TYPE_CHECKING
|
||||
from typing import IO, TYPE_CHECKING, Any, Optional
|
||||
|
||||
from ._extension import load_ipython_extension
|
||||
|
||||
__all__ = ["get_console", "reconfigure", "print", "inspect"]
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from typing import Any
|
||||
|
||||
|
||||
def load_ipython_extension(ip: Any) -> None:
|
||||
from rich.pretty import install
|
||||
from rich.traceback import install as tr_install
|
||||
|
||||
install()
|
||||
tr_install()
|
Loading…
Reference in New Issue