Skip to content

Discovery & Assets

File discovery for .pjx templates and the registry-wide asset listing used by build tooling.

Internal modules

Nothing on this page is part of the public API — none of it appears in pyjinhx.__all__, and the module paths may change. It is documented because build scripts have no public equivalent today.

walk_templates

def walk_templates(template_dir: Path | str) -> Iterator[TemplateCandidate]

The .pjx files under template_dir, nested ones included, sorted by path. See Template Discovery for the full description and TemplateCandidate fields.

build_registry

def build_registry(template_dir: Path | str | None, classes: Iterable[type]) -> None

Walk template_dir and publish a fresh tag → class registry. See Template Discovery.

get_class

def get_class(tag_name: str) -> type | None

The component class registered for tag_name, or None. See Template Discovery.

register_class

def register_class(tag_name: str, cls: type) -> None

Publish cls under tag_name unless the tag already has an owner. The one way a tag is claimed after the import-time build — used by component() to register a classless wrapper on demand. A tag that is already owned is left alone: a class registered this way never shadows a declared one; the loser is logged, not silently dropped.

get_template_dir

def get_template_dir() -> Path | None

The directory the last successful build_registry walked, or None if it hasn't run yet.

all_assets

def all_assets() -> tuple[tuple[Path, ...], tuple[Path, ...]]

Every CSS and JS path declared by any component class, registry-wide rather than session-scoped: a class contributes its assets whether or not it was rendered. Only classes imported by the time of the call are visible — import the component package before calling this from a build script.

Returns: The CSS paths then the JS paths, each deduped and in path-sorted order so repeated calls and repeated builds agree byte for byte.

from pyjinhx.assets import all_assets

css_paths, js_paths = all_assets()

See also Assets API for the per-request asset emission functions.