Remove HTML-to-Markdown parser and PDF generation functionality, clean up unused imports and whitespace

This commit is contained in:
2025-12-14 20:42:02 -05:00
parent 8db38ca75e
commit 6c83ada7d1
11 changed files with 969 additions and 1578 deletions
+23 -9
View File
@@ -1,30 +1,46 @@
"""
Routes API pour l'aide et la documentation.
Source unique: app/static/help.md
"""
from pathlib import Path
from fastapi import APIRouter, Depends
from fastapi.responses import Response
from fastapi.responses import JSONResponse, 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.help_renderer import render_help_page, get_raw_markdown
from app.utils.pdf_generator import markdown_to_pdf_bytes
router = APIRouter()
# Chemin vers le fichier source Markdown
HELP_MD_PATH = settings.base_dir / "static" / "help.md"
@router.get("/content")
async def get_help_content(api_key_valid: bool = Depends(verify_api_key)):
"""
Retourne le contenu HTML de la page d'aide généré depuis help.md.
Utilisé pour le chargement dynamique de la page d'aide.
"""
html_content, toc_html = render_help_page(HELP_MD_PATH)
return JSONResponse({
"content": html_content,
"toc": toc_html
})
@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)
markdown_content = get_raw_markdown(HELP_MD_PATH)
return Response(
content=markdown_content,
media_type="text/markdown",
media_type="text/markdown; charset=utf-8",
headers={
"Content-Disposition": "attachment; filename=homelab-automation-help.md"
}
@@ -34,9 +50,7 @@ async def download_help_markdown(api_key_valid: bool = Depends(verify_api_key)):
@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)
markdown_content = get_raw_markdown(HELP_MD_PATH)
pdf_bytes = markdown_to_pdf_bytes(
markdown_content,