# API Reference This section provides detailed API documentation for tdom-path. ## Core Functions ### make_traversable ```python from typing import Any from importlib.resources.abc import Traversable def make_traversable(component: Any, asset: str) -> Traversable: ... ``` Create path to asset resource as a Traversable instance. Supports two path formats: 1. **Package paths:** `"package:resource/path"` (e.g., `"mypackage:static/styles.css"`) - Resolves using `importlib.resources.files()` to access package resources - Works with any installed package - Component parameter is ignored for package paths 2. **Relative paths:** `"resource/path"` or `"./resource/path"` or `"../resource/path"` - Resolved relative to the component's module - Uses the component's `__module__` attribute to determine the base location - Component parameter is required (must have `__module__`) Path type detection is automatic based on presence of colon (`:`) character. **Parameters:** - `component`: Python object with `__module__` attribute (class, function, instance, etc.) For package paths, this parameter is ignored and can be None. - `asset`: Path to the asset. Can be: - Package path: `"package:resource/path"` - Relative path: `"resource/path"`, `"./resource/path"`, or `"../resource/path"` **Returns:** - `Traversable` instance representing the resource location **Raises:** - `TypeError`: If component doesn't have `__module__` attribute (relative paths only) - `ModuleNotFoundError`: If a package path references a non-existent package - `ImportError`: If there's an issue importing a package **Examples:** ```python >>> from tdom_path import make_traversable >>> # Package path - access asset from installed package >>> pkg_path = make_traversable(None, "mypackage:static/styles.css") # doctest: +SKIP >>> # Relative path - access local component asset >>> from mysite.components.heading import Heading >>> css_path = make_traversable(Heading, "static/styles.css") >>> # With ./ prefix >>> css_path = make_traversable(Heading, "./static/styles.css") >>> # Parent directory >>> shared_path = make_traversable(Heading, "../shared/common.css") # doctest: +SKIP ``` ### make_path_nodes ```python from typing import Any from importlib.resources.abc import Traversable from tdom import Node def make_path_nodes(target: Node, component: Any) -> Node: ... ``` Rewrite asset-bearing attributes in a tdom tree to use make_path. Walks the Node tree and detects elements with static asset references (`` and `