treescope.handlers

treescope.handlers#

Treescope rendering handlers, for use in renderer configurations.

These handlers are responsible for implementing each of the steps of the default Treescope renderer, and can be used individually to build custom renderer configurations.

Functions

use_autovisualizer_if_present(node, path, ...)

Treescope wrapper hook that runs the active autovisualizer.

handle_basic_types(node, path, subtree_renderer)

Renders basic builtin Python types.

replace_with_canonical_aliases(node, path, ...)

Rewrites objects to use well-known aliases when known.

handle_via_global_registry(node, path, ...)

Renders a type by looking it up in the global handler registry.

handle_via_treescope_repr_method(node, path, ...)

Renders a type by calling its __treescope_repr__ method, if it exists.

handle_code_objects_with_reflection(node, ...)

Renders code objects using source-code reflection and closure inspection.

handle_arbitrary_pytrees(node, path, ...)

Generic foldable fallback for an unrecognized pytree type.

handle_anything_with_repr(node, path, ...)

Builds a foldable from its repr.

append_repr_html_when_present(node, path, ...)

Appends rich HTML representations of objects that have them.

check_for_shared_values(node, path, ...)

Wrapper hook to check for and annotate shared values.

setup_shared_value_context()

Returns a context manager for the shared value context.