""" Routes API pour l'aide et la documentation. """ from pathlib import Path from fastapi import APIRouter, Depends from fastapi.responses import Response from app.core.config import settings from app.core.dependencies import verify_api_key from app.utils.markdown_parser import build_help_markdown from app.utils.pdf_generator import markdown_to_pdf_bytes router = APIRouter() @router.get("/documentation.md") async def download_help_markdown(api_key_valid: bool = Depends(verify_api_key)): """Télécharge la documentation d'aide en format Markdown.""" # Essayer de charger depuis index.html html_path = settings.base_dir / "index.html" markdown_content = build_help_markdown(html_path=html_path) return Response( content=markdown_content, media_type="text/markdown", headers={ "Content-Disposition": "attachment; filename=homelab-automation-help.md" } ) @router.get("/documentation.pdf") async def download_help_pdf(api_key_valid: bool = Depends(verify_api_key)): """Télécharge la documentation d'aide en format PDF.""" # Essayer de charger depuis index.html html_path = settings.base_dir / "index.html" markdown_content = build_help_markdown(html_path=html_path) pdf_bytes = markdown_to_pdf_bytes( markdown_content, title="Homelab Automation - Documentation" ) return Response( content=pdf_bytes, media_type="application/pdf", headers={ "Content-Disposition": "attachment; filename=homelab-automation-help.pdf" } )