Skip to content

[Sync to prerelease] Add manifest-driven screenshot capture tooling#1976

Merged
cderv merged 1 commit into
prereleasefrom
sync-1975-to-prerelease
Mar 27, 2026
Merged

[Sync to prerelease] Add manifest-driven screenshot capture tooling#1976
cderv merged 1 commit into
prereleasefrom
sync-1975-to-prerelease

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Description

Sync of #1975 to prerelease.

Original PR

Add manifest-driven screenshot capture tooling

What is this?

A developer tool for capturing and maintaining the documentation screenshots on quarto.org. Screenshots are defined declaratively in a JSON manifest, then captured automatically using Playwright — no manual screenshotting needed.

The problem it solves: quarto-web has ~30 screenshots across docs pages (about pages, navigation, sidebars, etc.). When the site design changes or examples need updating, recapturing them manually is tedious and error-prone. This tool makes it repeatable and consistent.

How it works

Everything lives under tools/screenshots/. The workflow:

  1. Define a screenshot in manifest.json — source page, viewport size, interactions (clicks, hovers), crop/clip regions, dark mode variant
  2. Run npm run capture — Playwright renders the page, executes the interactions, takes the screenshot, post-processes it (trim, crop, compress)
  3. Light and dark variants are produced automatically for every entry

The manifest currently defines 17 screenshots (34 images with dark variants), covering about pages, navbar configurations, sidebar layouts, breadcrumbs, reader mode, and repo action links.

Key capabilities

  • Declarative manifest with JSON Schema validation (npm run validate) and IDE autocompletion
  • Dark mode capture via JS toggle (avoids CSS visibility issues at narrow viewports)
  • Spotlight effect — dims the page with an overlay while highlighting a specific element (used for repo-actions screenshot)
  • Content-aware trim — detects background color and removes blank edges uniformly
  • Clip union — screenshots the bounding box of multiple CSS selectors
  • Quarto profile support — same example project renders different configurations (e.g., floating vs anchored sidebar)
  • CI compression workflow (.github/workflows/optimize-images.yml) — runs oxipng on changed PNGs after merge

Example projects

Small Quarto projects under examples/ serve as screenshot sources. Each is minimal — just enough YAML and content to demonstrate a feature. examples/quarto-demo/ is a git subtree of quarto-dev/quarto-demo used for sidebar and navigation screenshots.

Live use case: PR #1815

This tooling was developed alongside #1815 (Twitter → Bluesky migration), which needed 19 documentation screenshots recaptured with updated social links. That PR served as the real-world validation — every screenshot in #1815 was produced by this tool and cherry-picked from this branch.

For contributors

Setup requires Node.js and Playwright. From tools/screenshots/:

npm install
npx playwright install chromium

Then:

  • npm run capture — capture all screenshots
  • npm run capture -- --name navbar-tools — capture a specific entry
  • npm run capture -- --dry-run — preview the plan
  • npm run capture -- --list — list manifest entries
  • npm run validate — validate manifest against schema

See tools/screenshots/SETUP.md for the full guide.

Claude Code integration

A /screenshot skill guides Claude through the full workflow: creating example projects, iterating on the visual in headed Playwright, encoding the result into the manifest. This is the intended workflow for adding new screenshots — the skill handles the interactive exploration, the manifest captures the result, and capture.js replays it mechanically.

Add developer tooling for capturing and maintaining documentation
screenshots on quarto.org using Playwright. Screenshots are defined
declaratively in a JSON manifest, then captured automatically —
no manual screenshotting needed.

The tooling lives under _tools/screenshots/ and includes:

- capture.js: Playwright-based replay engine that renders pages,
  executes interactions (clicks, hovers, toggles), and captures
  screenshots with automatic light/dark variants
- manifest.json: Declarative definitions for 17 screenshots (34
  images with dark variants) covering about pages, navbar configs,
  sidebar layouts, breadcrumbs, reader mode, and repo action links
- JSON Schema validation for manifest entries
- Content-aware trim, crop, and clip-union post-processing via sharp
- Spotlight effect for highlighting specific elements
- Quarto profile support for rendering different configurations
- Example projects under examples/ as minimal screenshot sources
  (includes quarto-demo as a git subtree)
- CI compression workflow (.github/workflows/optimize-images.yml)
  for oxipng optimization after merge
- /screenshot Claude Code skill for interactive screenshot authoring

Developed alongside PR #1815 (Twitter → Bluesky migration), which
served as real-world validation — all 19 screenshots in that PR
were produced by this tool.

(cherry picked from commit b184c08)
@cderv
Copy link
Copy Markdown
Member

cderv commented Mar 27, 2026

/deploy-preview

@github-actions
Copy link
Copy Markdown
Contributor Author

📝 Preview Deployment

🔍 Full site preview: https://deploy-preview-1976.quarto.org

🔄 Modified Documents

🖼️ Pages with Updated Screenshots

@cderv cderv merged commit 8d4545d into prerelease Mar 27, 2026
@cderv cderv deleted the sync-1975-to-prerelease branch March 27, 2026 19:49
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.

1 participant