Functions
_get_icons_directory
Get the icons directory from the default theme.
_get_icons_directory
def _get_icons_directory() -> Path
Get the icons directory from the default theme.
Returns
Path
_load_icon
Load an icon SVG by name (with caching).
_load_icon
def _load_icon(name: str) -> str | None
Load an icon SVG by name (with caching).
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Icon name (without .svg extension) |
Returns
SVG content string, or None if not foundstr | None
—
get_icon_svg
Get raw SVG content for an icon.
get_icon_svg
def get_icon_svg(name: str) -> str | None
Get raw SVG content for an icon.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Icon name (e.g., "terminal", "search", "info") |
Returns
Raw SVG string, or None if not foundstr | None
—
_escape_attr
Escape HTML attribute value.
_escape_attr
def _escape_attr(value: str) -> str
Escape HTML attribute value.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
value |
str |
— |
Returns
str
render_svg_icon
Render an SVG icon for use in directives.
Uses LRU caching to avoid repeated regex processing for …
render_svg_icon
def render_svg_icon(name: str, size: int = 20, css_class: str = '', aria_label: str = '') -> str
Render an SVG icon for use in directives.
Uses LRU caching to avoid repeated regex processing for identical icon render calls. Typical hit rate >95% for navigation icons.
Applies ICON_MAP to resolve semantic names (e.g., "alert" -> "warning") before loading the icon file.
Parameters 4
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Icon name (e.g., "terminal", "search", "info", "alert") |
size |
int |
20 |
Icon size in pixels (default: 20) |
css_class |
str |
'' |
Additional CSS classes |
aria_label |
str |
'' |
Accessibility label |
Returns
Inline SVG HTML string, or empty string if icon not foundstr
—
render_icon
Render an icon by name, preferring Phosphor SVG icons.
This function maps common icon names to Pho…
render_icon
def render_icon(name: str, size: int = 20) -> str
Render an icon by name, preferring Phosphor SVG icons.
This function maps common icon names to Phosphor icons and always attempts to render SVG first. Only returns empty string if icon not found.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Icon name (semantic name like "book", "rocket", etc.) |
size |
int |
20 |
Icon size in pixels |
Returns
HTML for icon (SVG only, empty string if not found)str
—
clear_icon_cache
Clear both the raw icon cache and the render cache.
Useful for testing or when icons are modified …
clear_icon_cache
def clear_icon_cache() -> None
Clear both the raw icon cache and the render cache.
Useful for testing or when icons are modified during development.
icon_exists
Check if an icon exists in the icon library.
This checks both direct icon names and mapped names f…
icon_exists
def icon_exists(name: str) -> bool
Check if an icon exists in the icon library.
This checks both direct icon names and mapped names from ICON_MAP.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Icon name to check |
Returns
True if icon exists, False otherwisebool
—
warn_missing_icon
Log a warning for a missing icon with helpful context.
This centralizes icon warning logic so all …
warn_missing_icon
def warn_missing_icon(icon_name: str, directive: str = '', context: str = '') -> None
Log a warning for a missing icon with helpful context.
This centralizes icon warning logic so all directives can use it without duplicating code.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
icon_name |
str |
— | The icon name that was not found |
directive |
str |
'' |
Name of the directive using the icon (e.g., "dropdown", "card") |
context |
str |
'' |
Additional context like element title for locating the issue |
get_available_icons
Get list of all available icon names.
Returns both the raw icon file names and the semantic aliase…
get_available_icons
def get_available_icons() -> list[str]
Get list of all available icon names.
Returns both the raw icon file names and the semantic aliases from ICON_MAP.
Returns
Sorted list of available icon nameslist[str]
—