ScopedSelectableAnnotation

ScopedSelectableAnnotation#

class penzai.treescope.foldable_representation.basic_parts.ScopedSelectableAnnotation[source]#

Bases: DeferringToChild

Modifies its child so that selections outside it don’t include it.

It is sometimes useful to add additional annotations to an object that aren’t pretty-printed parts of that object. This causes some problems for ordinary roundtrip mode, since we want it to be possible to exactly round-trip an object based on its printed representation.

This object marks its child so that it doesn’t get selected by the mouse when the selection starts outside the node. This means that if you copy the object normally, you don’t copy the annotation, so that what you copied stays roundtrippable.

In text mode, selections can’t be manipulated. We fake the same thing by rendering it as a “comment” (by adding comment markers before every line) and hiding it if collapsed.

Variables:

child (part_interface.RenderableTreePart) – Child to render.

Inherited Attributes

collapsed_width

The length of this rendering if collapsed in one line, in characters.

newlines_in_expanded_parent

The number of newlines in this rendering if in an expanded parent.

tags_in_this_part

Returns a set of "tag" objects contained in this part.

Methods

__init__(child)

html_setup_parts(context)

render_to_html(stream, *[, at_beginning_of_line])

render_to_text(stream, *, expanded_parent, ...)

Attributes

collapsed_width

The length of this rendering if collapsed in one line, in characters.

newlines_in_expanded_parent

The number of newlines in this rendering if in an expanded parent.

tags_in_this_part

Returns a set of "tag" objects contained in this part.

child

Inherited Methods

(expand to view inherited methods)

foldables_in_this_part()