diff --git a/.gitignore b/.gitignore index a0aa6e66fc..a4673554d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ resources/test/cpython docs/ mkdocs.yml +.overrides ### # Rust.gitignore diff --git a/mkdocs.template.yml b/mkdocs.template.yml index fb466206c0..d73d5b6205 100644 --- a/mkdocs.template.yml +++ b/mkdocs.template.yml @@ -23,6 +23,7 @@ theme: toggle: icon: material/weather-night name: Switch to light mode + custom_dir: .overrides repo_url: https://github.com/charliermarsh/ruff repo_name: ruff site_author: charliermarsh diff --git a/scripts/generate_mkdocs.py b/scripts/generate_mkdocs.py index b303e72519..b100b0dcd3 100644 --- a/scripts/generate_mkdocs.py +++ b/scripts/generate_mkdocs.py @@ -19,6 +19,11 @@ DOCUMENTATION_LINK: str = ( "This README is also available as [documentation](https://beta.ruff.rs/docs/)." ) +FATHOM_SCRIPT: str = ( + '" +) + def main() -> None: """Generate an MkDocs-compatible `docs` and `mkdocs.yml`.""" @@ -34,7 +39,7 @@ def main() -> None: Path("docs").mkdir(parents=True, exist_ok=True) # Split the README.md into sections. - for (title, filename) in SECTIONS: + for title, filename in SECTIONS: with Path(f"docs/{filename}").open("w+") as f: block = content.split(f"") if len(block) != 2: @@ -64,6 +69,11 @@ def main() -> None: {"FAQ": "faq.md"}, {"Contributing": "contributing.md"}, ] + config["extra"] = {"analytics": {"provider": "fathom"}} + + Path(".overrides/partials/integrations/analytics").mkdir(parents=True, exist_ok=True) + with Path(".overrides/partials/integrations/analytics/fathom.html").open("w+") as fp: + fp.write(FATHOM_SCRIPT) with Path("mkdocs.yml").open("w+") as fp: yaml.safe_dump(config, fp)