Classes
VersionResolver
12
▼
Resolves versioned content paths and manages shared content.
This class handles the mapping betwee…
VersionResolver
12
▼
Resolves versioned content paths and manages shared content.
This class handles the mapping between source paths, logical paths, and output paths for versioned documentation. It also manages shared content that appears in all versions.
Responsibilities:
- Determine which version a content path belongs to
- Resolve shared content paths for each version
- Compute output paths with version prefixes
- Handle cross-version content linking
Attributes
| Name | Type | Description |
|---|---|---|
version_config |
— |
Site versioning configuration |
root_path |
— |
Site root directory |
enabled |
— |
Whether versioning is enabled (read-only property) |
Methods
enabled
0
bool
▼
Check if versioning is enabled.
property
enabled
0
bool
▼
def enabled(self) -> bool
Returns
bool
get_version_for_path
1
Version | None
▼
Determine which version a content path belongs to.
**Handles:**
- _versions//*…
get_version_for_path
1
Version | None
▼
def get_version_for_path(self, content_path: Path | str) -> Version | None
Determine which version a content path belongs to.
Handles:
- _versions/
/* paths → maps to specific version - Versioned section paths → maps to latest version
- Non-versioned paths → returns None
Parameters
| Name | Type | Description |
|---|---|---|
content_path |
— |
Path to content file (relative or absolute) |
Returns
Version | None
Version object or None if not versioned
get_logical_path
1
Path
▼
Get the logical path for a versioned content file.
Strips version-specific pre…
get_logical_path
1
Path
▼
def get_logical_path(self, content_path: Path | str) -> Path
Get the logical path for a versioned content file.
Strips version-specific prefixes to get the canonical path.
Parameters
| Name | Type | Description |
|---|---|---|
content_path |
— |
Source content path |
Returns
Path
Logical path without version prefix
get_shared_content_paths
0
list[Path]
▼
Get paths to shared content directories.
Shared content is included in all ver…
get_shared_content_paths
0
list[Path]
▼
def get_shared_content_paths(self) -> list[Path]
Get paths to shared content directories.
Shared content is included in all versions (e.g., common images, reusable snippets, shared partials).
Returns
list[Path]
List of absolute paths to shared content directories
should_include_shared_content
1
bool
▼
Check if shared content should be included for a version.
By default, shared c…
should_include_shared_content
1
bool
▼
def should_include_shared_content(self, version: Version) -> bool
Check if shared content should be included for a version.
By default, shared content is included in all versions. Can be disabled per-version via configuration.
Parameters
| Name | Type | Description |
|---|---|---|
version |
— |
Version to check |
Returns
bool
True if shared content should be included
resolve_cross_version_link
2
str | None
▼
Resolve a cross-version link reference.
Handles links like [[v2:path/to/page]]…
resolve_cross_version_link
2
str | None
▼
def resolve_cross_version_link(self, link_target: str, current_version: Version | None) -> str | None
Resolve a cross-version link reference.
Handles links like [[v2:path/to/page]] or [[latest:path/to/page]].
Parameters
| Name | Type | Description |
|---|---|---|
link_target |
— |
Link target with optional version prefix |
current_version |
— |
Current page's version context |
Returns
str | None
Resolved URL path or None if not a version link
assign_version_to_page
2
▼
Assign version information to a page based on its source path.
Updates page.co…
assign_version_to_page
2
▼
def assign_version_to_page(self, page: Page, source_path: Path) -> None
Assign version information to a page based on its source path.
Updates page.core.version if the page belongs to a versioned section.
Parameters
| Name | Type | Description |
|---|---|---|
page |
— |
Page to update |
source_path |
— |
Source content path |
get_version_url_prefix
1
str
▼
Get the URL prefix for a version.
get_version_url_prefix
1
str
▼
def get_version_url_prefix(self, version: Version | None) -> str
Parameters
| Name | Type | Description |
|---|---|---|
version |
— |
Version object (None for unversioned content) |
Returns
str
URL prefix string (empty for latest, "/v2" for v2, etc.)
Internal Methods 1 ▼
__init__
2
▼
Initialize the version resolver.
__init__
2
▼
def __init__(self, version_config: VersionConfig, root_path: Path) -> None
Parameters
| Name | Type | Description |
|---|---|---|
version_config |
— |
Site versioning configuration |
root_path |
— |
Site root directory |