Skip to content

Commit

Permalink
chore(docs): fail on non-existing font directory
Browse files Browse the repository at this point in the history
This avoids silent breakages on changes like #13093.
  • Loading branch information
nijel committed Nov 25, 2024
1 parent 1663f8d commit 425131e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
# -- Path setup --------------------------------------------------------------

file_dir = Path(__file__).parent.resolve()
font_locations = (
"weblate/static/vendor/font-source/TTF/",
"weblate/static/vendor/font-kurinto/",
)

weblate_dir = file_dir.parent
# Our extension
sys.path.append(str(file_dir / "_ext"))
Expand All @@ -39,13 +44,15 @@ def setup(app) -> None:
indextemplate="pair: %s; configuration value",
)

font_dirs = [
str(weblate_dir / font_dir)
for font_dir in (
"weblate/static/vendor/font-source/TTF/",
"weblate/static/vendor/font-kurinto/",
)
]
font_dirs: list[str] = []

for font_location in font_locations:
font_dir = weblate_dir / font_location
if not font_dir.is_dir():
msg = f"Font directory not found: {font_dir}"
raise NotADirectoryError(msg)
font_dirs.append(str(font_dir))

font_files = font_manager.findSystemFonts(fontpaths=font_dirs)

for font_file in font_files:
Expand Down

0 comments on commit 425131e

Please sign in to comment.