Module

utils.theme_resolution

Theme resolution and inheritance chain building.

Resolves theme inheritance chains by reading theme.toml files and following extends relationships. Supports site themes, installed themes, and bundled themes. Builds complete inheritance chains for template and asset discovery.

Key Concepts:

  • Theme inheritance: Child themes extend parent themes
  • Resolution order: Site themes → installed themes → bundled themes
  • Chain building: Recursive resolution of extends relationships
  • Template discovery: Uses inheritance chain for template lookup

Related Modules:

  • bengal.utils.theme_registry: Installed theme discovery
  • bengal.rendering.template_engine: Template engine using inheritance chains
  • bengal.core.theme: Theme configuration object

See Also:

  • bengal/utils/theme_resolution.py: resolve_theme_chain() for chain resolution
  • plan/active/rfc-theme-inheritance.md: Theme inheritance design

Functions

_read_theme_extends
Read theme.toml for 'extends' from site, installed, or bundled theme path.
2 str | None
def _read_theme_extends(site_root: Path, theme_name: str) -> str | None

Read theme.toml for 'extends' from site, installed, or bundled theme path.

Parameters 2

Name Type Default Description
site_root Path
theme_name str

Returns

str | None

resolve_theme_chain
Resolve theme inheritance chain starting from the active theme. Order: child first → parent → ... …
2 list[str]
def resolve_theme_chain(site_root: Path, active_theme: str | None) -> list[str]

Resolve theme inheritance chain starting from the active theme.

Order: child first → parent → ... (does not duplicate 'default').

Parameters 2

Name Type Default Description
site_root Path
active_theme str | None

Returns

list[str]

iter_theme_asset_dirs
Return list of theme asset directories from parents to child (low → high priority). Site assets can…
2 list[Path]
def iter_theme_asset_dirs(site_root: Path, theme_chain: Iterable[str]) -> list[Path]

Return list of theme asset directories from parents to child (low → high priority). Site assets can still override these.

Parameters 2

Name Type Default Description
site_root Path
theme_chain Iterable[str]

Returns

list[Path]