build_foldable_tree_node_from_children

build_foldable_tree_node_from_children#

penzai.treescope.foldable_representation.common_structures.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: tuple[Any, ...] | None = None, background_color: str | None = None, background_pattern: str | None = None, first_line_annotation: RenderableTreePart | None = None) RenderableAndLineAnnotations[source]#

Builds a foldable tree node with path buttons and hyperlink support.

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, and this node will be possible to target with hyperlinks.

  • 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.

Returns:

A new renderable part, possibly with a copy button annotation, for use in part of a rendered treescope tree.