theme.py¶
clew/wiki/theme.py
The site's theme: clew's default (the sassafras-class look) or any installed Sphinx theme.
sphinx_settings
dict[str, Any] clew.wiki.theme.sphinx_settings(ThemeSpec spec, Path repo_root, Path source)
The conf.py settings for a theme, its static files copied into the source tree.
Called by _render
Tested by
Calls _clew_assets
Source · 24 lines
def sphinx_settings(spec: ThemeSpec, repo_root: Path, source: Path) -> dict[str, Any]:
"""A NAMED THEME IS TAKEN AS IT IS: its own look, the repository's extra stylesheets and logo
only. The palette and fonts belong to clew's theme and are not forced onto another.
@brief Build theme settings.
@return Settings.
"""
static = Path(source) / "_static"
static.mkdir(parents=True, exist_ok=True)
settings: dict[str, Any] = {"html_theme": spec.name, "html_static_path": ["_static"]}
css: list[str] = []
if spec.name == "clew":
settings["html_theme_path"] = [str(THEMES)]
css += _clew_assets(spec, static)
for rel in spec.css:
shutil.copyfile(Path(repo_root) / rel, static / Path(rel).name)
css.append(Path(rel).name)
if spec.logo:
shutil.copyfile(Path(repo_root) / spec.logo, static / Path(spec.logo).name)
settings["html_logo"] = f"_static/{Path(spec.logo).name}"
settings["html_css_files"] = css
return settings