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.

clew/wiki/theme.py:41

Show on the map →

Called by _render

Tested by

1 teststest_another_installed_theme_can_be_named

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

Activity · 15 steps
lines 48–48static = Path(source) / "_static"lines 49–49static.mkdir(parents=True, exist_ok=True)lines 50–50settings: dict[str, Any] = {"html_theme": spec.name, "html_static_path": ["_static"]}lines 51–51css: list[str] = []lines 52–52◇ if spec.name == "clew"lines 53–53settings["html_theme_path"] = [str(THEMES)]lines 54–54css += _clew_assets(spec, static)lines 55–55◇ for rel in spec.csslines 56–56shutil.copyfile(Path(repo_root) / rel, static / Path(rel).name)lines 57–57css.append(Path(rel).name)lines 58–58◇ if spec.logolines 59–59shutil.copyfile(Path(repo_root) / spec.logo, static / Path(spec.logo).name)lines 60–60settings["html_logo"] = f"_static/{Path(spec.logo).name}"lines 61–61settings["html_css_files"] = csslines 62–62return settings

Requirements

REQ-DDB-WIKI-011