Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ notebooks/*.zarr/
*.sln
*.sw?
.idea/

# Downloaded assets
docs/assets/downloaded/*
44 changes: 44 additions & 0 deletions docs/hooks/download_fonts.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions docs/overrides/partials/copyright.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="md-copyright">
{% if config.copyright %}
<div class="md-copyright__highlight">
{{ config.copyright }}
{% for link in config.extra.footer_links %}
&nbsp;&nbsp;&nbsp;
<a href="{{ link.href }}" rel="noopener">{{ link.text }}</a>
{% endfor %}
</div>
{% endif %}
</div>
21 changes: 21 additions & 0 deletions docs/stylesheet/extra.css
Original file line number Diff line number Diff line change
@@ -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;
}
27 changes: 20 additions & 7 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Loading