Skip to content

Show Copy page on API Markdown pages - #4984

Merged
reakaleek merged 4 commits into
mainfrom
docs-copy-page-button-mis-876a49db
Nov 20, 2026
Merged

reakaleek merged 4 commits into
mainfrom
docs-copy-page-button-mis-876a49db

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Authored Markdown pages in the API reference, such as the Kibana Spaces overview, now show the Copy page menu like every other API page.

Affects: API reference

Prompt summary: Jan asks why /docs/api/kibana/kibana-api-overview has no Copy page button, when other API pages do. The goal is to give these pages the same button.

Why

MarkdownPageViewModel sets ShowPageActions to false, so authored intro, outro and Authentication pages hide Copy page. These pages already write a .md export, and their <link rel="alternate" type="text/markdown"> points to it. Only the button is missing.

What

Markdown pages get Copy page

The override in MarkdownPageViewModel is gone. Copy page and View as Markdown on these pages open the .md that the build already writes.

Every authored page writes its export

The generator used to skip the .md for a page whose export was empty, such as an empty authored file. It now skips only a page with no export, so Copy page never links to a missing file.

The page-actions opt-out is removed

No other page turned page actions off, so the ShowPageActions hook and the layout flag are deleted. ApiPageActionsModel.MarkdownUrl is no longer nullable. The download-only menu for pages without Markdown (_SpecDownloadActions, its CSS and its snapshot test) is deleted, because no page renders it now.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests
# IntroNav_CopyPageCopiesItsMarkdownExport, IntroNav_DesignSystemRailLinksItsMarkdownExport
# Generate_EmptyAuthoredPage_StillWritesTheExportItsCopyPageLinksTo
mise run serve

Then open http://localhost:3000/api/kibana/kibana-api-overview and click Copy page. The clipboard holds the page's Markdown with its front matter.

Check on the preview

🤖 Generated with Claude Code

reakaleek and others added 2 commits November 20, 2026 12:03
Intro, outro and Authentication pages already write a `.md` export, but
`MarkdownPageViewModel` hid the Copy page button. This deletes that
opt-out. No other page used it, so the download-only menu for pages
without Markdown goes too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 20, 2026 11:04
@reakaleek
reakaleek requested a review from akira28 November 20, 2026 11:04
@reakaleek reakaleek added the bug label Nov 20, 2026
Comment on lines -363 to -369
@supports not selector(:popover-open) {
.api-page-actions--download-only .api-page-actions-split {
display: none;
}
.api-page-actions--download-only .api-page-actions-menu {
display: block;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

Removing the inline fallback makes the JSON and YAML downloads inaccessible on authored API pages in the legacy layout when the browser lacks the Popover API. The new chevron cannot open the menu, and floating.css hides it. Keep a fallback for the split menu so adding Copy page does not remove access to the downloads.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change here. Authored pages now use the same split menu as the spec landing, group and operation pages. Those pages put the JSON and YAML downloads in the same popover and have never had a fallback for browsers without the Popover API. The deleted fallback only covered the download-only menu, and no page renders that menu anymore. The Popover API has been Baseline in Chromium, Firefox and Safari since April 2024, and is now widely available. A fallback for the split menu would apply to every API page, so it belongs in its own change if we want one.

reakaleek and others added 2 commits November 20, 2026 12:10
An empty authored page rendered Copy page and View as Markdown, but the
generator skipped its `.md` because the export was empty. It now skips
only pages with no export, so the links always resolve.

Per review by @infra-vault-gh-plugin-prod.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The earlier test checked only the layout model, so it passed even if a
layout dropped the button or the link. The new tests render the Kibana
intro page and check Copy page in the current layout and View as
Markdown in the navigation-preview rail.

Per review by @infra-vault-gh-plugin-prod.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
var markdown = await page.RenderCommonMarkAsync(renderContext, pageModel, ctx).ConfigureAwait(false);
if (string.IsNullOrEmpty(markdown))
// An empty authored page still gets its export, which its Copy page links to.
if (markdown is null)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

An empty guide.md now reserves the output path guide.md as a file. If the same API lists guide.md.md as another child, that page already needs guide.md/ as its HTML directory. These distinct child slugs built before the empty export was added, but now one of the writes fails and the API build can be left incomplete. Check for file/directory collisions when assigning export paths.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change in this PR. The collision does not come from the empty export. CreateSlugFromFile turns guide.md.md into the slug guide.md. A non-empty guide.md already wrote guide.md as its export before this change, so the two children already collided on main. This change applies the same export rule to empty pages and adds no new kind of collision. The general fix is to reject an authored slug that ends in .md (or contains a dot) in ValidateSlugForCollisions. That applies to every authored page whether or not it is empty, so it belongs in its own change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That describes a pre-existing collision when guide.md is non-empty, but it doesn’t rule out the regression for an empty guide.md: before this change, empty Markdown was skipped; now only null is skipped, so an empty page gets a guide.md export (changed guard).

The paths explain the conflict: guide.md produces slug guide, while guide.md.md produces slug guide.md (slug creation). The first page’s Markdown export is guide.md; the second page’s HTML output requires the guide.md/ directory (output path mapping, render/write sequence). So the general slug-validation fix may be worth handling separately, but this change does introduce that collision for the previously non-exported empty-page case.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@reakaleek
reakaleek enabled auto-merge (squash) November 20, 2026 11:21
@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 9503822 into main Nov 20, 2026
44 checks passed
@reakaleek
reakaleek deleted the docs-copy-page-button-mis-876a49db branch November 20, 2026 11:22
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.

2 participants