Skip to content

Commit

Permalink
Merge pull request #1387 from willmcgugan/10.7.0
Browse files Browse the repository at this point in the history
10.7.0
  • Loading branch information
willmcgugan committed Aug 5, 2021
2 parents 8d52f96 + 29e653c commit 52d159a
Show file tree
Hide file tree
Showing 29 changed files with 430 additions and 233 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [10.7.0] - 2021-08-05

### Added

- Added Text.apply_meta
- Added meta argument to Text.assemble
- Added Style.from_meta
- Added Style.on
- Added Text.on

### Changed

- Changed `RenderGroup` to `Group` and `render_group` to `group` (old names remain for compatibility but will be deprecated in the future)
- Changed `rich.repr.RichReprResult` to `rich.repr.Result` (old names remain for compatibility but will be deprecated in the future)
- Changed meta serialization to use pickle rather than marshal to permit callables

## [10.6.0] - 2021-07-12

### Deprecated
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ format-check:
format:
black .
typecheck:
mypy -p rich --strict
mypy -p rich --strict --no-incremental
typecheck-report:
mypy -p rich --strict --html-report mypy_report
.PHONY: docs
Expand Down
14 changes: 7 additions & 7 deletions docs/source/group.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Render Groups
=============

The :class:`~rich.console.RenderGroup` class allows you to group several renderables together so they may be rendered in a context where only a single renderable may be supplied. For instance, you might want to display several renderables within a :class:`~rich.panel.Panel`.
The :class:`~rich.console.Group` class allows you to group several renderables together so they may be rendered in a context where only a single renderable may be supplied. For instance, you might want to display several renderables within a :class:`~rich.panel.Panel`.

To render two panels within a third panel, you would construct a RenderGroup with the *child* renderables as positional arguments then wrap the result in another Panel::
To render two panels within a third panel, you would construct a Group with the *child* renderables as positional arguments then wrap the result in another Panel::

from rich import print
from rich.console import RenderGroup
from rich.console import Group
from rich.panel import Panel

panel_group = RenderGroup(
panel_group = Group(
Panel("Hello", style="on blue"),
Panel("World", style="on red"),
)
print(Panel(panel_group))


This pattern is nice when you know in advance what renderables will be in a group, but can get awkward if you have a larger number of renderables, especially if they are dynamic. Rich provides a :func:`~rich.console.render_group` decorator to help with these situations. The decorator builds a render group from an iterator of renderables. The following is the equivalent of the previous example using the decorator::
This pattern is nice when you know in advance what renderables will be in a group, but can get awkward if you have a larger number of renderables, especially if they are dynamic. Rich provides a :func:`~rich.console.group` decorator to help with these situations. The decorator builds a group from an iterator of renderables. The following is the equivalent of the previous example using the decorator::

from rich import print
from rich.console import render_group
from rich.console import group
from rich.panel import Panel

@render_group()
@group()
def get_panels():
yield Panel("Hello", style="on blue")
yield Panel("World", style="on red")
Expand Down
3 changes: 3 additions & 0 deletions docs/source/markup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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`).

Run the following command to see some examples::

python -m rich.markup

Syntax
------
Expand Down
4 changes: 2 additions & 2 deletions examples/fullscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from rich import box
from rich.align import Align
from rich.console import Console, RenderGroup
from rich.console import Console, Group
from rich.layout import Layout
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn
Expand Down Expand Up @@ -67,7 +67,7 @@ def make_sponsor_message() -> Panel:

message_panel = Panel(
Align.center(
RenderGroup(intro_message, "\n", Align.center(sponsor_message)),
Group(intro_message, "\n", Align.center(sponsor_message)),
vertical="middle",
),
box=box.ROUNDED,
Expand Down
4 changes: 2 additions & 2 deletions examples/group.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from rich import print
from rich.console import RenderGroup
from rich.console import Group
from rich.panel import Panel

panel_group = RenderGroup(
panel_group = Group(
Panel("Hello", style="on blue"),
Panel("World", style="on red"),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/group2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from rich import print
from rich.console import render_group
from rich.console import group
from rich.panel import Panel


@render_group()
@group()
def get_panels():
yield Panel("Hello", style="on blue")
yield Panel("World", style="on red")
Expand Down

0 comments on commit 52d159a

Please sign in to comment.