Files
Aislo/common_util/common_util_help_router.py
T
eomsangdonandClaude Opus 5.5 a1069f270a feat(529-1): 단계 틀 인자(아이콘 · [<][>] 묶음 · 도움말 이름) · D · E 단계 빈 길 일곱
- createWorkflowLayout icons 인자(없으면 B 일곱 아이콘 그대로)
- [?] [<] [>] 묶음 = B05~B09 · D02~D04 · E02~E05 · 묶음 안에서만 오감 · 설명서 이름 B0N/D0N/E0N
- 서버 설명서 주소 D01~D04 · E01~E05 허용 · 우클릭 막기 · 돋보기 d · e 주소
- ROUTES D01~E05 · PLAN_STEP_ROUTES · STAB_STEP_ROUTES · A00_Common/group_workflow(빈 단계 = 틀 · 좌측 [?] 줄 · 단계 막대)
- 페이지 폴더마다 draft/<폴더>_Route.ts · tsconfig 에 D0* · E0* · 문구 ui_template_locale_de
- 시험: 280-2 대역에 D · E 묶음 · 54-2 D · E 설명서 길

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:32:09 +09:00

35 lines
1.3 KiB
Python

"""[?] 설명서 글(54-2) — `resources/help/<페이지>/*.md` 를 부를 때마다 읽어 줌.
사용자가 메모장으로 파일을 고치면 화면 고침 없이 다음에 열 때 바뀐 글이 보임.
파일 이름 순서 = 모달 왼쪽 차례 순서 · 제목 = 첫 `# ` 줄(없으면 파일 이름).
"""
from __future__ import annotations
import re
from pathlib import Path
from fastapi import APIRouter, HTTPException
router = APIRouter(prefix="/api/help", tags=["help"])
HELP_ROOT = Path(__file__).resolve().parent.parent / "resources" / "help"
PAGE_RE = re.compile(r"^(B0[2-9]|D0[1-4]|E0[1-5])$")
def read_help(page: str, root: Path = HELP_ROOT) -> list[dict[str, str]]:
if not PAGE_RE.match(page):
raise HTTPException(status_code=404, detail="없는 페이지")
folder = root / page
items = []
for path in sorted(folder.glob("*.md")) if folder.is_dir() else []:
text = path.read_text(encoding="utf-8-sig")
head = next((line[2:].strip() for line in text.splitlines() if line.startswith("# ")), "")
items.append({"key": path.stem, "title": head or path.stem, "text": text})
return items
@router.get("/{page}")
async def get_help(page: str) -> dict[str, list[dict[str, str]]]:
return {"items": read_help(page)}