1 min read
pyssg.config
Site configuration loading.
Configuration is expressed as Python code in a pyssg.config.py file at the
site root, rather than as YAML/TOML. Code lets the user compose plugin instances
and arbitrary template variables with full type checking, which is the whole
point of the design: the basic user only ever touches this file plus a layout
package.
The file MUST expose a module-level config bound to a :class:Config
instance. Loading is deterministic and side-effect free with respect to this
module: we import the file fresh each call and read back the variable, holding no
global mutable state.
class Config
Resolved site configuration.
Directory fields are relative to the site directory; the engine joins them
against the site root when it runs. plugins order is the apply order.
site holds arbitrary template variables (title, etc.).
layout is either a str path relative to the site directory, or an
absolute :class:~pathlib.Path (e.g. a built-in theme; see
:func:pyssg.themes.theme_path) used as-is.
load_config(site_dir: Path) -> Config
Load and validate the pyssg.config.py found in site_dir.
Raises :class:ConfigError if the file is missing, does not export a
config variable, or that variable is not a :class:Config instance.