mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 10:08:40 +00:00
more docs
This commit is contained in:
parent
d09aa7b72d
commit
24f3ff4d60
9 changed files with 116 additions and 8 deletions
|
@ -10,6 +10,9 @@ Welcome to Rich's documentation!
|
|||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
introduction.rst
|
||||
markup.rst
|
||||
|
||||
reference.rst
|
||||
|
||||
Indices and tables
|
||||
|
|
34
docs/source/introduction.rst
Normal file
34
docs/source/introduction.rst
Normal file
|
@ -0,0 +1,34 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
Rich is a Python library for rendering *rich* text and formatting to the terminal. Use Rich to create slick command line applications and as a handy debugging aid.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You may install Rich with your favorite PyPi package manager::
|
||||
|
||||
pip install rich
|
||||
|
||||
Add the ``-U`` switch to update to the current version, if rich is already installed.
|
||||
|
||||
|
||||
Quick Start
|
||||
-----------
|
||||
|
||||
The quickest way to get up and running with Rich is to use the alternative ``print`` function, which can be used as a drop-in replacement for Python's built in function. Here's how you would do that::
|
||||
|
||||
from rich import print
|
||||
|
||||
You can then print content to the terminal in the same way as usual. Rich will add the time and file/line number where print was called. It will also format and syntax highlight any Python objects you print.
|
||||
|
||||
If you would rather not shadow Python's builtin print, you can import rich.print as ``rprint`` (for example)::
|
||||
|
||||
from rich import print as rprint
|
||||
|
||||
For more control over formatting, create a :ref:`rich.console.Console` object::
|
||||
|
||||
from rich.console import Console
|
||||
console = Console()
|
||||
console.print("Hello, **World**! :smiley:")
|
35
docs/source/markup.rst
Normal file
35
docs/source/markup.rst
Normal file
|
@ -0,0 +1,35 @@
|
|||
Console Markup
|
||||
==============
|
||||
|
||||
Rich supports a simple markup which you can use to insert color and styles virtually everywhere Rich would accept a string (e.g. :meth:`~rich.console.Console.print` and :meth:`~rich.console.Console.log`).
|
||||
|
||||
|
||||
Formatting
|
||||
----------
|
||||
|
||||
for bold, italic, and strikethrough, Rich uses the same convention as Markdown::
|
||||
|
||||
For italics, wrap text in asterisks or underscores. e.g. ``*this is italics*`` or ``_this is also italics_``.
|
||||
|
||||
For bold, wrap the text in *two* asterisks or underscores. e.g. ``**this is bold**``or ``__this is also bold__``.
|
||||
|
||||
For strikethrough, wrap the text in tildes. e.g. ``~this has a line through it~``.
|
||||
|
||||
For code, wrap the text in backticks. e.g. ```import this```
|
||||
|
||||
|
||||
Styles
|
||||
------
|
||||
|
||||
For other styles and color, you can use a syntax similar to bbcode. If you write the style in square brackets, i.e. ``[bold red]``, that style will apply when it is *closed* with a corrensponding ``[/bold red]``.
|
||||
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a simple example::
|
||||
|
||||
from rich import print
|
||||
print("Hello, **World**!")
|
||||
print("[bold red]alert![/bold red] *Something happened*")
|
|
@ -5,4 +5,6 @@ Reference
|
|||
:maxdepth: 3
|
||||
|
||||
reference/console.rst
|
||||
|
||||
reference/emoji.rst
|
||||
reference/highlighter.rst
|
||||
reference/text.rst
|
||||
|
|
6
docs/source/reference/emoji.rst
Normal file
6
docs/source/reference/emoji.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
rich.box
|
||||
========
|
||||
|
||||
.. automodule:: rich.emoji
|
||||
:members: Emoji
|
||||
|
7
docs/source/reference/highlighter.rst
Normal file
7
docs/source/reference/highlighter.rst
Normal file
|
@ -0,0 +1,7 @@
|
|||
rich.highlighter
|
||||
================
|
||||
|
||||
.. automodule:: rich.highlighter
|
||||
:members:
|
||||
:special-members: __call__
|
||||
|
6
docs/source/reference/text.rst
Normal file
6
docs/source/reference/text.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
rich.text
|
||||
=========
|
||||
|
||||
.. automodule:: rich.text
|
||||
:members: Text
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue