MCPcopy
hub / github.com/Textualize/rich / make_test_card

Function make_test_card

rich/__main__.py:39–206  ·  view source on GitHub ↗

Get a renderable that demonstrates a number of features.

()

Source from the content-addressed store, hash-verified

37
38
39def make_test_card() -> Table:
40 """Get a renderable that demonstrates a number of features."""
41 table = Table.grid(padding=1, pad_edge=True)
42 table.title = "Rich features"
43 table.add_column("Feature", no_wrap=True, justify="center", style="bold red")
44 table.add_column("Demonstration")
45
46 color_table = Table(
47 box=None,
48 expand=False,
49 show_header=False,
50 show_edge=False,
51 pad_edge=False,
52 )
53 color_table.add_row(
54 (
55 "✓ [bold green]4-bit color[/]\n"
56 "✓ [bold blue]8-bit color[/]\n"
57 "✓ [bold magenta]Truecolor (16.7 million)[/]\n"
58 "✓ [bold yellow]Dumb terminals[/]\n"
59 "✓ [bold cyan]Automatic color conversion"
60 ),
61 ColorBox(),
62 )
63
64 table.add_row("Colors", color_table)
65
66 table.add_row(
67 "Styles",
68 "All ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].",
69 )
70
71 lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus."
72 lorem_table = Table.grid(padding=1, collapse_padding=True)
73 lorem_table.pad_edge = False
74 lorem_table.add_row(
75 Text(lorem, justify="left", style="green"),
76 Text(lorem, justify="center", style="yellow"),
77 Text(lorem, justify="right", style="blue"),
78 Text(lorem, justify="full", style="red"),
79 )
80 table.add_row(
81 "Text",
82 Group(
83 Text.from_markup(
84 """Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].\n"""
85 ),
86 lorem_table,
87 ),
88 )
89
90 def comparison(renderable1: RenderableType, renderable2: RenderableType) -> Table:
91 table = Table(show_header=False, pad_edge=False, box=None, expand=True)
92 table.add_column("1", ratio=1)
93 table.add_column("2", ratio=1)
94 table.add_row(renderable1, renderable2)
95 return table
96

Callers 4

test_card_renderFunction · 0.90
test_card.pyFile · 0.90
__main__.pyFile · 0.85
pager.pyFile · 0.85

Calls 12

add_columnMethod · 0.95
add_rowMethod · 0.95
TableClass · 0.90
TextClass · 0.90
GroupClass · 0.90
SyntaxClass · 0.90
PrettyClass · 0.90
MarkdownClass · 0.90
comparisonFunction · 0.85
gridMethod · 0.80
from_markupMethod · 0.80
ColorBoxClass · 0.70

Tested by 1

test_card_renderFunction · 0.72