astx.viz
astx.viz
Source: packages/astx/src/astx/viz.py
title: AST graphic representation Module.
summary: >-
This module provides utilities for converting an Abstract Syntax Tree (AST)
to Mermaid for inline display in Jupyter (Lab ≥4.1 / NB ≥7.1) and to ASCII
via the `mermaid-ascii` CLI.Functions
ast_to_mermaid(ast: ReprStruct, direction: Direction='TD') -> str
title: Mermaid for Jupyter/image (uses named items).
parameters:
ast:
type: ReprStruct
direction:
type: Direction
returns:
type: strast_to_mermaid_ascii(ast: ReprStruct, direction: Direction='TD') -> str
title: >-
Mermaid tailored for mermaid-ascii, no named items, pipe edge labels.
parameters:
ast:
type: ReprStruct
direction:
type: Direction
returns:
type: strvisualize_image(ast: ReprStruct, direction: Direction='TD') -> None
title: Display the AST as Mermaid inline in Jupyter (Lab ≥4.1 / NB ≥7.1).
parameters:
ast:
type: ReprStruct
direction:
type: Directionvisualize_ascii(ast: ReprStruct, timeout: int=10, direction: Direction='TD', width: Optional[int]=None, border_padding: Optional[int]=0, padding_x: Optional[int]=3, padding_y: Optional[int]=3, ascii_only: bool=False) -> str
title: Render the AST to ASCII using the `mermaid-ascii` CLI.
summary: |-
For maximum compatibility, this uses an ASCII-friendly Mermaid form:
- no named items (node text is the identifier)
- pipe-labeled edges (--> |label| ...)
parameters:
ast:
type: ReprStruct
timeout:
type: int
direction:
type: Direction
width:
type: Optional[int]
border_padding:
type: Optional[int]
padding_x:
type: Optional[int]
padding_y:
type: Optional[int]
ascii_only:
type: bool
returns:
type: str