Classes
AssetReference
3
▼
Reference to an asset from a page.
AssetReference
3
▼
Reference to an asset from a page.
Attributes
| Name | Type | Description |
|---|---|---|
url |
str
|
— |
type |
str
|
— |
source_page |
str
|
— |
AssetDependencyEntry
5
▼
Cache entry for asset dependencies.
Implements the Cacheable protocol for type-safe serialization.
AssetDependencyEntry
5
▼
Cache entry for asset dependencies.
Implements the Cacheable protocol for type-safe serialization.
Attributes
| Name | Type | Description |
|---|---|---|
assets |
set[str]
|
— |
tracked_at |
str
|
— |
is_valid |
bool
|
— |
Methods
to_cache_dict
0
dict[str, Any]
▼
Serialize to cache-friendly dictionary (Cacheable protocol).
to_cache_dict
0
dict[str, Any]
▼
def to_cache_dict(self) -> dict[str, Any]
Returns
dict[str, Any]
from_cache_dict
1
AssetDependencyEntry
▼
Deserialize from cache dictionary (Cacheable protocol).
classmethod
from_cache_dict
1
AssetDependencyEntry
▼
def from_cache_dict(cls, data: dict[str, Any]) -> AssetDependencyEntry
Parameters
| Name | Type | Description |
|---|---|---|
data |
— |
Returns
AssetDependencyEntry
AssetDependencyMap
17
▼
Persistent map of page-to-asset dependencies for incremental discovery.
Purpose:
- Track which ass…
AssetDependencyMap
17
▼
Persistent map of page-to-asset dependencies for incremental discovery.
Purpose:
- Track which assets each page references
- Enable on-demand asset discovery
- Skip asset discovery for unchanged pages
- Support incremental asset fingerprinting
Cache Format (JSON): { "version": 1, "pages": { "content/index.md": { "assets": [ "/images/logo.png", "/css/style.css", "/fonts/inter.woff2" ], "tracked_at": "2025-10-16T12:00:00", "is_valid": true } } }
Methods
save_to_disk
0
▼
Save asset dependencies to disk.
save_to_disk
0
▼
def save_to_disk(self) -> None
track_page_assets
2
▼
Track assets referenced by a page.
track_page_assets
2
▼
def track_page_assets(self, source_path: Path, assets: set[str]) -> None
Parameters
| Name | Type | Description |
|---|---|---|
source_path |
— |
Path to source page |
assets |
— |
Set of asset URLs/paths referenced by the page |
get_page_assets
1
set[str] | None
▼
Get assets referenced by a page.
get_page_assets
1
set[str] | None
▼
def get_page_assets(self, source_path: Path) -> set[str] | None
Parameters
| Name | Type | Description |
|---|---|---|
source_path |
— |
Path to source page |
Returns
set[str] | None
Set of asset URLs if found and valid, None otherwise
has_assets
1
bool
▼
Check if page has tracked assets.
has_assets
1
bool
▼
def has_assets(self, source_path: Path) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
source_path |
— |
Path to source page |
Returns
bool
True if page has valid asset tracking
get_all_assets
0
set[str]
▼
Get all unique assets referenced by any page.
get_all_assets
0
set[str]
▼
def get_all_assets(self) -> set[str]
Returns
set[str]
Set of all asset URLs across all pages
get_assets_for_pages
1
set[str]
▼
Get all assets referenced by a set of pages.
get_assets_for_pages
1
set[str]
▼
def get_assets_for_pages(self, source_paths: list[Path]) -> set[str]
Parameters
| Name | Type | Description |
|---|---|---|
source_paths |
— |
List of page paths to find assets for |
Returns
set[str]
Set of all asset URLs referenced by the given pages
invalidate
1
▼
Mark a page's asset tracking as invalid.
invalidate
1
▼
def invalidate(self, source_path: Path) -> None
Parameters
| Name | Type | Description |
|---|---|---|
source_path |
— |
Path to source page |
invalidate_all
0
▼
Invalidate all asset tracking entries.
invalidate_all
0
▼
def invalidate_all(self) -> None
clear
0
▼
Clear all asset tracking.
clear
0
▼
def clear(self) -> None
get_valid_entries
0
dict[str, set[str]]
▼
Get all valid asset tracking entries.
get_valid_entries
0
dict[str, set[str]]
▼
def get_valid_entries(self) -> dict[str, set[str]]
Returns
dict[str, set[str]]
Dictionary mapping source_path to asset set for valid entries
get_invalid_entries
0
dict[str, set[str]]
▼
Get all invalid asset tracking entries.
get_invalid_entries
0
dict[str, set[str]]
▼
def get_invalid_entries(self) -> dict[str, set[str]]
Returns
dict[str, set[str]]
Dictionary mapping source_path to asset set for invalid entries
get_asset_pages
1
set[str]
▼
Get all pages that reference a specific asset.
get_asset_pages
1
set[str]
▼
def get_asset_pages(self, asset_url: str) -> set[str]
Parameters
| Name | Type | Description |
|---|---|---|
asset_url |
— |
Asset URL to find references for |
Returns
set[str]
Set of page paths that reference this asset
stats
0
dict[str, Any]
▼
Get asset dependency map statistics.
stats
0
dict[str, Any]
▼
def stats(self) -> dict[str, Any]
Returns
dict[str, Any]
Dictionary with cache stats
Internal Methods 4 ▼
__init__
1
▼
Initialize asset dependency map.
__init__
1
▼
def __init__(self, cache_path: Path | None = None)
Parameters
| Name | Type | Description |
|---|---|---|
cache_path |
— |
Path to cache file (defaults to .bengal/asset_deps.json) Default:None
|
_deserialize
1
▼
Deserialize loaded data into cache state.
_deserialize
1
▼
def _deserialize(self, data: dict[str, Any]) -> None
Parameters
| Name | Type | Description |
|---|---|---|
data |
— |
_serialize
0
dict[str, Any]
▼
Serialize cache state for saving.
_serialize
0
dict[str, Any]
▼
def _serialize(self) -> dict[str, Any]
Returns
dict[str, Any]
_on_version_mismatch
0
▼
Clear state on version mismatch.
_on_version_mismatch
0
▼
def _on_version_mismatch(self) -> None