diff --git a/docs/source/index.rst b/docs/source/index.rst index f40541a2..be116a24 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -20,15 +20,16 @@ Welcome to Rich's documentation! traceback.rst prompt.rst - tables.rst + columns.rst + group.rst + live.rst + markdown.rst padding.rst panel.rst - group.rst - columns.rst - live.rst progress.rst - markdown.rst syntax.rst + tables.rst + tree.rst protocol.rst diff --git a/docs/source/reference.rst b/docs/source/reference.rst index ed85f17a..d4deb432 100644 --- a/docs/source/reference.rst +++ b/docs/source/reference.rst @@ -35,4 +35,5 @@ Reference reference/text.rst reference/theme.rst reference/traceback.rst + reference/tree.rst references/abc.rst diff --git a/docs/source/text.rst b/docs/source/text.rst index ed5f06cb..50113d37 100644 --- a/docs/source/text.rst +++ b/docs/source/text.rst @@ -9,7 +9,10 @@ You can consider this class to be like a string with marked up regions of text. One way to add a style to Text is the :meth:`~rich.text.Text.stylize` method which applies a style to a start and end offset. Here is an example:: + from rich.console import Console from rich.text import Text + + console = Console() text = Text("Hello, World!") text.stylize("bold magenta", 0, 6) console.print(text) diff --git a/rich/tree.py b/rich/tree.py index 0d732ef6..614783a3 100644 --- a/rich/tree.py +++ b/rich/tree.py @@ -12,7 +12,7 @@ class Tree(JupyterMixin): """A renderable for a tree structure. Args: - renderable (RenderableType): The renderable or str for the tree label. + label (RenderableType): The renderable or str for the tree label. style (StyleType, optional): Style of this tree. Defaults to "tree". guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line". expanded (bool, optional): Also display children. Defaults to True. @@ -21,14 +21,14 @@ class Tree(JupyterMixin): def __init__( self, - renderable: RenderableType, + label: RenderableType, *, style: StyleType = "tree", guide_style: StyleType = "tree.line", expanded=True, highlight=False, ) -> None: - self.renderable = renderable + self.label = label self.style = style self.guide_style = guide_style self.children: List[Tree] = [] @@ -37,7 +37,7 @@ class Tree(JupyterMixin): def add( self, - renderable: RenderableType, + label: RenderableType, *, style: StyleType = None, guide_style: StyleType = None, @@ -47,7 +47,7 @@ class Tree(JupyterMixin): """Add a child tree. Args: - renderable (RenderableType): The renderable or str for the tree label. + label (RenderableType): The renderable or str for the tree label. style (StyleType, optional): Style of this tree. Defaults to "tree". guide_style (StyleType, optional): Style of the guide lines. Defaults to "tree.line". expanded (bool, optional): Also display children. Defaults to True. @@ -57,7 +57,7 @@ class Tree(JupyterMixin): Tree: A new child Tree, which may be further modified. """ node = Tree( - renderable, + label, style=self.style if style is None else style, guide_style=self.guide_style if guide_style is None else guide_style, expanded=expanded, @@ -123,7 +123,7 @@ class Tree(JupyterMixin): style = style_stack.current + get_style(node.style) prefix = levels[1:] renderable_lines = console.render_lines( - Styled(node.renderable, style), + Styled(node.label, style), options.update( width=options.max_width - sum(level.cell_length for level in prefix),