yera 0.11.1

yera.ui.apps_sidebar

Build and render the source-oriented app navigation tree.

Stable app IDs are separated into directory, Python-file, and app-function nodes. Directory-only chains are compacted without removing file ownership. Rendering escapes labels and app names, URL-encodes destinations, and preserves the selected app and default expansion state.

Symbols

def app_icon — Render the escaped initial badge used for an app.
class AppTreeFile — Describe a Python source file containing app functions.
class AppTreeFolder — Describe a directory containing app folders or source files.
class AppTreeLeaf — Describe a selectable app function inside a source file.
def build_app_tree — Build source-oriented navigation from stable app identifiers.
def render_app_tree — Render app navigation as nested folders, files, and runnable leaves.

app_icon

app_icon(
    app_id: str,
    app: AppReference,
) → str

Render the escaped initial badge used for an app.

Parameters

app_id
type: str

Stable identifier used to choose the badge colour.

app
type: AppReference

App reference supplying the user-facing name.

Returns

type: str

An HTML badge whose displayed initial is escaped.

AppTreeFile

Describe a Python source file containing app functions.

Fields

label
type: str (required)

Display filename including its .py suffix.

count
type: int (required)

Number of app leaves beneath the file.

children
type: list[yera.ui.apps_sidebar.AppTreeLeaf] (required)

App functions sorted by function name.

Methods


AppTreeFile.__init__

__init__(
    label: str,
    count: int,
    children: list[AppTreeLeaf],
) → None

AppTreeFolder

Describe a directory containing app folders or source files.

Fields

label
type: str (required)

Directory label, including compacted path segments.

count
type: int (required)

Number of app leaves beneath the directory.

children
type: list[yera.ui.apps_sidebar.AppTreeFolder | yera.ui.apps_sidebar.AppTreeFile] (required)

Nested folders and source files in display order.

Methods


AppTreeFolder.__init__

__init__(
    label: str,
    count: int,
    children: list[AppTreeFolder | AppTreeFile],
) → None

AppTreeLeaf

Describe a selectable app function inside a source file.

Fields

app_id
type: str (required)

Stable slash-delimited app identifier.

app
type: yera.apps.reference.AppReference (required)

App metadata and callable reference.

function_name
type: str (required)

Source-level function name shown beneath the file.

Methods


AppTreeLeaf.__init__

__init__(
    app_id: str,
    app: AppReference,
    function_name: str,
) → None

build_app_tree

build_app_tree(
    apps: Mapping[str, AppReference],
) → list[AppTreeFolder | AppTreeFile]

Build source-oriented navigation from stable app identifiers.

Normal app IDs are interpreted as directory segments followed by a Python module and function. Custom single-segment IDs fall back to app metadata for their file label. Directories and files are sorted, function leaves are sorted by name, and directory-only chains are compacted.

Parameters

apps
type: Mapping[str, AppReference]

Available applications keyed by their stable identifiers.

Returns

type: list[AppTreeFolder | AppTreeFile]

Ordered folder and file nodes containing every supplied app.

render_app_tree

render_app_tree(
    nodes: Sequence[AppTreeLeaf | AppTreeFolder | AppTreeFile],
    depth: int = 0,
    selected_app_id: str | None = None,
) → str

Render app navigation as nested folders, files, and runnable leaves.

Folder expansion is based on nesting depth. Selection links use canonical app URLs, while each leaf also provides an HTMX action that creates a session. Labels, names, accessible text, and URL attributes are escaped.

Parameters

nodes
type: Sequence[AppTreeLeaf | AppTreeFolder | AppTreeFile]

Tree nodes at the current level.

depth
type: int = 0

Current nesting depth, used only for default folder expansion.

selected_app_id
type: str | None = None

App identifier marked as the current selection.

Returns

type: str

HTML for the app tree at this level and all descendants.