Classes
CacheInvalidator
Cache invalidation logic for incremental builds.
Tracks invalidated paths based on content, templa…
CacheInvalidator
Cache invalidation logic for incremental builds.
Tracks invalidated paths based on content, template, and config changes. Provides methods for selective invalidation and full cache invalidation.
Creation:
Direct instantiation: CacheInvalidator(config_hash, content_paths, template_paths)
- Created by DependencyTracker for cache invalidation
- Requires config hash and path lists
Attributes
| Name | Type | Description |
|---|---|---|
config_hash |
— | Hash of configuration for config change detection |
content_paths |
— | List of content file paths |
template_paths |
— | List of template file paths |
invalidated |
— | Set of invalidated paths |
Relationships |
— |
|
Methods 4
is_stale
property
Invariant: Check if cache needs rebuild.
is_stale
property def is_stale(self) -> bool
Invariant: Check if cache needs rebuild.
Returns
bool
invalidate_content
Invalidate on content changes.
invalidate_content
def invalidate_content(self, changed_paths: set[Path]) -> set[Path]
Invalidate on content changes.
Parameters 1
changed_paths |
set[Path] |
Returns
set[Path]
invalidate_templates
Invalidate dependent pages on template changes.
invalidate_templates
def invalidate_templates(self, changed_paths: set[Path]) -> set[Path]
Invalidate dependent pages on template changes.
Parameters 1
changed_paths |
set[Path] |
Returns
set[Path]
invalidate_config
Full invalidation on config change.
invalidate_config
def invalidate_config(self) -> set[Path]
Full invalidation on config change.
Returns
set[Path]
Internal Methods 1
__init__
__init__
def __init__(self, config_hash: str, content_paths: list[Path], template_paths: list[Path])
Parameters 3
config_hash |
str |
|
content_paths |
list[Path] |
|
template_paths |
list[Path] |
DependencyTracker
Tracks dependencies between pages and their templates, partials, and config files.
Records templat…
DependencyTracker
Tracks dependencies between pages and their templates, partials, and config files.
Records template and data file dependencies during rendering to enable incremental builds. Uses thread-local storage for thread-safe parallel rendering and maintains dependency graphs for change detection.
Creation:
Direct instantiation: DependencyTracker(cache, site=None)
- Created by IncrementalOrchestrator for dependency tracking
- Requires BuildCache instance for dependency storage
Attributes
| Name | Type | Description |
|---|---|---|
cache |
— | BuildCache instance for dependency storage |
site |
— | Optional Site instance for config path access |
logger |
— | Logger instance for dependency tracking events |
tracked_files |
— | Mapping of file paths to page paths |
dependencies |
— | Forward dependency graph (page → dependencies) |
reverse_dependencies |
— | Reverse dependency graph (dependency → pages) |
current_page |
— | Thread-local current page being processed |
invalidator |
— | CacheInvalidator for cache invalidation |
Relationships |
— |
|
Methods 10
start_page
Mark the start of processing a page (thread-safe).
start_page
def start_page(self, page_path: Path) -> None
Mark the start of processing a page (thread-safe).
Parameters 1
page_path |
Path |
Path to the page being processed |
track_template
Record that the current page depends on a template (thread-safe).
track_template
def track_template(self, template_path: Path) -> None
Record that the current page depends on a template (thread-safe).
Parameters 1
template_path |
Path |
Path to the template file |
track_partial
Record that the current page depends on a partial/include (thread-safe).
track_partial
def track_partial(self, partial_path: Path) -> None
Record that the current page depends on a partial/include (thread-safe).
Parameters 1
partial_path |
Path |
Path to the partial file |
track_config
Record that the current page depends on the config file (thread-safe).
All page…
track_config
def track_config(self, config_path: Path) -> None
Record that the current page depends on the config file (thread-safe). All pages depend on config, so this marks it as a global dependency.
Parameters 1
config_path |
Path |
Path to the config file |
track_asset
Record an asset file (for cache invalidation).
track_asset
def track_asset(self, asset_path: Path) -> None
Record an asset file (for cache invalidation).
Parameters 1
asset_path |
Path |
Path to the asset file |
track_taxonomy
Record taxonomy (tags/categories) dependencies.
When a page's tags change, tag…
track_taxonomy
def track_taxonomy(self, page_path: Path, tags: set[str]) -> None
Record taxonomy (tags/categories) dependencies.
When a page's tags change, tag pages need to be regenerated.
Parameters 2
page_path |
Path |
Path to the page |
tags |
set[str] |
Set of tags/categories for this page |
end_page
Mark the end of processing a page (thread-safe).
end_page
def end_page(self) -> None
Mark the end of processing a page (thread-safe).
get_changed_files
Get all files that have changed since the last build.
get_changed_files
def get_changed_files(self, root_path: Path) -> set[Path]
Get all files that have changed since the last build.
Parameters 1
root_path |
Path |
Root path of the site |
Returns
Set of paths that have changedset[Path]
—
find_new_files
Find files that are new (not in cache).
find_new_files
def find_new_files(self, current_files: set[Path]) -> set[Path]
Find files that are new (not in cache).
Parameters 1
current_files |
set[Path] |
Set of current file paths |
Returns
Set of new file pathsset[Path]
—
find_deleted_files
Find files that were deleted (in cache but not on disk).
find_deleted_files
def find_deleted_files(self, current_files: set[Path]) -> set[Path]
Find files that were deleted (in cache but not on disk).
Parameters 1
current_files |
set[Path] |
Set of current file paths |
Returns
Set of deleted file pathsset[Path]
—
Internal Methods 2
__init__
Initialize the dependency tracker.
__init__
def __init__(self, cache: BuildCache, site: Site | None = None) -> None
Initialize the dependency tracker.
Parameters 2
cache |
BuildCache |
BuildCache instance to store dependencies in |
site |
Site | None |
Optional Site instance to get config path from |
_hash_config
Hash config for invalidation.
_hash_config
def _hash_config(self) -> str
Hash config for invalidation.
Returns
str