feat: markdown API documentation rendering
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from auto_reverse.doc.markdown import render_markdown
|
||||
from auto_reverse.models import EndpointRecord, Signature
|
||||
|
||||
|
||||
def _rec(method, template, **kw):
|
||||
rec = EndpointRecord(signature=Signature(method, "ex.com", template, "2xx"))
|
||||
for k, v in kw.items():
|
||||
setattr(rec, k, v)
|
||||
return rec
|
||||
|
||||
|
||||
def test_renders_heading_and_endpoints():
|
||||
md = render_markdown([_rec("GET", "/api/users", summary="List users")], title="ex.com API")
|
||||
assert "# ex.com API" in md
|
||||
assert "`GET /api/users`" in md
|
||||
assert "List users" in md
|
||||
|
||||
|
||||
def test_groups_by_tag():
|
||||
records = [
|
||||
_rec("GET", "/api/users", tag="Users"),
|
||||
_rec("GET", "/api/cart", tag="Cart"),
|
||||
]
|
||||
md = render_markdown(records, title="x")
|
||||
assert "## Users" in md
|
||||
assert "## Cart" in md
|
||||
|
||||
|
||||
def test_untagged_go_under_general():
|
||||
md = render_markdown([_rec("GET", "/api/x")], title="x")
|
||||
assert "## General" in md
|
||||
Reference in New Issue
Block a user