build_foldable_tree_node_from_children#
- treescope.rendering_parts.build_foldable_tree_node_from_children(prefix: RenderableTreePart | str, children: Sequence[RenderableAndLineAnnotations | RenderableTreePart | str], suffix: RenderableTreePart | str, comma_separated: bool = False, force_trailing_comma: bool = False, path: str | None = None, background_color: str | None = None, background_pattern: str | None = None, first_line_annotation: RenderableTreePart | None = None, expand_state: part_interface.ExpandState = ExpandState.WEAKLY_COLLAPSED) RenderableAndLineAnnotations [source]#
Builds a foldable tree node with path buttons.
- Parameters:
prefix – Contents of the first line, before the children. Should not contain any other foldables. Usually ends with an opening paren/bracket, e.g. “SomeClass(”
children – Sequence of children of this node, which should each be rendered on their own line.
suffix – Contents of the last line, after the children. Usually a closing paren/bracket for
prefix
.comma_separated – Whether to insert commas between children.
force_trailing_comma – Whether to always insert a trailing comma after the last child.
path – Keypath to this node from the root. If provided, copy-path buttons will be added.
background_color – Optional background and border color for this node.
background_pattern – Optional background pattern as a CSS “image”. If provided,
background_color
must also be provided, and will be used as the border for the pattern.first_line_annotation – An annotation for the first line of the node when it is expanded.
expand_state – Initial expand state for the foldable.
- Returns:
A new renderable part, possibly with a copy button annotation, for use in part of a rendered treescope tree.