Fix pre-commit and CI issues

- Add site_name to zensical.toml (required by MkDocs)
- Fix RET504 in docs_gen.py (unnecessary assignment before return)
- Remove docs/run_markdown_code_runner.py (lint issues, not needed for CI)
This commit is contained in:
Bas Nijholt 2026-01-12 10:48:43 -08:00
commit ee78670aa2
3 changed files with 2 additions and 98 deletions

View file

@ -84,9 +84,7 @@ def transform_readme_links(content: str) -> str:
content = content.replace(f"]({old_link})", f"]({new_link})")
# Also handle the ToC link pattern [[ToC](#...)]
content = re.sub(r"\[\[ToC\]\([^)]+\)\]", "", content)
return content
return re.sub(r"\[\[ToC\]\([^)]+\)\]", "", content)
def get_feature_list() -> str:

View file

@ -1,95 +0,0 @@
#!/usr/bin/env python3
"""Run markdown-code-runner on all documentation files.
This script processes all Markdown files in the docs/ directory that contain
CODE blocks, executing them and updating the OUTPUT sections.
Usage:
python docs/run_markdown_code_runner.py
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
# Add the custom_components to the path for imports
REPO_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(REPO_ROOT / "custom_components"))
sys.path.insert(0, str(REPO_ROOT))
def find_markdown_files() -> list[Path]:
"""Find all Markdown files in the docs directory."""
docs_dir = REPO_ROOT / "docs"
return list(docs_dir.rglob("*.md"))
def has_code_blocks(file_path: Path) -> bool:
"""Check if a Markdown file has CODE blocks."""
content = file_path.read_text()
return (
"<!-- CODE:START -->" in content or "```python markdown-code-runner" in content
)
def run_markdown_code_runner(file_path: Path) -> bool:
"""Run markdown-code-runner on a single file."""
try:
result = subprocess.run(
["markdown-code-runner", str(file_path)],
capture_output=True,
text=True,
check=True,
env={
**subprocess.os.environ,
"PYTHONPATH": f"{REPO_ROOT / 'custom_components'}:{REPO_ROOT}",
},
)
return True
except subprocess.CalledProcessError as e:
print(f" Error: {e.stderr}")
return False
except FileNotFoundError:
print(
" Error: markdown-code-runner not found. Install with: pip install markdown-code-runner",
)
return False
def main() -> int:
"""Process all Markdown files with CODE blocks."""
print("Finding Markdown files with CODE blocks...")
markdown_files = find_markdown_files()
files_with_code = [f for f in markdown_files if has_code_blocks(f)]
if not files_with_code:
print("No files with CODE blocks found.")
return 0
print(f"Found {len(files_with_code)} files with CODE blocks:")
success_count = 0
failure_count = 0
for file_path in sorted(files_with_code):
relative_path = file_path.relative_to(REPO_ROOT)
print(f"\nProcessing {relative_path}...")
if run_markdown_code_runner(file_path):
print(" ✓ Success")
success_count += 1
else:
print(" ✗ Failed")
failure_count += 1
print(f"\n{'='*50}")
print(f"Results: {success_count} succeeded, {failure_count} failed")
return 1 if failure_count > 0 else 0
if __name__ == "__main__":
sys.exit(main())

View file

@ -3,6 +3,7 @@
[project]
name = "Adaptive Lighting"
site_name = "Adaptive Lighting"
site_url = "https://adaptive-lighting.nijho.lt"
repo_url = "https://github.com/basnijholt/adaptive-lighting"
repo_name = "basnijholt/adaptive-lighting"