mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-17 17:24:03 +02:00
Add documentation site with Zensical framework
Create comprehensive documentation site for adaptive-lighting.nijho.lt: - Add zensical.toml configuration with Material theme (amber/orange) - Create docs_gen.py module for extracting README sections via markers - Add section markers to README.md for content reuse - Create documentation pages: - index.md: Home with features overview - getting-started.md: Installation and quick setup - configuration.md: Auto-generated config options table - services.md: Auto-generated service documentation - automation-examples.md: Real-world automation recipes - troubleshooting.md: Common issues and solutions - see-also.md: External resources and links - advanced/brightness-modes.md: Brightness mode deep dive - advanced/manual-control.md: Manual control system docs - advanced/sleep-mode.md: Sleep mode configuration - Add GitHub Actions workflow for building and deploying to Pages - Add custom CSS with sun-themed styling - Add CNAME for custom domain Uses markdown-code-runner to auto-generate content from code schemas and extract README sections for single-source documentation.
This commit is contained in:
parent
e0f812d406
commit
f5877076ce
18 changed files with 2159 additions and 0 deletions
91
docs/run_markdown_code_runner.py
Normal file
91
docs/run_markdown_code_runner.py
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
#!/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(f" ✓ Success")
|
||||
success_count += 1
|
||||
else:
|
||||
print(f" ✗ 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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue