Classes
TaxonomyIndexMixin
Mixin providing taxonomy indexing for fast incremental builds.
Requires these attributes on the ho…
TaxonomyIndexMixin
Mixin providing taxonomy indexing for fast incremental builds.
Requires these attributes on the host class:
- taxonomy_deps: dict[str, set[str]]
- page_tags: dict[str, set[str]]
- tag_to_pages: dict[str, set[str]]
- known_tags: set[str]
Attributes
| Name | Type | Description |
|---|---|---|
taxonomy_deps |
dict[str, set[str]] |
|
page_tags |
dict[str, set[str]] |
|
tag_to_pages |
dict[str, set[str]] |
|
known_tags |
set[str] |
Methods 6
add_taxonomy_dependency
Record that a taxonomy term affects a page.
add_taxonomy_dependency
def add_taxonomy_dependency(self, taxonomy_term: str, page: Path) -> None
Record that a taxonomy term affects a page.
Parameters 2
taxonomy_term |
str |
Taxonomy term (e.g., "tag:python") |
page |
Path |
Page that uses this taxonomy term |
get_previous_tags
Get tags from previous build for a page.
get_previous_tags
def get_previous_tags(self, page_path: Path) -> set[str]
Get tags from previous build for a page.
Parameters 1
page_path |
Path |
Path to page |
Returns
Set of tags from previous build (empty set if new page)set[str]
—
update_tags
Store current tags for a page (for next build's comparison).
update_tags
def update_tags(self, page_path: Path, tags: set[str]) -> None
Store current tags for a page (for next build's comparison).
Parameters 2
page_path |
Path |
Path to page |
tags |
set[str] |
Current set of tags for the page |
update_page_tags
Update tag index when a page's tags change.
Maintains bidirectional index:
- p…
update_page_tags
def update_page_tags(self, page_path: Path, tags: set[str]) -> set[str]
Update tag index when a page's tags change.
Maintains bidirectional index:
- page_tags: path → tags (forward)
- tag_to_pages: tag → paths (inverted)
This is the key method that enables O(1) taxonomy reconstruction.
Parameters 2
page_path |
Path |
Path to page source file |
tags |
set[str] |
Current set of tags for this page (original case, e.g., "Python", "Web Dev") |
Returns
Set of affected tag slugs (tags added, removed, or modified)set[str]
—
get_pages_for_tag
Get all page paths for a given tag.
get_pages_for_tag
def get_pages_for_tag(self, tag_slug: str) -> set[str]
Get all page paths for a given tag.
Parameters 1
tag_slug |
str |
Tag slug (e.g., 'python', 'web-dev') |
Returns
Set of page path stringsset[str]
—
get_all_tags
Get all known tag slugs from previous build.
get_all_tags
def get_all_tags(self) -> set[str]
Get all known tag slugs from previous build.
Returns
Set of tag slugsset[str]
—