diff --git a/.gitignore b/.gitignore index d316ee0..26de413 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ notebooks/*.zarr/ *.sln *.sw? .idea/ + +# Downloaded assets +docs/assets/downloaded/* \ No newline at end of file diff --git a/docs/hooks/download_fonts.py b/docs/hooks/download_fonts.py new file mode 100644 index 0000000..32a7444 --- /dev/null +++ b/docs/hooks/download_fonts.py @@ -0,0 +1,44 @@ +from pathlib import Path +from urllib.error import URLError +from urllib.request import urlretrieve + +ROBOTO_BASE_URL = "https://raw.githubusercontent.com/google/fonts/main/ofl/roboto" + +DOWNLOADS = ( + { + "name": "Roboto.ttf", + "url": f"{ROBOTO_BASE_URL}/Roboto%5Bwdth,wght%5D.ttf", + }, + { + "name": "Roboto-Italic.ttf", + "url": f"{ROBOTO_BASE_URL}/Roboto-Italic%5Bwdth,wght%5D.ttf", + }, + { + "name": "OFL.txt", + "url": f"{ROBOTO_BASE_URL}/OFL.txt", + }, +) + + +def on_config(config): + """Download self-hosted Roboto assets before MkDocs builds the site.""" + docs_dir = Path(config["docs_dir"]) + font_dir = docs_dir / "assets" / "downloaded" / "fonts" + font_dir.mkdir(parents=True, exist_ok=True) + + for item in DOWNLOADS: + target = font_dir / item["name"] + if target.exists(): + continue + + try: + print(f"Downloading Roboto asset: {item['name']}") + urlretrieve(item["url"], target) + except URLError as exc: + raise RuntimeError( + f"Could not download {item['name']} from {item['url']}. " + "Check your network connection or place the file manually in " + f"{font_dir}." + ) from exc + + return config diff --git a/docs/overrides/partials/copyright.html b/docs/overrides/partials/copyright.html new file mode 100644 index 0000000..64cdec3 --- /dev/null +++ b/docs/overrides/partials/copyright.html @@ -0,0 +1,11 @@ + diff --git a/docs/stylesheet/extra.css b/docs/stylesheet/extra.css new file mode 100644 index 0000000..38b6b4c --- /dev/null +++ b/docs/stylesheet/extra.css @@ -0,0 +1,21 @@ +@font-face { + font-family: "Roboto"; + src: url("../assets/downloaded/fonts/Roboto.ttf") format("truetype"); + font-style: normal; + font-weight: 100 900; + font-stretch: 75% 100%; + font-display: swap; +} + +@font-face { + font-family: "Roboto"; + src: url("../assets/downloaded/fonts/Roboto-Italic.ttf") format("truetype"); + font-style: italic; + font-weight: 100 900; + font-stretch: 75% 100%; + font-display: swap; +} + +:root { + --md-text-font: "Roboto", "Segoe UI", Helvetica, Arial, sans-serif; +} diff --git a/mkdocs.yml b/mkdocs.yml index ca30b93..6de0897 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,6 +18,8 @@ theme: name: material # logo: assets/logo.png # favicon: assets/logo-small.png + font: false + custom_dir: docs/overrides palette: # Palette toggle for light mode - scheme: default @@ -41,13 +43,6 @@ markdown_extensions: emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_generator: !!python/name:material.extensions.emoji.to_svg -extra: - social: - - icon: fontawesome/brands/github - link: https://github.com/bcdev/xrlint - - icon: fontawesome/brands/python - link: https://pypi.org/project/xrlint/ - watch: - xrlint @@ -76,3 +71,21 @@ plugins: members_order: source extra: show_overloads: true + +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/bcdev/xrlint + - icon: fontawesome/brands/python + link: https://pypi.org/project/xrlint/ + footer_links: + - text: Imprint + href: https://www.brockmann-consult.de/imprint/ + - text: Privacy Policy + href: https://www.brockmann-consult.de/privacy-policy-documentation-pages/ + +extra_css: + - stylesheet/extra.css + +hooks: + - docs/hooks/download_fonts.py \ No newline at end of file