GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: v0.5.0 S2 — MCP view 도구 (to_markdown / to_html) 추가 · DanMeon/rhwp-python@aa73bb9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs
    • implementation/v0.5.0/stages
      • stage-2.md
    • traces
      • coverage.md
  • python/rhwp/mcp
    • server.py
    • tools.py
  • tests
    • test_mcp_server.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/implementation/v0.5.0/stages/stage-2.md‎

Copy file name to clipboard
+94Lines changed: 94 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
status: Frozen
3+
description: "v0.5.0 S2 작업 로그 — view 도구 추가 (to_markdown / to_html). v0.4.0 view 렌더러 위 thin wrapper, 도구 카운트 4 → 6"
4+
target: v0.5.0
5+
last_updated: 2026-05-06
6+
---
7+
8+
# Stage S2 — view 도구 추가 (완료)
9+
10+
**작업일**: 2026-05-06
11+
**계획 문서**: [roadmap/v0.5.0/mcp.md](../../../roadmap/v0.5.0/mcp.md) §구현 스테이지 분할 S2
12+
**선행 stage**: [stage-1.md](stage-1.md) (서버 스켈레톤 + 코어 4 도구)
13+
14+
## 스코프
15+
16+
mcp.md §구현 스테이지 분할 S2 행 정확 매핑:
17+
18+
- `python/rhwp/mcp/tools.py` 에 `to_markdown(path)` / `to_html(path, *, include_css=False)` 추가
19+
- `python/rhwp/mcp/server.py` `build_server()` 에 두 도구 등록 — 도구 카운트 4 → 6
20+
- `tests/test_mcp_server.py` 의 `test_lists_exactly_four_tools` → `test_lists_exactly_six_tools` 갱신 + `TestToMarkdown` / `TestToHtml` 클래스 추가 (AC-6 spec 매핑)
21+
- v0.4.0 view 렌더러 (`HwpDocument.to_markdown()` / `to_html(*, include_css=...)`) 위 thin wrapper — 추가 변환 / sanitize / wrapping 없이 pass-through
22+
23+
S3 (`chunks` extras gate), S4 (streamable-http transport), S5 (문서화·검증) 는 본 스테이지 범위 밖.
24+
25+
## 산출물
26+
27+
| 파일 | 변동 | 내용 |
28+
|---|---|---|
29+
| `python/rhwp/mcp/tools.py` | +30 / -1 | `to_markdown(path) -> str` / `to_html(path, *, include_css=False) -> str` 추가. 모듈 docstring 의 stage 분할 주석 갱신 (S1 4 + S2 2). v0.4.0 view API 와 동일하게 `include_css` keyword-only 강제 |
30+
| `python/rhwp/mcp/server.py` | +3 / -2 | `build_server()` 가 6 도구 등록 — `server.tool(tools.to_markdown)` / `server.tool(tools.to_html)` 추가. 주석 갱신 ("S1 코어 4 + S2 view 2") |
31+
| `tests/test_mcp_server.py` | +44 / -5 | 모듈 docstring AC 매핑 갱신 (AC-6 추가), `test_lists_exactly_six_tools` 로 rename + 도구 set 6 개로 확장, `TestToMarkdown` (2 테스트) / `TestToHtml` (3 테스트) 신설 — 모두 AC-6 spec 매핑 |
32+
| `docs/traces/coverage.md` | +5 | auto-regen — `v0.5.0/mcp#AC-6` 매핑 3 개 추가 (TestToMarkdown::test_matches_view_api, TestToHtml::test_matches_view_api_no_css, TestToHtml::test_matches_view_api_with_css) |
33+
34+
## S2 확정 결정 사항
35+
36+
| 결정 | 선택 | 근거 |
37+
|---|---|---|
38+
| **`to_html` 의 `include_css` keyword-only 강제** | `def to_html(path: str, *, include_css: bool = False)` (positional 거부) | v0.4.0 `HwpDocument.to_html(*, include_css=False)` 의 invariant 와 동일. `include_css=True` 가 의미적으로 부울 플래그이고 호출처가 의도를 명시해야 한다는 view-layer 결정을 wrapper 가 침식하지 않게 함. JSON Schema 출고에는 영향 없음 (positional/keyword 구분 없음) — Python 호출 측면의 invariant 보존 |
39+
| **"thin wrapper" 의미 — byte-equality 강제** | 도구 출력 == `HwpDocument.to_xxx(...)` 직접 호출 출력 (bytewise 동일) | AC-6 의 "thin wrapper" 를 "추가 변환 / sanitize 없음" 으로 해석. 테스트 (`TestToMarkdown::test_matches_view_api` / `TestToHtml::test_matches_view_api_no_css` / `..._with_css`) 가 byte-equality 검증. 이로써 향후 view API 가 진화해도 wrapper 가 "투명한 통과" 에서 벗어나면 자동 회귀 검출 |
40+
| **docstring 에 view 동작 요약 복제** | tools.py 의 `to_markdown` / `to_html` docstring 이 GFM 표 / `<aside>` 각주 등 view 동작을 짧게 요약 | LLM 이 도구 호출 의도 / 결과를 정확히 추론하도록 schema 에 노출되는 description 을 간결하지만 informative 하게 유지. drift 위험 (view API 결정사항이 바뀌면 두 곳 동기화 필요) 은 인지하면서 LLM 도구 호출 정확도 우선 |
41+
| **새 도구 등록 위치 — 같은 `build_server()` factory** | 별도 `build_view_tools()` 분기 없이 inline 등록 | S3 의 `chunks` 도구는 extras-gate 가 필요 (langchain-text-splitters 미설치 시 도구 자체 미등록 vs 등록 후 호출 시 에러) — 이 결정은 S3 에서 해결. S2 는 무조건 v0.4.0 view API (코어 wheel 내장) 가용하므로 분기 불필요 |
42+
| **AC-2 의 도구 카운트** | S2 시점 6 (S1 의 4 + S2 의 2). spec 본문은 GA 기준 7 개 (S3 chunks 후 충족) | mcp.md AC-2 본문은 그대로 두고 (GA 기준 = 7 개), impl-log 에서 stage 별 진행 카운트만 기록 — stage-1 § S2 진입 조건 row 4 의 인계 사항 그대로 적용 |
43+
44+
## 비타협 제약 준수
45+
46+
- **`unsendable` 안전 패턴** — 새 2 도구 모두 sync 함수, handler 안에서 `rhwp.parse(path) → .to_ir() → .to_xxx(...)` → `str` 반환. Document 가 thread 경계 절대 안 넘음. `TestSyncHandler::test_all_registered_tools_are_sync` 가 등록된 6 도구를 walk 해 자동 커버 (S1 의 함수 walk 패턴이 의도대로 동작)
47+
- **v0.4.0 view API 위 thin wrapper** — 추가 변환 / sanitize / wrapping 없음. byte-equality 테스트가 invariant 보장
48+
- **Pydantic V2 / Literal enum 정책** — 본 stage 는 새 모델 / enum 추가 없음 (str 입출력만)
49+
- **`__init__.py` 모듈 레벨 third-party import 금지** — S1 그대로, 변경 없음
50+
- **모듈 위치** `python/rhwp/mcp/` (top-level) — 변경 없음
51+
52+
## 검증
53+
54+
| 검사 | 결과 |
55+
|---|---|
56+
| `uv run pytest tests/ -m "not slow"` | **553 passed, 2 skipped** (S1 548 + S2 신규 5) |
57+
| `uv run pytest tests/test_mcp_server.py -v` | **23 passed** (S1 18 + S2 5) |
58+
| `uv run ruff check python/rhwp/mcp/ tests/test_mcp_server.py` | clean |
59+
| `uv run pyright python/rhwp/mcp/ tests/test_mcp_server.py` | **0 errors** |
60+
| `uv run python scripts/lint_docs.py` | exit 0 |
61+
| `uv run python scripts/generate_spec_trace.py --check` | up to date — 8 AC 매핑 (S1 의 7 + S2 의 AC-6×3) |
62+
| `code-reviewer` fresh-context 검증 | LOW 3 / MEDIUM 0 / HIGH 0 / BLOCKER 0 — LOW-1 (`include_css` keyword-only) 반영, LOW-2 / LOW-3 은 trade-off 명시 후 보류 |
63+
64+
### 테스트 커버리지 (mcp.md §S2 → AC 매핑)
65+
66+
| mcp.md AC | 테스트 |
67+
|---|---|
68+
| AC-2 (도구 6 개 노출 — S1 코어 4 + S2 view 2) | `TestToolRegistry::test_lists_exactly_six_tools` |
69+
| AC-6 (view 도구 = `HwpDocument.to_xxx(...)` thin wrapper) | `TestToMarkdown::test_matches_view_api`, `TestToHtml::test_matches_view_api_no_css`, `TestToHtml::test_matches_view_api_with_css` (모두 byte-equality 검증) |
70+
| AC-6 보조 (출력 형식 sanity) | `TestToMarkdown::test_returns_non_empty_string`, `TestToHtml::test_returns_html5_document` |
71+
72+
S1 의 AC-3 / AC-4 / AC-5 / AC-9 / AC-10 매핑은 그대로 유지 — `TestSyncHandler` 가 6 도구를 walk 하고 packaging 검증은 도구 카운트와 독립.
73+
74+
## 알려진 한계 (S3 이후 처리)
75+
76+
- **`to_markdown` / `to_html` docstring drift 위험** — view API 결정사항 (GFM 표 정책 / `<aside>` 각주 마커 등) 이 바뀌면 tools.py 의 docstring 도 함께 갱신 필요. 회귀 검출은 byte-equality 테스트가 담당하지만 docstring 자체는 자동 동기화 안 됨. v0.4.0 view API 가 GA 라 변동 가능성은 낮음 (CONVENTIONS § Frozen body 변경 금지 정책)
77+
- **`include_css` 외 view API 옵션 미노출** — 현재 `to_html` 은 `include_css` 만 wrapper 인자로 노출. v0.4.0 view API 가 미래에 추가 옵션 (예: 외부 stylesheet URL / inline 이미지 base64 등) 을 도입하면 wrapper 갱신 필요. v0.5.0 GA 시점에는 v0.4.0 view API 가 frozen 이라 영향 없음
78+
79+
## S3 진입 조건 (인수인계)
80+
81+
S3 는 `chunks` 도구 — `langchain-text-splitters` extras gate. S1 / S2 에서 고정한 계약:
82+
83+
1. **`tools.py` 의 sync-only 패턴** — `chunks` 도구도 같은 형태. 단, `chunks` 는 langchain extras 미설치 환경에서 import 자체가 실패 — 도구 본체에서 lazy import + try/except 처리 또는 `server.py` 의 `build_server()` 에서 도구 등록 자체를 conditional 로 분리. mcp.md AC-7 ("chunks 도구 호출 시 langchain-text-splitters 미설치면 MCP isError=True 응답 — 서버 기동은 정상 + 다른 6 도구는 사용 가능") 이 후자 (등록은 무조건 + 호출 시 친절 에러) 를 시사
84+
2. **`TestToolRegistry::test_lists_exactly_six_tools`** → S3 종료 시 7 로 재카운트. mcp.md AC-2 ("GA 시점 7 도구") 충족
85+
3. **`TestSyncHandler::test_all_registered_tools_are_sync`** — 자동 커버 (등록 도구 walk)
86+
4. **CI test-without-extras skip count** — S2 는 추가 변동 없음. S3 도 `test_mcp_server.py` 자체는 fastmcp 만 gate (langchain 미설치는 `chunks` 도구의 in-tool 분기) 라 skip count 그대로 5 유지 예상
87+
88+
## 참조
89+
90+
- 상위 설계: [roadmap/v0.5.0/mcp.md](../../../roadmap/v0.5.0/mcp.md)
91+
- 결정 사항 증거: [design/v0.5.0/mcp-research.md](../../../design/v0.5.0/mcp-research.md)
92+
- 선행 stage: [stage-1.md](stage-1.md)
93+
- v0.4.0 view 렌더러 (의존 대상): `python/rhwp/ir/nodes.py` `HwpDocument.to_markdown()` / `to_html(*, include_css=...)`
94+
- v0.4.0 spec: roadmap/v0.4.0/view-renderer.md (Frozen, GA 2026-05-05)
Collapse file

‎docs/traces/coverage.md‎

Copy file name to clipboardExpand all lines: docs/traces/coverage.md
+10-2Lines changed: 10 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,22 @@ v0.4.0+ 신규 spec 의 인수조건 ↔ 테스트 매핑. 기존 v0.1.0 ~ v0.3.
548548
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestPackagingSurface::test_pyproject_declares_fastmcp_extras_and_script` |
549549
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestParseHwpSummary::test_returns_counts_matching_doc` |
550550
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestSyncHandler::test_all_registered_tools_are_sync` |
551+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToHtml::test_matches_view_api_no_css` |
552+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToHtml::test_matches_view_api_with_css` |
553+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToHtml::test_returns_html5_document` |
554+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToMarkdown::test_matches_view_api` |
555+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToMarkdown::test_returns_non_empty_string` |
551556
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToolRegistry::test_each_tool_has_description` |
552557
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToolRegistry::test_iter_blocks_kind_schema_is_enum` |
553558
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToolRegistry::test_iter_blocks_scope_schema_is_enum` |
554-
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToolRegistry::test_lists_exactly_four_tools` |
559+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestToolRegistry::test_lists_exactly_six_tools` |
555560
| v0.5.0/mcp | AC-10 | `tests/test_mcp_server.py::TestPackagingSurface::test_module_is_top_level_not_under_integrations` |
556-
| v0.5.0/mcp | AC-2 | `tests/test_mcp_server.py::TestToolRegistry::test_lists_exactly_four_tools` |
561+
| v0.5.0/mcp | AC-2 | `tests/test_mcp_server.py::TestToolRegistry::test_lists_exactly_six_tools` |
557562
| v0.5.0/mcp | AC-3 | `tests/test_mcp_server.py::TestErrorHandling::test_iter_blocks_invalid_kind` |
558563
| v0.5.0/mcp | AC-4 | `tests/test_mcp_server.py::TestErrorHandling::test_extract_text_missing_file` |
559564
| v0.5.0/mcp | AC-5 | `tests/test_mcp_server.py::TestSyncHandler::test_all_registered_tools_are_sync` |
565+
| v0.5.0/mcp | AC-6 | `tests/test_mcp_server.py::TestToHtml::test_matches_view_api_no_css` |
566+
| v0.5.0/mcp | AC-6 | `tests/test_mcp_server.py::TestToHtml::test_matches_view_api_with_css` |
567+
| v0.5.0/mcp | AC-6 | `tests/test_mcp_server.py::TestToMarkdown::test_matches_view_api` |
560568
| v0.5.0/mcp | AC-9 | `tests/test_mcp_server.py::TestPackagingSurface::test_entry_point_dispatches_to_run` |
561569
| v0.5.0/mcp | AC-9 | `tests/test_mcp_server.py::TestPackagingSurface::test_pyproject_declares_fastmcp_extras_and_script` |
Collapse file

‎python/rhwp/mcp/server.py‎

Copy file name to clipboardExpand all lines: python/rhwp/mcp/server.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515

1616

1717
def build_server() -> FastMCP:
18-
"""새 ``FastMCP`` 인스턴스를 만들고 도구 4 종을 등록해 반환.
18+
"""새 ``FastMCP`` 인스턴스를 만들고 도구 6 종을 등록해 반환.
1919
2020
테스트가 ``mcp.list_tools()`` / ``mcp.call_tool(name, args)`` 를 in-process
2121
호출할 수 있도록 build 단계를 함수로 분리 — 모듈 import 부수 효과 없이
2222
fresh 인스턴스 획득.
2323
"""
2424
server = FastMCP("rhwp-mcp")
25-
# ^ S1 도구 4 종. S2 (to_markdown / to_html) / S3 (chunks) 는 후속 stage 에서 추가.
25+
# ^ S1 코어 4 + S2 view 2. S3 (chunks) 는 후속 stage 에서 추가.
2626
# fastmcp v3 의 ``server.tool(fn)`` 은 데코레이터 호출 형태 — 동일 인스턴스에
2727
# 여러 도구를 program 적으로 등록할 때 같은 클로저 충돌 없이 안전.
2828
server.tool(tools.parse_hwp_summary)
2929
server.tool(tools.extract_text)
3030
server.tool(tools.get_ir)
3131
server.tool(tools.iter_blocks)
32+
server.tool(tools.to_markdown)
33+
server.tool(tools.to_html)
3234
return server
3335

3436

Collapse file

‎python/rhwp/mcp/tools.py‎

Copy file name to clipboardExpand all lines: python/rhwp/mcp/tools.py
+33-2Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
을 강제하기 위해 모두 sync 함수로 정의 — Document 가 thread 경계를 절대 안
66
넘는다. 자세한 배경은 ``docs/design/v0.5.0/mcp-research.md`` § 3.
77
8-
S1 — 4 개 도구 (`parse_hwp_summary` / `extract_text` / `get_ir` / `iter_blocks`).
9-
S2 (`to_markdown` / `to_html`), S3 (`chunks`) 는 후속 stage 에서 추가.
8+
- S1 — `parse_hwp_summary` / `extract_text` / `get_ir` / `iter_blocks` (코어 4)
9+
- S2 — `to_markdown` / `to_html` (v0.4.0 view API thin wrapper)
10+
- S3 — `chunks` (langchain-text-splitters extras gate, 후속 stage)
1011
"""
1112

1213
from typing import Any, Literal
@@ -77,6 +78,36 @@ def get_ir(path: str) -> dict[str, Any]:
7778
return rhwp.parse(path).to_ir().model_dump(mode="json")
7879

7980

81+
def to_markdown(path: str) -> str:
82+
"""HWP 또는 HWPX 파일을 GFM (GitHub Flavored Markdown) 문자열로 변환.
83+
84+
v0.4.0 view 렌더러 (``HwpDocument.to_markdown()``) 위 thin wrapper. 표는
85+
모든 셀 ``span == 1`` 일 때 GFM ``|...|`` 표, 병합 셀은 ``TableBlock.html``
86+
인라인 폴백. 이미지는 placeholder (``picture.image.uri`` pass-through),
87+
각주/미주는 본문 끝 정의 + 본문 paragraph 안 ``[^N]`` reference. 머리글 /
88+
꼬리말은 출력 미포함.
89+
"""
90+
return rhwp.parse(path).to_ir().to_markdown()
91+
92+
93+
def to_html(path: str, *, include_css: bool = False) -> str:
94+
"""HWP 또는 HWPX 파일을 완전 HTML5 문서로 변환.
95+
96+
v0.4.0 view 렌더러 (``HwpDocument.to_html()``) 위 thin wrapper. 표는
97+
``TableBlock.html`` 그대로 inline (rowspan/colspan 보존). 이미지는
98+
``picture.image.uri`` pass-through, 수식 디스플레이는 ``<div class="math">``,
99+
각주/미주는 본문 직후 ``<aside id="...">`` 정의 블록 + 본문 안 ``<sup>``
100+
인용 마커. 머리글/꼬리말은 출력 미포함.
101+
102+
Args:
103+
path: HWP 또는 HWPX 파일 경로.
104+
include_css: True 면 ``<head>`` 안 embedded ``<style>`` 동봉 (브라우저
105+
표시용). 기본 False — RAG 임베딩 / 텍스트 추출 사용처용. v0.4.0 view
106+
API 와 동일하게 keyword-only — 호출 의미 명확화.
107+
"""
108+
return rhwp.parse(path).to_ir().to_html(include_css=include_css)
109+
110+
80111
def iter_blocks(
81112
path: str,
82113
kind: BlockKind | None = None,
Collapse file

‎tests/test_mcp_server.py‎

Copy file name to clipboardExpand all lines: tests/test_mcp_server.py
+57-11Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
"""rhwp.mcp fastmcp 서버 단위 테스트 (S1).
1+
"""rhwp.mcp fastmcp 서버 단위 테스트 (S1 + S2).
22
33
``fastmcp`` (``[mcp]`` extras) 미설치 환경에서는 file-level ``importorskip`` 로
44
전체 skip — CI ``test-without-extras`` 잡이 카운트 검증 (AC-1).
55
6-
S1 시점 인수조건 매핑:
6+
인수조건 매핑:
77
8-
- AC-2 (도구 4 개 노출) → ``TestToolRegistry``
9-
- AC-3 (잘못된 enum → isError=True) → ``TestErrorHandling::test_iter_blocks_invalid_kind``
10-
- AC-4 (FileNotFound → isError=True) → ``TestErrorHandling::test_extract_text_missing_file``
11-
- AC-5 (모든 handler sync 함수) → ``TestSyncHandler``
12-
- AC-9 (pyproject 등록) → ``TestPackagingSurface`` (entry point + extras 키 verify)
13-
- AC-10 (모듈 위치) → ``TestPackagingSurface``
8+
- AC-2 (도구 6 개 노출 — S1 코어 4 + S2 view 2) → ``TestToolRegistry``
9+
- AC-3 (잘못된 enum → isError=True) → ``TestErrorHandling``
10+
- AC-4 (FileNotFound → isError=True) → ``TestErrorHandling``
11+
- AC-5 (모든 handler sync 함수) → ``TestSyncHandler``
12+
- AC-6 (view 도구가 v0.4.0 view API thin wrapper) → ``TestToMarkdown`` / ``TestToHtml``
13+
- AC-9 (pyproject 등록) → ``TestPackagingSurface``
14+
- AC-10 (모듈 위치) → ``TestPackagingSurface``
1415
"""
1516

1617
from pathlib import Path
@@ -36,13 +37,20 @@
3637

3738
# ------------------------------------------------------------------ AC-2
3839
class TestToolRegistry:
39-
"""도구 등록 (S1: 4 개)."""
40+
"""도구 등록 (S1 코어 4 + S2 view 2 = 6 개)."""
4041

4142
@pytest.mark.spec("v0.5.0/mcp#AC-2")
42-
def test_lists_exactly_four_tools(self) -> None:
43+
def test_lists_exactly_six_tools(self) -> None:
4344
server = build_server()
4445
names = {t.name for t in asyncio.run(server.list_tools())}
45-
assert names == {"parse_hwp_summary", "extract_text", "get_ir", "iter_blocks"}
46+
assert names == {
47+
"parse_hwp_summary",
48+
"extract_text",
49+
"get_ir",
50+
"iter_blocks",
51+
"to_markdown",
52+
"to_html",
53+
}
4654

4755
def test_each_tool_has_description(self) -> None:
4856
server = build_server()
@@ -147,6 +155,44 @@ def test_returns_dict_with_schema_envelope(self, hwp_sample: Path) -> None:
147155
assert "body" in result
148156

149157

158+
class TestToMarkdown:
159+
"""AC-6 — to_markdown 가 v0.4.0 ``HwpDocument.to_markdown()`` 위 thin wrapper."""
160+
161+
@pytest.mark.spec("v0.5.0/mcp#AC-6")
162+
def test_matches_view_api(self, hwp_sample: Path) -> None:
163+
"""도구 출력이 ``HwpDocument.to_markdown()`` 직접 호출과 byte-equal."""
164+
tool_output = tools.to_markdown(str(hwp_sample))
165+
view_output = rhwp.parse(str(hwp_sample)).to_ir().to_markdown()
166+
assert tool_output == view_output
167+
168+
def test_returns_non_empty_string(self, hwp_sample: Path) -> None:
169+
result = tools.to_markdown(str(hwp_sample))
170+
assert isinstance(result, str)
171+
assert result.strip(), "to_markdown must yield non-empty markdown for fixture"
172+
173+
174+
class TestToHtml:
175+
"""AC-6 — to_html 가 v0.4.0 ``HwpDocument.to_html()`` 위 thin wrapper."""
176+
177+
@pytest.mark.spec("v0.5.0/mcp#AC-6")
178+
def test_matches_view_api_no_css(self, hwp_sample: Path) -> None:
179+
"""기본 ``include_css=False`` 가 ``HwpDocument.to_html()`` 와 byte-equal."""
180+
tool_output = tools.to_html(str(hwp_sample))
181+
view_output = rhwp.parse(str(hwp_sample)).to_ir().to_html(include_css=False)
182+
assert tool_output == view_output
183+
184+
@pytest.mark.spec("v0.5.0/mcp#AC-6")
185+
def test_matches_view_api_with_css(self, hwp_sample: Path) -> None:
186+
"""``include_css=True`` 가 ``HwpDocument.to_html(include_css=True)`` 와 byte-equal."""
187+
tool_output = tools.to_html(str(hwp_sample), include_css=True)
188+
view_output = rhwp.parse(str(hwp_sample)).to_ir().to_html(include_css=True)
189+
assert tool_output == view_output
190+
191+
def test_returns_html5_document(self, hwp_sample: Path) -> None:
192+
result = tools.to_html(str(hwp_sample))
193+
assert result.startswith("<!DOCTYPE html>") or result.lstrip().startswith("<!DOCTYPE")
194+
195+
150196
class TestIterBlocks:
151197
def test_default_returns_dicts(self, hwp_sample: Path) -> None:
152198
result = tools.iter_blocks(str(hwp_sample))

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.