- extract_ts.mjs — 함수(kind · exported · doc · params · returns · calls · called_by · 다시 내보내기) · 세션 칸 · 서버 주소 글자 · 계산 등록부 그대로 - extract_py.py — def 전부 · docstring 첫 줄 · 부르는 함수 · FastAPI 라우트 데코레이터 - extract_api.py — 서버 안 켜고 openapi 주소 → handler · TS 부르는 곳 짝 · 짝 없는 것 따로 - 범위 = scope.json 한 곳 · 세는 규칙 = README · 시험 test_478_extract(6) - 수치 = 함수 5746 · 세션 칸 45 · 서버 주소 41 · 등록부 45 · 14.3 s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""docs/tools/extract_all.py — 추출 한 명령(PLAN 478-1).
|
|
|
|
TS → 파이썬 → 서버 주소 차례로 돌리고 함수 둘을 `docs/_data/functions.json` 한 벌로 합침 ·
|
|
걸린 시간 출력. 부르기: `./venv/Scripts/python.exe docs/tools/extract_all.py`
|
|
(ts-morph = `npm --prefix docs/tools install`).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
TOOLS = ROOT / "docs/tools"
|
|
DATA = ROOT / "docs/_data"
|
|
STEPS = [
|
|
("ts", ["node", str(TOOLS / "extract_ts.mjs")]),
|
|
("py", [sys.executable, str(TOOLS / "extract_py.py")]),
|
|
("api", [sys.executable, "-W", "ignore", str(TOOLS / "extract_api.py")]),
|
|
]
|
|
|
|
|
|
def load(name: str):
|
|
return json.loads((DATA / name).read_text(encoding="utf-8"))
|
|
|
|
|
|
def main() -> None:
|
|
start = time.perf_counter()
|
|
for name, cmd in STEPS:
|
|
t = time.perf_counter()
|
|
subprocess.run(cmd, cwd=ROOT, check=True) # noqa: S603 — 고정 명령
|
|
print(f" {name} {time.perf_counter() - t:.1f} s")
|
|
functions = sorted(
|
|
load("raw/functions_ts.json") + load("raw/functions_py.json"), key=lambda f: f["id"]
|
|
)
|
|
(DATA / "functions.json").write_text(
|
|
json.dumps(functions, ensure_ascii=False, indent=1) + "\n", encoding="utf-8"
|
|
)
|
|
print(
|
|
f"함수 {len(functions)} · 세션 칸 {len(load('session_keys.json'))} · "
|
|
f"서버 주소 {len(load('api.json'))} · 등록부 {len(load('registry.json'))} · "
|
|
f"모두 {time.perf_counter() - start:.1f} s"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|