Module

collections.loader

Collection loader - loads collection definitions from project files.

Discovers and loads collection schemas from the user's collections.py file at the project root.

Functions

load_collections
Load collection definitions from project's collections.py file. Searches for collections.py in the…
2 dict[str, Collectio…
def load_collections(project_root: Path, collection_file: str = 'collections.py') -> dict[str, CollectionConfig[Any]]

Load collection definitions from project's collections.py file.

Searches for collections.py in the project root and loads the collectionsdictionary containing CollectionConfig instances.

Parameters 2

Name Type Default Description
project_root Path

Path to project root directory

collection_file str 'collections.py'

Name of collections file (default: collections.py)

Returns

dict[str, CollectionConfig[Any]]

Dictionary mapping collection names to CollectionConfig instances. Returns empty dict if no collections file found.

get_collection_for_path
Determine which collection a content file belongs to. Matches the file path against collection dir…
3 tuple[str | None, C…
def get_collection_for_path(file_path: Path, content_root: Path, collections: dict[str, CollectionConfig[Any]]) -> tuple[str | None, CollectionConfig[Any] | None]

Determine which collection a content file belongs to.

Matches the file path against collection directories to find the applicable collection.

Parameters 3

Name Type Default Description
file_path Path

Path to content file

content_root Path

Root content directory

collections dict[str, CollectionConfig[Any]]

Dictionary of loaded collections

Returns

tuple[str | None, CollectionConfig[Any] | None]

Tuple of (collection_name, CollectionConfig) if file is in a collection, or (None, None) if file doesn't belong to any collection.

validate_collections_config
Validate collection configurations. Checks that collection directories exist and are valid.
2 list[str]
def validate_collections_config(collections: dict[str, CollectionConfig[Any]], content_root: Path) -> list[str]

Validate collection configurations.

Checks that collection directories exist and are valid.

Parameters 2

Name Type Default Description
collections dict[str, CollectionConfig[Any]]

Dictionary of loaded collections

content_root Path

Root content directory

Returns

list[str]

List of warning messages for invalid configurations.