DynamicSharedCheck#
- class penzai.treescope.handlers.shared_value_postprocessor.DynamicSharedCheck[source]#
Bases:
RenderableTreePartDynamic group that renders its child only if a node is shared.
This node is used to apply special rendering to nodes that are encountered in multiple places in the same input. It works by holding a particular node ID as well as a reference to a set of node IDs that have been seen more than once. When rendered, it checks if its node ID has been seen more than once and renders differently if so.
Note that we might have only seen this object once at the time the shared warning object is constructed, even if eventually we will see it again. This means the
seen_more_than_onceattribute has to be (a reference to) a mutable set modified elsewhere.Shared markers always act like empty parts for layout decisions.
- Variables:
if_shared (penzai.treescope.foldable_representation.part_interface.RenderableTreePart) – Child to render only if the node is shared.
node_id (int) – Node ID of the node we are rendering. Used for the warning and also looked up in
seen_more_than_once.seen_more_than_once (set[int]) – Reference to an externally-maintaned set of node IDs we’ve seen more than once. Usually, this will be the same set from the active
_shared_object_ids_seencontext.
Inherited Attributes
collapsed_widthThe length of this rendering if collapsed in one line, in characters.
newlines_in_expanded_parentThe number of newlines in this rendering if in an expanded parent.
tags_in_this_partReturns a set of "tag" objects contained in this part.
Methods
__init__(if_shared, node_id, seen_more_than_once)foldables_in_this_part()html_setup_parts(setup_context)render_to_html(stream, *[, at_beginning_of_line])render_to_text(stream, *, expanded_parent, ...)Attributes
collapsed_widthThe length of this rendering if collapsed in one line, in characters.
newlines_in_expanded_parentThe number of newlines in this rendering if in an expanded parent.
tags_in_this_partReturns a set of "tag" objects contained in this part.
if_sharednode_idseen_more_than_once