Skip to content

TreeOptions

🛈 DocStrings

Configuration options for tree visualization.

Controls the appearance and content of the generated tree structure.

Parameters:

Name Type Description Default
show_types bool

Include node type annotations

True
show_line_numbers bool

Display source line numbers

False
show_decorators bool

Include decorator information

True
sort_alphabetically bool

Sort nodes by name

False
include_private bool

Include private members (_name)

True
include_dunder bool

Include double underscore methods (name)

False
max_depth int | None

Maximum tree depth to display

None
branch_style str

Style of tree branches ("ascii" or "unicode")

'ascii'
Source code in src/jinjarope/codetree.py
@dataclass
class TreeOptions:
    """Configuration options for tree visualization.

    Controls the appearance and content of the generated tree structure.

    Args:
        show_types: Include node type annotations
        show_line_numbers: Display source line numbers
        show_decorators: Include decorator information
        sort_alphabetically: Sort nodes by name
        include_private: Include private members (_name)
        include_dunder: Include double underscore methods (__name__)
        max_depth: Maximum tree depth to display
        branch_style: Style of tree branches ("ascii" or "unicode")
    """

    show_types: bool = True
    show_line_numbers: bool = False
    show_decorators: bool = True
    sort_alphabetically: bool = False
    include_private: bool = True
    include_dunder: bool = False
    max_depth: int | None = None
    branch_style: str = "ascii"  # "ascii" or "unicode"

    @property
    def symbols(self) -> dict[str, str]:
        """Get tree drawing symbols based on selected style.

        Returns a dictionary containing the appropriate symbols for
        drawing tree branches.
        """
        if self.branch_style == "unicode":
            return {"pipe": "│   ", "last": "└── ", "branch": "├── ", "empty": "    "}
        return {"pipe": "|   ", "last": "`-- ", "branch": "|-- ", "empty": "    "}

symbols property

symbols: dict[str, str]

Get tree drawing symbols based on selected style.

Returns a dictionary containing the appropriate symbols for drawing tree branches.

:fa-brands-github: Show source on GitHub