Skip to content

[docs] Add "Copy page as markdown" button#8102

Open
dokson wants to merge 1 commit into
palantir:developfrom
dokson:ac/docs-copy-page-markdown
Open

[docs] Add "Copy page as markdown" button#8102
dokson wants to merge 1 commit into
palantir:developfrom
dokson:ac/docs-copy-page-markdown

Conversation

@dokson
Copy link
Copy Markdown

@dokson dokson commented May 4, 2026

Summary

Fixes #7687.

Adds a "Copy page" button to every docs page that hands the reader an LLM/IDE-friendly markdown blob of the current page, like Radix and Groq do.

Pipeline (docs-data)

For every page produced by the MarkdownPlugin, the build now reads the source .mdx via PageData.sourcePath, runs it through a new stripDocumentalistTags helper, and attaches the result as sourceMarkdown on the page object. The helper replaces top-level @reactDocs / @reactExample / @interface / @css lines with HTML comment placeholders (<!-- Interactive widget: ... (see online docs) -->) so the exported markdown stays valid and self-documenting. Lines inside fenced code blocks are left untouched, so Sass @use / @import in code samples are preserved.

stripDocumentalistTags lives in its own module (markdownExport.mts) with a dedicated markdownExport.test.ts, so importing it for testing does not trigger the top-level build code in compile-docs-data.mts.

UI (docs-theme)

A new CopyPageMarkdownButton renders a Blueprint AnchorButton with a clipboard icon and "Copy page" label. On click it writes sourceMarkdown to the clipboard and swaps the icon to a tick with a "Copied!" tooltip for 1.5s. The button is hidden when sourceMarkdown is undefined (e.g. transient pages or build-time skip).

Wiring (docs-app)

BlueprintDocs.renderPageActions now renders the new button alongside the existing "Edit this page" link, so every page action area gets both controls.

Test plan

  • pnpm --filter @blueprintjs/docs-data run test for markdownExport.test.ts — 3/3 passed (existing failures in navHelpers.test.ts are pre-existing and unrelated)
  • ESLint / Prettier on changed files
  • Manual smoke check in the docs app (deferred to reviewer — local Windows env hits an unrelated docs-data:compile issue with Node 25; the repo's .nvmrc pins 24.14.1)

Out of scope

A "View page as markdown" link or the dropdown variant from the issue's second screenshot. Once the basic sourceMarkdown plumbing is in place those are easy follow-ups, happy to do them in a separate PR if maintainers want.

Add a Copy page button to every docs page that hands the reader an LLM/IDE-friendly markdown blob of the current page. Builds on cameronjoyner's Documentalist pipeline by attaching a sourceMarkdown field to each PageData at build time and rendering an AnchorButton next to "Edit this page".

Pipeline (docs-data): for every page produced by the MarkdownPlugin, read the source .mdx via PageData.sourcePath and run it through stripDocumentalistTags, which replaces top-level @reactDocs/@reactExample/@interface/@css lines with HTML comment placeholders ("see online docs") so the exported markdown is valid for tooling and self-documenting. Lines inside fenced code blocks are left untouched, so Sass @use/@import in code samples are preserved. The function is in its own module (markdownExport.mts) with a vitest test, so importing it does not trigger the top-level build code in compile-docs-data.mts.

UI (docs-theme): a new CopyPageMarkdownButton renders a Blueprint AnchorButton with a clipboard icon and "Copy page" label, swapping to a tick + "Copied!" tooltip for 1.5s on success. Hidden when the page has no sourceMarkdown.

Wiring (docs-app): BlueprintDocs.renderPageActions now renders the new button alongside the existing "Edit this page" link.

Fixes palantir#7687.
@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented May 4, 2026

Generate changelog in packages/docs-theme/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[docs] Add "Copy page as markdown" button

Check the box to generate changelog(s)

  • Generate changelog entry

@dokson
Copy link
Copy Markdown
Author

dokson commented May 4, 2026

@cameronjoyner — implements #7687 starting from your "Copy page" idea. The sourceMarkdown is plumbed through the docs-data build (with Documentalist tags replaced by HTML comments so the output is valid markdown for LLM/IDE tooling), and the button lives in @blueprintjs/docs-theme next to the existing CodeExample widget so external docs consumers can reuse it. Happy to follow up with a "View as markdown" link or the dropdown variant if you want them in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Add a "copy as markdown" button

1 participant