Skip to content

Emit CommonMark for generated API Explorer pages - #3994

Draft
reakaleek wants to merge 3 commits into
mainfrom
issue-809-api-markdown
Draft

Emit CommonMark for generated API Explorer pages#3994
reakaleek wants to merge 3 commits into
mainfrom
issue-809-api-markdown

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Generated API Explorer pages now write a sibling CommonMark file and serve it through a .md suffix or Accept: text/markdown. Agents and tools can read native API pages without scraping HTML.

Affects: API reference, Isolated builds

Why

Local preview and isolated builds publish API HTML only. A request for Markdown on an /api/doc/ URL returns HTML or 404. elastic/docs-eng-team#809 needs readable CommonMark next to each generated API page.

What

Sibling CommonMark files

Each successful index.html write also writes a sibling .md file from the page models. Grouping models that render no page still emit no file. The generator does not convert Razor HTML.

Preview and static serving

Preview and static hosts serve that file when the path ends with .md or when Accept prefers text/markdown. Browser and text/html requests still receive HTML. Path traversal checks apply to both file types.

Alternate link

The API layout emits one <link rel="alternate" type="text/markdown"> in the document head. There is no visible View as Markdown or Copy as Markdown control.

Out of scope: OkfMarkdownExporter still skips live /api/* links. Production www.elastic.co still proxies API pages to bump.sh until the API Explorer cutover.

Verify

dotnet test tests/Elastic.ApiExplorer.Tests/
dotnet test tests/Elastic.Documentation.Tests/
dotnet run --project src/tooling/docs-builder -- serve
curl -D - http://localhost:3000/api/doc/docs-builder-elasticsearch.md
curl -D - -H 'Accept: text/markdown' http://localhost:3000/api/doc/docs-builder-elasticsearch/
curl -D - http://localhost:3000/api/doc/docs-builder-elasticsearch/operation/operation-async-search-get.md

Expect 200 and text/markdown; charset=utf-8 with readable CommonMark. A normal browser request to the HTML URL must still return HTML.

Made with Cursor

Agents and Accept: text/markdown requests currently receive no readable API Markdown. Write sibling .md files from page models and serve them from preview and static hosts.

Co-Authored-By: Cursor Grok 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/3994/

Sample changed pages:

Agents and OKF consumers need structured page metadata. Write title, description, url, products, type, and resource, and drop authored YAML from child pages.

Co-Authored-By: Cursor Grok 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse the supplemental frontmatter splitter and limit body description inference to authored child pages.

Co-Authored-By: GPT-5.6 Sol <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant