feat(server): serve bundled API docs at /docs - #3347
Conversation
|
Nice. It works for me, and degrades gracefully when the documentation path is inaccessible. |
|
Awesome! I would like to review this before it merges. Thanks for your patience :) |
ca535f0 to
a1335bc
Compare
jeremyfowers
left a comment
There was a problem hiding this comment.
So, at the risk of scope-creeping you very badly...
How would you feel about changing this PR so that it builds the entire docs site with Zensical and serves that over the /docs endpoint, just like https://lemonade-server.ai/docs/ does? That would be much more comprehensive. It would also mean, later on, we could load it in an iframe in the GUI and display the complete up-to-date project documentation for the user's current install.
Alternatively, if you don't want to take that on, this PR still needs to be durable in the likely event people will want more in /docs than just api/lemonade.md. I think the simplest way to achieve that would be to make the current endpoint /docs/api/lemonade, and then it makes sense that it serves exactly that doc, at the same relative path that https://lemonade-server.ai/docs/api/lemonade/
Otherwise if /v1/docs serves the document /docs/api/lemonade.md it will be a breaking change when we inevitably decide to add more documentation to the endpoint.
Thoughts?
|
what I would find most useful is to have I don't think this is a breaking change because you first query I use this "here's the top of the docs, you figure it out" pattern a lot for making python api bindings. you can serve a rendered copy of the docs from |
Replaces the concatenated response with a JSON index at /v1/docs and one page per URL at /v1/docs/api/lemonade, so pages can be added later without breaking clients. Widens the bundle to all of docs/api.
Lists the reference pages the server ships, or returns one as markdown when `page` is given. Reuses the HTTP endpoint's lookup so the path confinement is shared rather than written twice.
…ocs/ Adds BUILD_DOCS_SITE, off by default, which builds the existing Zensical site into resources/docs-site and serves it at /docs/. Off by default because zensical installs with pip; the Debian build uses only the archive.
Installs zensical and configures with BUILD_DOCS_SITE=ON in both Windows installer jobs, so the shipped MSIs carry the docs site while source builds that cannot install from pip are unaffected.
|
Reading your comments, there are two audiences consuming that functionality, so I @jeremyfowers, you're right, it was a much needed change, so I went ahead and
@ckuethe, this is the discovery-first shape you described. @superm1, enabling the site for the Debian package needs a change in Thank you all. |
|
Lovely. Versioned doc API is fine, I'm just happy that there'll be an endpoint I can point my agent at, allowing it to figure out what endpoints are available and how to use them. |
Summary
Serves the server's own API documentation three ways. Machine clients fetch an
index of the available pages and then each page as markdown, agents get the same
through an MCP tool, and browsers get the human-readable rendered site.
GET /v1/docsGET /v1/docs/api/lemonadePOST /mcp->lemonade_docsGET /docs/The three API routes are always present. Additionally, the website can be
enabled with the
BUILD_DOCS_SITEflag. The Windows installers set it, so anMSI install includes the site; building from source, it is optional.
Fixes #1700
Scope
prefixes; all 7 files in
docs/apiinstead of 3, read from the folder ratherthan a list in the code.
the published site; the WiX generator now takes an id prefix so it can harvest
more than one folder.
the flag on.
Enabling the site for the Debian package needs a separate change in
contrib/debian/rules, raised in the comments.Testing
Testing details:
All 63
cpp-citests pass, including the rewrittenDocsEndpointTest.Verified against a running server: the index and every page it lists, on all four
prefixes; unknown pages and path traversal rejected; the MCP tool over real
JSON-RPC; and
/docs/serving the site with the existing routes unaffected.Built and extracted
lemonade-server-minimal.msito confirm the 7 markdown filesand 129 site files install, and confirmed the WiX generator still produces
identical output for the web app.
Documentation
docs/api/lemonade.mddocuments both endpoints,docs/api/mcp.mddocuments thenew tool,
docs/api/README.mdandAGENTS.mdwere updated to match.Breaking Changes
/v1/docschanges from concatenated markdown to a JSON index. The endpoint isunreleased, so no shipped client depends on it.
AI-assisted contribution