Classes
Fragment
6
▼
A single block's rendered output with semantic metadata.
Fragment
6
▼
A single block's rendered output with semantic metadata.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
Block name (e.g., "content", "sidebar") |
role |
str
|
Semantic role from BlockMetadata.inferred_role (e.g., "content", "navigation", "unknown") |
html |
str
|
Raw rendered HTML of this block |
content_hash |
str
|
SHA256[:16] hex digest of the rendered HTML |
depends_on |
frozenset[str]
|
Context paths this block reads (from BlockMetadata) |
cache_scope |
str
|
Caching granularity from BlockMetadata.cache_scope ("site", "page", "none", "unknown") |
RenderCapture
8
▼
Collects fragments and context during a single render() call.
Populated by compiler-injected hooks…
RenderCapture
8
▼
Collects fragments and context during a single render() call.
Populated by compiler-injected hooks when an active capture exists.
Usecaptured_render() to create and activate a capture.
Attributes
| Name | Type | Description |
|---|---|---|
template_name |
str
|
Name of the rendered template |
blocks |
dict[str, Fragment]
|
Block name -> Fragment mapping for captured blocks |
context_keys |
dict[str, Any]
|
Snapshotted context values (top-level keys only) |
_capture_blocks |
frozenset[str] | None
|
— |
_capture_context |
frozenset[str] | None
|
— |
_block_metadata |
dict[str, Any] | None
|
— |
Methods
changed_from
1
dict[str, tuple[Fragment…
▼
Blocks whose content_hash differs between two captures.
Returns a dict mapping…
changed_from
1
dict[str, tuple[Fragment…
▼
def changed_from(self, other: RenderCapture) -> dict[str, tuple[Fragment, Fragment]]
Blocks whose content_hash differs between two captures.
Returns a dict mapping block name to (old_fragment, new_fragment) for blocks present in both captures with different content.
Parameters
| Name | Type | Description |
|---|---|---|
other |
— |
The earlier capture to compare against. |
Returns
dict[str, tuple[Fragment, Fragment]]
Dict of block name -> (other's fragment, self's fragment) for changed blocks.
Internal Methods 1 ▼
_record
2
▼
Record a block's rendered output.
Called by compiler-injected hooks at block c…
_record
2
▼
def _record(self, name: str, html: str) -> None
Record a block's rendered output.
Called by compiler-injected hooks at block call sites. Skips recording if the block is not in the capture set. Pulls role and depends_on from _block_metadata when available.
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Block name |
html |
— |
Rendered HTML output of the block |
Functions
_compute_content_hash
1
str
▼
Compute content hash for a rendered block.
Uses SHA256 truncated to 16 hex cha…
_compute_content_hash
1
str
▼
def _compute_content_hash(html: str) -> str
Compute content hash for a rendered block.
Uses SHA256 truncated to 16 hex chars, matching the block_hash precedent in kida.analysis.analyzer.
Parameters
| Name | Type | Description |
|---|---|---|
html |
str |
Returns
str
get_capture
0
RenderCapture | None
▼
Get current capture (None if capture not active).
get_capture
0
RenderCapture | None
▼
def get_capture() -> RenderCapture | None
Returns
RenderCapture | None
captured_render
2
Iterator[RenderCapture]
▼
Context manager for captured rendering.
Creates a RenderCapture and makes it a…
captured_render
2
Iterator[RenderCapture]
▼
def captured_render(capture_blocks: frozenset[str] | None = None, capture_context: frozenset[str] | None = None) -> Iterator[RenderCapture]
Context manager for captured rendering.
Creates a RenderCapture and makes it available via get_capture() for the duration of the with block. Compiler-injected hooks record block content and context snapshots into the capture.
Parameters
| Name | Type | Description |
|---|---|---|
capture_blocks |
frozenset[str] | None |
Set of block names to capture. None captures all blocks. Default:None
|
capture_context |
frozenset[str] | None |
Set of top-level context keys to snapshot. None captures no context (explicit opt-in for context). Default:None
|
Returns
Iterator[RenderCapture]