Module

utils.theme_registry

Installed theme discovery and utilities.

Discovers uv/pip-installed themes via entry points (group: "bengal.themes"). Provides theme package lookup and resource access for installed themes.

Key Concepts:

  • Entry points: Python package entry points for theme discovery
  • Package naming: Prefer "bengal-theme-<slug>" format
  • Resource access: PackageLoader for template/asset access
  • Theme packages: ThemePackage dataclass for theme metadata

Conventions:

  • Package name: prefer "bengal-theme-<slug>"; accept "<slug>-bengal-theme".
  • Entry point name: slug (e.g., "acme") → value: import path (e.g., "bengal_themes.acme").

Related Modules:

  • bengal.utils.theme_resolution: Theme inheritance chain resolution
  • bengal.rendering.template_engine: Template engine using theme packages
  • bengal.core.theme: Theme configuration object

See Also:

  • bengal/utils/theme_registry.py: get_theme_package() for theme lookup
  • bengal/utils/theme_registry.py: ThemePackage for theme representation

Classes

ThemePackage dataclass
5

Attributes

Name Type Description
slug str
package str
distribution str | None
version str | None

Methods 5

templates_exists
0 bool
def templates_exists(self) -> bool
Returns

bool

assets_exists
0 bool
def assets_exists(self) -> bool
Returns

bool

manifest_exists
0 bool
def manifest_exists(self) -> bool
Returns

bool

jinja_loader
0 PackageLoader
def jinja_loader(self) -> PackageLoader
Returns

PackageLoader

resolve_resource_path
1 Path | None
def resolve_resource_path(self, relative: str) -> Path | None
Parameters 1
relative str
Returns

Path | None

Functions

get_installed_themes
Discover installed themes via entry points.
0 dict[str, ThemePackage]
def get_installed_themes() -> dict[str, ThemePackage]

Discover installed themes via entry points.

Returns

dict[str, ThemePackage]

Mapping of slug -> ThemePackage

get_theme_package
1 ThemePackage | None
def get_theme_package(slug: str) -> ThemePackage | None

Parameters 1

Name Type Default Description
slug str

Returns

ThemePackage | None

clear_theme_cache
0 None
def clear_theme_cache() -> None