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

Method render

rich/pretty.py:467–490  ·  view source on GitHub ↗

Render the node to a pretty repr. Args: max_width (int, optional): Maximum width of the repr. Defaults to 80. indent_size (int, optional): Size of indents. Defaults to 4. expand_all (bool, optional): Expand all levels. Defaults to False. Returns:

(
        self, max_width: int = 80, indent_size: int = 4, expand_all: bool = False
    )

Source from the content-addressed store, hash-verified

465 return repr_text
466
467 def render(
468 self, max_width: int = 80, indent_size: int = 4, expand_all: bool = False
469 ) -> str:
470 """Render the node to a pretty repr.
471
472 Args:
473 max_width (int, optional): Maximum width of the repr. Defaults to 80.
474 indent_size (int, optional): Size of indents. Defaults to 4.
475 expand_all (bool, optional): Expand all levels. Defaults to False.
476
477 Returns:
478 str: A repr string of the original object.
479 """
480 lines = [_Line(node=self, is_root=True)]
481 line_no = 0
482 while line_no < len(lines):
483 line = lines[line_no]
484 if line.expandable and not line.expanded:
485 if expand_all or not line.check_length(max_width):
486 lines[line_no : line_no + 1] = line.expand(indent_size)
487 line_no += 1
488
489 repr_str = "\n".join(str(line) for line in lines)
490 return repr_str
491
492
493@dataclass

Callers 1

pretty_reprFunction · 0.45

Calls 4

_LineClass · 0.85
joinMethod · 0.80
check_lengthMethod · 0.45
expandMethod · 0.45

Tested by

no test coverage detected