From c9c4a340fdc9b41e5dc9e3d9cc69ccfda552b821 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 11 Jan 2026 11:21:16 +0000 Subject: [PATCH] Remove redundant documentation UI routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /docs now correctly points to FastAPI's Swagger API docs. README files can be viewed directly in the git repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- server.py | 184 ------------------------------------------------------ 1 file changed, 184 deletions(-) diff --git a/server.py b/server.py index 723399f..5bd30eb 100644 --- a/server.py +++ b/server.py @@ -3682,190 +3682,6 @@ async def download_client(): ) -# ============================================================================ -# Documentation Routes -# ============================================================================ - -# Documentation paths -L2_DOCS_DIR = Path(__file__).parent -COMMON_DOCS_DIR = Path(__file__).parent.parent / "common" - -L2_DOCS_MAP = { - "l2": L2_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'
      \g<0>
    ', 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 L2 - - - - - -
    -

    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 L2_DOCS_MAP: - raise HTTPException(404, f"Documentation '{doc_name}' not found") - - doc_path = L2_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) - - if __name__ == "__main__": import uvicorn uvicorn.run("server:app", host="0.0.0.0", port=8200, workers=4)