penzai.treescope.foldable_representation.common_structures.build_custom_foldable_tree_node(contents: RenderableTreePart, path: tuple[Any, ...] | None = None, label: RenderableTreePart = EmptyPart(), expand_state: part_interface.ExpandState = ExpandState.WEAKLY_COLLAPSED) RenderableAndLineAnnotations[source]#

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

  • contents – Contents of this foldable that should not open/close the custom foldable when clicked.

  • path – Keypath to this node from the root. If provided, a copy-path button will be added at the end of the node.

  • label – The beginning of the first line, which should allow opening/closing the custom foldable when clicked. Should not contain any other foldables.

  • expand_state – Initial expand state for the foldable.


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