From 7015e5260b63b71e98da31f7cbdff214a205a4c3 Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Mon, 29 Nov 2021 17:17:41 -0800 Subject: [PATCH 1/4] add rendering of the default styles --- rich/default_styles.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rich/default_styles.py b/rich/default_styles.py index 355f9df8..63290bca 100644 --- a/rich/default_styles.py +++ b/rich/default_styles.py @@ -157,3 +157,27 @@ DEFAULT_STYLES: Dict[str, Style] = { "markdown.link": Style(color="bright_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)) From b47150933e03794ef32bf1c17d959758ea470a9c Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Mon, 29 Nov 2021 17:17:58 -0800 Subject: [PATCH 2/4] include default styles appendix table --- docs/source/appendix.rst | 1 + docs/source/appendix/default_styles.rst | 162 ++++++++++++++++++++++++ docs/source/style.rst | 2 +- 3 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 docs/source/appendix/default_styles.rst diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index 3ae7fa68..166ce7d6 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -6,4 +6,5 @@ Appendix appendix/box.rst appendix/colors.rst + appendix/default_styles.rst \ No newline at end of file diff --git a/docs/source/appendix/default_styles.rst b/docs/source/appendix/default_styles.rst new file mode 100644 index 00000000..3057cb9e --- /dev/null +++ b/docs/source/appendix/default_styles.rst @@ -0,0 +1,162 @@ +.. _appendix-styles: + +Default Styles +============== + +A list of all the available styles provided in the default Theme. + +You can also produce this table by running the following command:: + + python -m rich.default_styles + +.. raw:: html + +
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+    ┃ Name                           Styling                            ┃
+    ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
+    │ none                          │ none                               │
+    │ reset                         │ not bold not dim not italic not    │
+    │                               │ underline not blink not blink2 not │
+    │                               │ reverse not conceal not strike     │
+    │                               │ default on default                 │
+    │ dim                           │ dim                                │
+    │ bright                        │ not dim                            │
+    │ bold                          │ bold                               │
+    │ strong                        │ bold                               │
+    │ code                          │ bold reverse                       │
+    │ italic                        │ italic                             │
+    │ emphasize                     │ italic                             │
+    │ underline                     │ underline                          │
+    │ blink                         │ blink                              │
+    │ blink2                        │ blink2                             │
+    │ reverse                       │ reverse                            │
+    │ strike                        │ strike                             │
+    │ black                         │ black                              │
+    │ red                           │ red                                │
+    │ green                         │ green                              │
+    │ yellow                        │ yellow                             │
+    │ magenta                       │ magenta                            │
+    │ cyan                          │ cyan                               │
+    │ white                         │ white                              │
+    │ inspect.attr                  │ italic yellow                      │
+    │ inspect.attr.dunder           │ dim italic yellow                  │
+    │ inspect.callable              │ bold red                           │
+    │ inspect.def                   │ italic bright_cyan                 │
+    │ inspect.error                 │ bold red                           │
+    │ inspect.equals                │ none                               │
+    │ inspect.help                  │ cyan                               │
+    │ inspect.doc                   │ dim                                │
+    │ inspect.value.border          │ green                              │
+    │ live.ellipsis                 │ bold red                           │
+    │ layout.tree.row               │ not dim red                        │
+    │ layout.tree.column            │ not dim blue                       │
+    │ logging.keyword               │ bold yellow                        │
+    │ logging.level.notset          │ dim                                │
+    │ logging.level.debug           │ green                              │
+    │ logging.level.info            │ blue                               │
+    │ logging.level.warning         │ red                                │
+    │ logging.level.error           │ bold red                           │
+    │ logging.level.critical        │ bold reverse red                   │
+    │ log.level                     │ none                               │
+    │ log.time                      │ dim cyan                           │
+    │ log.message                   │ none                               │
+    │ log.path                      │ dim                                │
+    │ repr.ellipsis                 │ yellow                             │
+    │ repr.indent                   │ dim green                          │
+    │ repr.error                    │ bold red                           │
+    │ repr.str                      │ not bold not italic green          │
+    │ repr.brace                    │ bold                               │
+    │ repr.comma                    │ bold                               │
+    │ repr.ipv4                     │ bold bright_green                  │
+    │ repr.ipv6                     │ bold bright_green                  │
+    │ repr.eui48                    │ bold bright_green                  │
+    │ repr.eui64                    │ bold bright_green                  │
+    │ repr.tag_start                │ bold                               │
+    │ repr.tag_name                 │ bold bright_magenta                │
+    │ repr.tag_contents             │ default                            │
+    │ repr.tag_end                  │ bold                               │
+    │ repr.attrib_name              │ not italic yellow                  │
+    │ repr.attrib_equal             │ bold                               │
+    │ repr.attrib_value             │ not italic magenta                 │
+    │ repr.number                   │ bold not italic cyan               │
+    │ repr.bool_true                │ italic bright_green                │
+    │ repr.bool_false               │ italic bright_red                  │
+    │ repr.none                     │ italic magenta                     │
+    │ repr.url                      │ not bold not italic underline      │
+    │                               │ bright_blue                        │
+    │ repr.uuid                     │ not bold bright_yellow             │
+    │ repr.call                     │ bold magenta                       │
+    │ repr.path                     │ magenta                            │
+    │ repr.filename                 │ bright_magenta                     │
+    │ rule.line                     │ bright_green                       │
+    │ rule.text                     │ none                               │
+    │ json.brace                    │ bold                               │
+    │ json.bool_true                │ italic bright_green                │
+    │ json.bool_false               │ italic bright_red                  │
+    │ json.null                     │ italic magenta                     │
+    │ json.number                   │ bold not italic cyan               │
+    │ json.str                      │ not bold not italic green          │
+    │ json.key                      │ bold blue                          │
+    │ prompt                        │ none                               │
+    │ prompt.choices                │ bold magenta                       │
+    │ prompt.default                │ bold cyan                          │
+    │ prompt.invalid                │ red                                │
+    │ prompt.invalid.choice         │ red                                │
+    │ pretty                        │ none                               │
+    │ scope.border                  │ blue                               │
+    │ scope.key                     │ italic yellow                      │
+    │ scope.key.special             │ dim italic yellow                  │
+    │ scope.equals                  │ red                                │
+    │ table.header                  │ bold                               │
+    │ table.footer                  │ bold                               │
+    │ table.cell                    │ none                               │
+    │ table.title                   │ italic                             │
+    │ table.caption                 │ dim italic                         │
+    │ traceback.error               │ italic red                         │
+    │ traceback.border.syntax_error │ bright_red                         │
+    │ traceback.border              │ red                                │
+    │ traceback.text                │ none                               │
+    │ traceback.title               │ bold red                           │
+    │ traceback.exc_type            │ bold bright_red                    │
+    │ traceback.exc_value           │ none                               │
+    │ traceback.offset              │ bold bright_red                    │
+    │ bar.back                      │ grey23                             │
+    │ bar.complete                  │ rgb(249,38,114)                    │
+    │ bar.finished                  │ rgb(114,156,31)                    │
+    │ bar.pulse                     │ rgb(249,38,114)                    │
+    │ progress.description          │ none                               │
+    │ progress.filesize             │ green                              │
+    │ progress.filesize.total       │ green                              │
+    │ progress.download             │ green                              │
+    │ progress.elapsed              │ yellow                             │
+    │ progress.percentage           │ magenta                            │
+    │ progress.remaining            │ cyan                               │
+    │ progress.data.speed           │ red                                │
+    │ progress.spinner              │ green                              │
+    │ status.spinner                │ green                              │
+    │ tree                          │ none                               │
+    │ tree.line                     │ none                               │
+    │ markdown.paragraph            │ none                               │
+    │ markdown.text                 │ none                               │
+    │ markdown.emph                 │ italic                             │
+    │ markdown.strong               │ bold                               │
+    │ markdown.code                 │ bright_white on black              │
+    │ markdown.code_block           │ dim cyan on black                  │
+    │ markdown.block_quote          │ magenta                            │
+    │ markdown.list                 │ cyan                               │
+    │ markdown.item                 │ none                               │
+    │ markdown.item.bullet          │ bold yellow                        │
+    │ markdown.item.number          │ bold yellow                        │
+    │ markdown.hr                   │ yellow                             │
+    │ markdown.h1.border            │ none                               │
+    │ markdown.h1                   │ bold                               │
+    │ markdown.h2                   │ bold underline                     │
+    │ markdown.h3                   │ bold                               │
+    │ markdown.h4                   │ bold dim                           │
+    │ markdown.h5                   │ underline                          │
+    │ markdown.h6                   │ italic                             │
+    │ markdown.h7                   │ dim italic                         │
+    │ markdown.link                 │ bright_blue                        │
+    │ markdown.link_url             │ blue                               │
+    └───────────────────────────────┴────────────────────────────────────┘
+    
diff --git a/docs/source/style.rst b/docs/source/style.rst index ee9eca5d..e248be5d 100644 --- a/docs/source/style.rst +++ b/docs/source/style.rst @@ -141,7 +141,7 @@ The Theme class will inherit the default styles builtin to Rich. If your custom 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 refer to :ref:`appendix-styles` or run the following command:: python -m rich.theme From ef943a95a21cd80f737f18d6bf731fe07033be9c Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Mon, 3 Jan 2022 11:25:57 -0500 Subject: [PATCH 3/4] remove default_styles table from appendix --- docs/source/appendix.rst | 2 - docs/source/appendix/default_styles.rst | 162 ------------------------ docs/source/style.rst | 3 +- 3 files changed, 2 insertions(+), 165 deletions(-) delete mode 100644 docs/source/appendix/default_styles.rst diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index 166ce7d6..a381eb84 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -6,5 +6,3 @@ Appendix appendix/box.rst appendix/colors.rst - appendix/default_styles.rst - \ No newline at end of file diff --git a/docs/source/appendix/default_styles.rst b/docs/source/appendix/default_styles.rst deleted file mode 100644 index 3057cb9e..00000000 --- a/docs/source/appendix/default_styles.rst +++ /dev/null @@ -1,162 +0,0 @@ -.. _appendix-styles: - -Default Styles -============== - -A list of all the available styles provided in the default Theme. - -You can also produce this table by running the following command:: - - python -m rich.default_styles - -.. raw:: html - -
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
-    ┃ Name                           Styling                            ┃
-    ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
-    │ none                          │ none                               │
-    │ reset                         │ not bold not dim not italic not    │
-    │                               │ underline not blink not blink2 not │
-    │                               │ reverse not conceal not strike     │
-    │                               │ default on default                 │
-    │ dim                           │ dim                                │
-    │ bright                        │ not dim                            │
-    │ bold                          │ bold                               │
-    │ strong                        │ bold                               │
-    │ code                          │ bold reverse                       │
-    │ italic                        │ italic                             │
-    │ emphasize                     │ italic                             │
-    │ underline                     │ underline                          │
-    │ blink                         │ blink                              │
-    │ blink2                        │ blink2                             │
-    │ reverse                       │ reverse                            │
-    │ strike                        │ strike                             │
-    │ black                         │ black                              │
-    │ red                           │ red                                │
-    │ green                         │ green                              │
-    │ yellow                        │ yellow                             │
-    │ magenta                       │ magenta                            │
-    │ cyan                          │ cyan                               │
-    │ white                         │ white                              │
-    │ inspect.attr                  │ italic yellow                      │
-    │ inspect.attr.dunder           │ dim italic yellow                  │
-    │ inspect.callable              │ bold red                           │
-    │ inspect.def                   │ italic bright_cyan                 │
-    │ inspect.error                 │ bold red                           │
-    │ inspect.equals                │ none                               │
-    │ inspect.help                  │ cyan                               │
-    │ inspect.doc                   │ dim                                │
-    │ inspect.value.border          │ green                              │
-    │ live.ellipsis                 │ bold red                           │
-    │ layout.tree.row               │ not dim red                        │
-    │ layout.tree.column            │ not dim blue                       │
-    │ logging.keyword               │ bold yellow                        │
-    │ logging.level.notset          │ dim                                │
-    │ logging.level.debug           │ green                              │
-    │ logging.level.info            │ blue                               │
-    │ logging.level.warning         │ red                                │
-    │ logging.level.error           │ bold red                           │
-    │ logging.level.critical        │ bold reverse red                   │
-    │ log.level                     │ none                               │
-    │ log.time                      │ dim cyan                           │
-    │ log.message                   │ none                               │
-    │ log.path                      │ dim                                │
-    │ repr.ellipsis                 │ yellow                             │
-    │ repr.indent                   │ dim green                          │
-    │ repr.error                    │ bold red                           │
-    │ repr.str                      │ not bold not italic green          │
-    │ repr.brace                    │ bold                               │
-    │ repr.comma                    │ bold                               │
-    │ repr.ipv4                     │ bold bright_green                  │
-    │ repr.ipv6                     │ bold bright_green                  │
-    │ repr.eui48                    │ bold bright_green                  │
-    │ repr.eui64                    │ bold bright_green                  │
-    │ repr.tag_start                │ bold                               │
-    │ repr.tag_name                 │ bold bright_magenta                │
-    │ repr.tag_contents             │ default                            │
-    │ repr.tag_end                  │ bold                               │
-    │ repr.attrib_name              │ not italic yellow                  │
-    │ repr.attrib_equal             │ bold                               │
-    │ repr.attrib_value             │ not italic magenta                 │
-    │ repr.number                   │ bold not italic cyan               │
-    │ repr.bool_true                │ italic bright_green                │
-    │ repr.bool_false               │ italic bright_red                  │
-    │ repr.none                     │ italic magenta                     │
-    │ repr.url                      │ not bold not italic underline      │
-    │                               │ bright_blue                        │
-    │ repr.uuid                     │ not bold bright_yellow             │
-    │ repr.call                     │ bold magenta                       │
-    │ repr.path                     │ magenta                            │
-    │ repr.filename                 │ bright_magenta                     │
-    │ rule.line                     │ bright_green                       │
-    │ rule.text                     │ none                               │
-    │ json.brace                    │ bold                               │
-    │ json.bool_true                │ italic bright_green                │
-    │ json.bool_false               │ italic bright_red                  │
-    │ json.null                     │ italic magenta                     │
-    │ json.number                   │ bold not italic cyan               │
-    │ json.str                      │ not bold not italic green          │
-    │ json.key                      │ bold blue                          │
-    │ prompt                        │ none                               │
-    │ prompt.choices                │ bold magenta                       │
-    │ prompt.default                │ bold cyan                          │
-    │ prompt.invalid                │ red                                │
-    │ prompt.invalid.choice         │ red                                │
-    │ pretty                        │ none                               │
-    │ scope.border                  │ blue                               │
-    │ scope.key                     │ italic yellow                      │
-    │ scope.key.special             │ dim italic yellow                  │
-    │ scope.equals                  │ red                                │
-    │ table.header                  │ bold                               │
-    │ table.footer                  │ bold                               │
-    │ table.cell                    │ none                               │
-    │ table.title                   │ italic                             │
-    │ table.caption                 │ dim italic                         │
-    │ traceback.error               │ italic red                         │
-    │ traceback.border.syntax_error │ bright_red                         │
-    │ traceback.border              │ red                                │
-    │ traceback.text                │ none                               │
-    │ traceback.title               │ bold red                           │
-    │ traceback.exc_type            │ bold bright_red                    │
-    │ traceback.exc_value           │ none                               │
-    │ traceback.offset              │ bold bright_red                    │
-    │ bar.back                      │ grey23                             │
-    │ bar.complete                  │ rgb(249,38,114)                    │
-    │ bar.finished                  │ rgb(114,156,31)                    │
-    │ bar.pulse                     │ rgb(249,38,114)                    │
-    │ progress.description          │ none                               │
-    │ progress.filesize             │ green                              │
-    │ progress.filesize.total       │ green                              │
-    │ progress.download             │ green                              │
-    │ progress.elapsed              │ yellow                             │
-    │ progress.percentage           │ magenta                            │
-    │ progress.remaining            │ cyan                               │
-    │ progress.data.speed           │ red                                │
-    │ progress.spinner              │ green                              │
-    │ status.spinner                │ green                              │
-    │ tree                          │ none                               │
-    │ tree.line                     │ none                               │
-    │ markdown.paragraph            │ none                               │
-    │ markdown.text                 │ none                               │
-    │ markdown.emph                 │ italic                             │
-    │ markdown.strong               │ bold                               │
-    │ markdown.code                 │ bright_white on black              │
-    │ markdown.code_block           │ dim cyan on black                  │
-    │ markdown.block_quote          │ magenta                            │
-    │ markdown.list                 │ cyan                               │
-    │ markdown.item                 │ none                               │
-    │ markdown.item.bullet          │ bold yellow                        │
-    │ markdown.item.number          │ bold yellow                        │
-    │ markdown.hr                   │ yellow                             │
-    │ markdown.h1.border            │ none                               │
-    │ markdown.h1                   │ bold                               │
-    │ markdown.h2                   │ bold underline                     │
-    │ markdown.h3                   │ bold                               │
-    │ markdown.h4                   │ bold dim                           │
-    │ markdown.h5                   │ underline                          │
-    │ markdown.h6                   │ italic                             │
-    │ markdown.h7                   │ dim italic                         │
-    │ markdown.link                 │ bright_blue                        │
-    │ markdown.link_url             │ blue                               │
-    └───────────────────────────────┴────────────────────────────────────┘
-    
diff --git a/docs/source/style.rst b/docs/source/style.rst index e248be5d..4b96117a 100644 --- a/docs/source/style.rst +++ b/docs/source/style.rst @@ -141,9 +141,10 @@ The Theme class will inherit the default styles builtin to Rich. If your custom You can disable inheriting the default theme by setting ``inherit=False`` on the :class:`rich.theme.Theme` constructor. -To see the default theme refer to :ref:`appendix-styles` or run the following command:: +To see the default theme run the following commands:: python -m rich.theme + python -m rich.default_styles Loading Themes From 854638f54e9ba17d9f2e6a9dc6e0a1af0509d29d Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Mon, 3 Jan 2022 11:30:48 -0500 Subject: [PATCH 4/4] clean up diffs --- docs/source/appendix.rst | 1 + docs/source/style.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index a381eb84..3ae7fa68 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -6,3 +6,4 @@ Appendix appendix/box.rst appendix/colors.rst + \ No newline at end of file diff --git a/docs/source/style.rst b/docs/source/style.rst index 4b96117a..53ff7c51 100644 --- a/docs/source/style.rst +++ b/docs/source/style.rst @@ -141,7 +141,7 @@ The Theme class will inherit the default styles builtin to Rich. If your custom 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 commands:: +To see the default theme, run the following commands:: python -m rich.theme python -m rich.default_styles