Merge pull request #1730 from nathanrpage97/feat/docs-add-default-theme-appendix

Docs add default theme appendix
This commit is contained in:
Will McGugan 2022-01-06 12:02:36 +00:00 committed by GitHub
commit f5829f7f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -141,9 +141,10 @@ The Theme class will inherit the default styles built-in to Rich. If your custom
You can disable inheriting the default theme by setting ``inherit=False`` on the :class:`rich.theme.Theme` constructor. You can disable inheriting the default theme by setting ``inherit=False`` on the :class:`rich.theme.Theme` constructor.
To see the default theme, run the following command:: To see the default theme, run the following commands::
python -m rich.theme python -m rich.theme
python -m rich.default_styles
Loading Themes Loading Themes

View File

@ -157,3 +157,27 @@ DEFAULT_STYLES: Dict[str, Style] = {
"markdown.link": Style(color="bright_blue"), "markdown.link": Style(color="bright_blue"),
"markdown.link_url": Style(color="blue"), "markdown.link_url": Style(color="blue"),
} }
if __name__ == "__main__": # pragma: no cover
import argparse
import io
from rich.console import Console
from rich.table import Table
from rich.text import Text
parser = argparse.ArgumentParser()
parser.add_argument("--html", action="store_true", help="Export as HTML table")
args = parser.parse_args()
html: bool = args.html
console = Console(record=True, width=70, file=io.StringIO()) if html else Console()
table = Table("Name", "Styling")
for style_name, style in DEFAULT_STYLES.items():
table.add_row(Text(style_name, style=style), str(style))
console.print(table)
if html:
print(console.export_html(inline_styles=True))