Functions
register
Register cross-reference functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register cross-reference functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
ref
Generate cross-reference link to a page or heading.
O(1) lookup - zero performance impact!
ref
def ref(path: str, index: dict[str, Any], baseurl: str = '', text: str | None = None) -> Markup
Generate cross-reference link to a page or heading.
O(1) lookup - zero performance impact!
Parameters 4
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Path to reference ('docs/installation', 'id:my-page', or slug) |
index |
dict[str, Any] |
— | Cross-reference index from site |
baseurl |
str |
'' |
|
text |
str | None |
None |
Optional custom link text (defaults to page title) |
Returns
Safe HTML link or broken reference indicatorMarkup
—
doc
Get page object by path.
O(1) lookup - zero performance impact!
Useful for accessing page metadata…
doc
def doc(path: str, index: dict[str, Any]) -> Page | None
Get page object by path.
O(1) lookup - zero performance impact! Useful for accessing page metadata in templates.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Path to page ('docs/installation', 'id:my-page', or slug) |
index |
dict[str, Any] |
— | Cross-reference index from site |
Returns
Page object or None if not foundPage | None
—
anchor
Link to a heading (anchor) in a page.
anchor
def anchor(heading: str, index: dict[str, Any], baseurl: str = '', page_path: str | None = None) -> Markup
Link to a heading (anchor) in a page.
Parameters 4
| Name | Type | Default | Description |
|---|---|---|---|
heading |
str |
— | Heading text to link to |
index |
dict[str, Any] |
— | Cross-reference index from site |
baseurl |
str |
'' |
|
page_path |
str | None |
None |
Optional page path to restrict search (default: search all) |
Returns
Safe HTML link to heading or broken reference indicatorMarkup
—
relref
Get relative URL for a page.
Returns just the URL without generating a full link.
Useful for custo…
relref
def relref(path: str, index: dict[str, Any], baseurl: str = '') -> str
Get relative URL for a page.
Returns just the URL without generating a full link. Useful for custom link generation.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Path to page |
index |
dict[str, Any] |
— | Cross-reference index from site |
baseurl |
str |
'' |
Returns
URL string or empty string if not foundstr
—