Update documentation and scripts for font addition process; introduce uv run add-font CLI command for streamlined font management. Enhance formula generation with improved class name formatting and validation steps. Remove outdated font formula files.
This commit is contained in:
parent
69d8156b09
commit
56b64d0b34
266 changed files with 1187 additions and 8145 deletions
42
tests/test_formula_content.py
Normal file
42
tests/test_formula_content.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"""Tests for formula content: correct paths and valid Ruby class name."""
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import FONT_FILES_DIR, FORMULA_DIR, get_font_dir_names
|
||||
|
||||
|
||||
def formula_name_to_class(formula_name: str) -> str:
|
||||
"""Same logic as generator: formula name to PascalCase (no hyphens)."""
|
||||
parts = re.split(r"[-_]+", formula_name)
|
||||
return "".join(p.capitalize() for p in parts if p)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("font_name", get_font_dir_names())
|
||||
def test_formula_references_correct_font_path(font_name):
|
||||
"""Generated formula contains the correct font_files/font-<name>/ path."""
|
||||
formula_path = FORMULA_DIR / f"{font_name}.rb"
|
||||
content = formula_path.read_text()
|
||||
# Install block should reference this font path
|
||||
assert f"font_files/{font_name}/" in content, (
|
||||
f"{font_name}: formula does not reference font_files/{font_name}/"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("font_name", get_font_dir_names())
|
||||
def test_formula_class_name_valid_and_matches(font_name):
|
||||
"""Formula defines class Font<PascalCase> with no hyphens (valid Ruby)."""
|
||||
formula_path = FORMULA_DIR / f"{font_name}.rb"
|
||||
content = formula_path.read_text()
|
||||
formula_name = font_name.replace("font-", "", 1)
|
||||
expected_class = "Font" + formula_name_to_class(formula_name)
|
||||
# Class line: class FontSomething < Formula
|
||||
match = re.search(r"class\s+(Font\w+)\s+<\s+Formula", content)
|
||||
assert match, f"{font_name}: no 'class Font... < Formula' found"
|
||||
actual_class = match.group(1)
|
||||
assert "-" not in actual_class, (
|
||||
f"{font_name}: Ruby class name must not contain hyphens (got {actual_class})"
|
||||
)
|
||||
assert actual_class == expected_class, (
|
||||
f"{font_name}: expected class {expected_class}, got {actual_class}"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue