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

Method __rich_console__

rich/table.py:475–521  ·  view source on GitHub ↗
(
        self, console: "Console", options: "ConsoleOptions"
    )

Source from the content-addressed store, hash-verified

473 self.rows[-1].end_section = True
474
475 def __rich_console__(
476 self, console: "Console", options: "ConsoleOptions"
477 ) -> "RenderResult":
478 if not self.columns:
479 yield Segment("\n")
480 return
481
482 max_width = options.max_width
483 if self.width is not None:
484 max_width = self.width
485
486 extra_width = self._extra_width
487
488 widths = self._calculate_column_widths(
489 console, options.update_width(max_width - extra_width)
490 )
491 table_width = sum(widths) + extra_width
492
493 render_options = options.update(
494 width=table_width, highlight=self.highlight, height=None
495 )
496
497 def render_annotation(
498 text: TextType, style: StyleType, justify: "JustifyMethod" = "center"
499 ) -> "RenderResult":
500 render_text = (
501 console.render_str(text, style=style, highlight=False)
502 if isinstance(text, str)
503 else text
504 )
505 return console.render(
506 render_text, options=render_options.update(justify=justify)
507 )
508
509 if self.title:
510 yield from render_annotation(
511 self.title,
512 style=Style.pick_first(self.title_style, "table.title"),
513 justify=self.title_justify,
514 )
515 yield from self._render(console, render_options, widths)
516 if self.caption:
517 yield from render_annotation(
518 self.caption,
519 style=Style.pick_first(self.caption_style, "table.caption"),
520 justify=self.caption_justify,
521 )
522
523 def _calculate_column_widths(
524 self, console: "Console", options: "ConsoleOptions"

Callers

nothing calls this directly

Calls 6

_renderMethod · 0.95
SegmentClass · 0.85
update_widthMethod · 0.80
pick_firstMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected