Functions
discover_pages
1
list[PageRoute]
▼
Walk a pages directory and discover all routes.
discover_pages
1
list[PageRoute]
▼
def discover_pages(pages_dir: str | Path) -> list[PageRoute]
Parameters
| Name | Type | Description |
|---|---|---|
pages_dir |
str | Path |
Path to the |
Returns
list[PageRoute]
_walk_directory
7
None
▼
Recursively walk a directory, discovering routes and layouts.
_walk_directory
7
None
▼
def _walk_directory(directory: Path, root: Path, *, url_parts: list[str], layouts: list[LayoutInfo], context_providers: list[ContextProvider], depth: int, routes: list[PageRoute]) -> None
Parameters
| Name | Type | Description |
|---|---|---|
directory |
Path |
Current directory being walked. |
root |
Path |
Root pages directory (for computing template paths). |
url_parts |
list[str] |
URL path segments accumulated so far. |
layouts |
list[LayoutInfo] |
Layout chain accumulated from parent directories. |
context_providers |
list[ContextProvider] |
Context providers from parent directories. |
depth |
int |
Current nesting depth. |
routes |
list[PageRoute] |
Accumulator for discovered routes. |
_parse_layout_target
1
str
▼
Extract the target element ID from a layout template.
Looks for ``{# target: e…
_parse_layout_target
1
str
▼
def _parse_layout_target(layout_file: Path) -> str
Extract the target element ID from a layout template.
Looks for{# target: element_id #}in the template.
Defaults to"body"if not found.
Parameters
| Name | Type | Description |
|---|---|---|
layout_file |
Path |
Returns
str
_load_context_provider
2
ContextProvider | None
▼
Load a context() function from a _context.py file.
Returns None if the module …
_load_context_provider
2
ContextProvider | None
▼
def _load_context_provider(context_file: Path, depth: int) -> ContextProvider | None
Load a context() function from a _context.py file.
Returns None if the module doesn't export acontextfunction.
Parameters
| Name | Type | Description |
|---|---|---|
context_file |
Path |
|
depth |
int |
Returns
ContextProvider | None
_process_route_file
6
None
▼
Load a route .py file and extract handler functions.
``page.py`` maps to the d…
_process_route_file
6
None
▼
def _process_route_file(file: Path, root: Path, *, url_parts: list[str], layout_chain: LayoutChain, context_providers: tuple[ContextProvider, ...], routes: list[PageRoute]) -> None
Load a route .py file and extract handler functions.
page.pymaps to the directory URL. Other files append their
stem to the URL path.
Handler functions are named after HTTP methods:get, post, etc.
Parameters
| Name | Type | Description |
|---|---|---|
file |
Path |
|
root |
Path |
|
url_parts |
list[str] |
|
layout_chain |
LayoutChain |
|
context_providers |
tuple[ContextProvider, ...] |
|
routes |
list[PageRoute] |