Classes
MenuOrchestrator
Orchestrates navigation menu building with incremental caching.
Handles menu building from config …
MenuOrchestrator
Orchestrates navigation menu building with incremental caching.
Handles menu building from config definitions, page frontmatter, and section structure. Supports incremental menu building by caching menus when config and menu-related pages are unchanged.
Creation:
Direct instantiation: MenuOrchestrator(site)
- Created by BuildOrchestrator during build
- Requires Site instance with pages and config populated
Attributes
| Name | Type | Description |
|---|---|---|
site |
— | Site instance containing menu configuration and pages |
_menu_cache_key |
— | Cache key for incremental menu building |
Relationships |
— |
|
Methods 2
build
Build all menus from config and page frontmatter.
With incremental building:
-…
build
def build(self, changed_pages: set[Path] | None = None, config_changed: bool = False) -> bool
Build all menus from config and page frontmatter.
With incremental building:
- If config unchanged AND no pages with menu frontmatter changed
- Skip rebuild and reuse cached menus
Parameters 2
changed_pages |
set[Path] | None |
Set of paths for pages that changed (for incremental builds) |
config_changed |
bool |
Whether config file changed (forces rebuild) |
Returns
True if menus were rebuilt, False if cached menus reused Called during site.build() after content discovery.bool
—
mark_active
Mark active menu items for the current page being rendered.
Called during rende…
mark_active
def mark_active(self, current_page: Page) -> None
Mark active menu items for the current page being rendered. Called during rendering for each page.
Parameters 1
current_page |
Page |
Page currently being rendered |
Internal Methods 6
__init__
Initialize menu orchestrator.
__init__
def __init__(self, site: Site)
Initialize menu orchestrator.
Parameters 1
site |
Site |
Site instance containing menu configuration |
_can_skip_rebuild
Check if menu rebuild can be skipped (incremental optimization).
Menus need re…
_can_skip_rebuild
def _can_skip_rebuild(self, changed_pages: set[Path]) -> bool
Check if menu rebuild can be skipped (incremental optimization).
Menus need rebuild only if:
- Config changed (menu definitions)
- Pages with 'menu' frontmatter changed
Parameters 1
changed_pages |
set[Path] |
Set of changed page paths |
Returns
True if rebuild can be skipped (menus unchanged)bool
—
_compute_menu_cache_key
Compute cache key for current menu configuration.
Key includes:
- Menu config …
_compute_menu_cache_key
def _compute_menu_cache_key(self) -> str
Compute cache key for current menu configuration.
Key includes:
- Menu config from bengal.toml
- List of pages with menu frontmatter and their menu data
- Dev params (repo_url)
- Dev section names (api, cli) that affect dev menu bundling
Returns
SHA256 hash of menu-related datastr
—
_build_auto_menu_with_dev_bundling
Build auto-discovered menu with dev assets bundled into dropdown.
This is the …
_build_auto_menu_with_dev_bundling
def _build_auto_menu_with_dev_bundling(self) -> list[dict[str, Any]]
Build auto-discovered menu with dev assets bundled into dropdown.
This is the single source of truth for auto menu generation. Integrates section discovery, dev bundling, and menu structure in one place.
Returns
List of menu item dicts ready for MenuBuilder (with deduplication)list[dict[str, Any]]
—
_find_section_by_name
Find a section by its name/slug.
_find_section_by_name
def _find_section_by_name(self, section_name: str) -> Any | None
Find a section by its name/slug.
Parameters 1
section_name |
str |
Section name to find (e.g., 'api', 'cli') |
Returns
Section object if found, None otherwiseAny | None
—
_build_full
Build all menus from scratch.
_build_full
def _build_full(self) -> bool
Build all menus from scratch.
Returns
True (menus were rebuilt)bool
—