Classes
FunctionBlockParsingMixin
6
▼
Mixin for parsing function blocks.
Host attributes and cross-mixin dependencies are declared via i…
FunctionBlockParsingMixin
6
▼
Mixin for parsing function blocks.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Inherits block stack management from BlockStackMixin.
Methods
Internal Methods 6 ▼
_parse_type_annotation
0
str | None
▼
Parse an optional type annotation after a parameter name.
Called when the curr…
_parse_type_annotation
0
str | None
▼
def _parse_type_annotation(self) -> str | None
Parse an optional type annotation after a parameter name.
Called when the current token is COLON (indicating a type follows). Consumes the colon and type expression tokens, returning the raw annotation string.
Grammar::
type_expr := NAME [ '|' NAME ]* [ '[' type_expr (',' type_expr)* ']' ]
Handles:str, int, list, str | None,
dict[str, int], MyModel.
Returns
str | None
Raw annotation string, or None if no colon follows.
_parse_type_annotation_inner
0
str
▼
Parse a single type inside brackets (for generic parameters).
_parse_type_annotation_inner
0
str
▼
def _parse_type_annotation_inner(self) -> str
Returns
str
Type string (e.g. "str", "str | None").
_parse_def
0
Def
▼
Parse {% def name(args) %}...{% end %} or {% enddef %.
Kida functions with tru…
_parse_def
0
Def
▼
def _parse_def(self) -> Def
Parse {% def name(args) %}...{% end %} or {% enddef %.
Kida functions with true lexical scoping (can access outer scope). Uses stack-based parsing for proper nested block handling.
Supports optional type annotations on parameters::
{% def card(title: str, items: list, footer: str | None = None) %}
...
{% end %}
Returns
Def
_parse_call
0
CallBlock
▼
Parse {% call name(args) %}body{% end %} or {% endcall %.
Call a function/def …
_parse_call
0
CallBlock
▼
def _parse_call(self) -> CallBlock
Parse {% call name(args) %}body{% end %} or {% endcall %.
Call a function/def with body content that fills {% slot %}. Supports named slots: {% slot name %}...{% end %} assigns to slot name; content outside slot blocks goes to default.
Returns
CallBlock
_parse_call_body
0
dict[str, Sequence[Node]]
▼
Parse call block body into slots dict.
When {% slot name %}...{% end %} appear…
_parse_call_body
0
dict[str, Sequence[Node]]
▼
def _parse_call_body(self) -> dict[str, Sequence[Node]]
Parse call block body into slots dict.
When {% slot name %}...{% end %} appears, content goes to slots[name]. Other content goes to slots["default"].
Returns
dict[str, Sequence[Node]]
_parse_slot
0
Slot | SlotBlock
▼
Parse {% slot %} or {% slot name %} — context-dependent.
Inside {% call %}: pa…
_parse_slot
0
Slot | SlotBlock
▼
def _parse_slot(self) -> Slot | SlotBlock
Parse {% slot %} or {% slot name %} — context-dependent.
Inside {% call %}: parse {% slot name %}...{% end %} as SlotBlock. Inside {% def %}: parse self-closing {% slot %} or {% slot name %} as Slot.
Returns
Slot | SlotBlock