diff --git a/server.py b/server.py index 3efac70..b178bd6 100644 --- a/server.py +++ b/server.py @@ -612,7 +612,7 @@ def render_home_html(actor_id: Optional[str] = None) -> str: Recipes Media Storage - API Docs + API {user_section} @@ -6443,190 +6443,6 @@ async def download_client(): ) -# ============================================================================ -# Documentation Routes -# ============================================================================ - -# Documentation paths -DOCS_DIR = Path(__file__).parent -COMMON_DOCS_DIR = Path(__file__).parent.parent / "common" - -DOCS_MAP = { - "l1": DOCS_DIR / "README.md", - "common": COMMON_DOCS_DIR / "README.md", -} - - -def render_markdown(content: str) -> str: - """Convert markdown to HTML with basic styling.""" - import re - - # Escape HTML first - content = content.replace("&", "&").replace("<", "<").replace(">", ">") - - # Code blocks (``` ... ```) - def code_block_replace(match): - lang = match.group(1) or "" - code = match.group(2) - return f'
{code}
' - content = re.sub(r'```(\w*)\n(.*?)```', code_block_replace, content, flags=re.DOTALL) - - # Inline code - content = re.sub(r'`([^`]+)`', r'\1', content) - - # Headers - content = re.sub(r'^### (.+)$', r'

\1

', content, flags=re.MULTILINE) - content = re.sub(r'^## (.+)$', r'

\1

', content, flags=re.MULTILINE) - content = re.sub(r'^# (.+)$', r'

\1

', content, flags=re.MULTILINE) - - # Bold and italic - content = re.sub(r'\*\*([^*]+)\*\*', r'\1', content) - content = re.sub(r'\*([^*]+)\*', r'\1', content) - - # Links - content = re.sub(r'\[([^\]]+)\]\(([^)]+)\)', r'\1', content) - - # Tables - def table_replace(match): - lines = match.group(0).strip().split('\n') - if len(lines) < 2: - return match.group(0) - - header = lines[0] - rows = lines[2:] if len(lines) > 2 else [] - - header_cells = [cell.strip() for cell in header.split('|')[1:-1]] - header_html = ''.join(f'{cell}' for cell in header_cells) - - rows_html = '' - for row in rows: - cells = [cell.strip() for cell in row.split('|')[1:-1]] - cells_html = ''.join(f'{cell}' for cell in cells) - rows_html += f'{cells_html}' - - return f'{header_html}{rows_html}
' - - content = re.sub(r'(\|[^\n]+\|\n)+', table_replace, content) - - # Bullet points - content = re.sub(r'^- (.+)$', r'
  • \1
  • ', content, flags=re.MULTILINE) - content = re.sub(r'(]*>.*\n?)+', r'', content) - - # Paragraphs (lines not starting with < or whitespace) - lines = content.split('\n') - result = [] - in_paragraph = False - for line in lines: - stripped = line.strip() - if not stripped: - if in_paragraph: - result.append('

    ') - in_paragraph = False - result.append('') - elif stripped.startswith('<'): - if in_paragraph: - result.append('

    ') - in_paragraph = False - result.append(line) - else: - if not in_paragraph: - result.append('

    ') - in_paragraph = True - result.append(line) - if in_paragraph: - result.append('

    ') - content = '\n'.join(result) - - return content - - -@app.get("/docs", response_class=HTMLResponse) -async def docs_index(request: Request): - """Documentation index page.""" - user = await get_optional_user(request) - - html = f""" - - - Documentation - Art DAG L1 - - - - - -
    -

    Documentation

    - -
    - -""" - return HTMLResponse(html) - - -@app.get("/docs/{doc_name}", response_class=HTMLResponse) -async def docs_page(doc_name: str, request: Request): - """Render a markdown documentation file as HTML.""" - if doc_name not in DOCS_MAP: - raise HTTPException(404, f"Documentation '{doc_name}' not found") - - doc_path = DOCS_MAP[doc_name] - if not doc_path.exists(): - raise HTTPException(404, f"Documentation file not found: {doc_path}") - - content = doc_path.read_text() - html_content = render_markdown(content) - - html = f""" - - - {doc_name.upper()} - Art DAG Documentation - - - - - -
    - -
    - {html_content} -
    -
    - -""" - return HTMLResponse(html) - - # ============================================================================ # 3-Phase Execution API (Analyze → Plan → Execute) # ============================================================================