Skip to content

Commit 1f54c50

Browse files
committed
Adjust contribution guide
1 parent 23d3603 commit 1f54c50

2 files changed

Lines changed: 40 additions & 5 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ This guide contains all the information you need about:
1515

1616
We provide built-in scripts to automate screenshot generation and keep images consistent with documentation guidelines:
1717

18-
- `bun run screenshots [target]`: Automatically capture documentation screenshots using Playwright.
18+
- `bun <path/to/screenshot.ts>`: Run an individual co-located screenshot script directly.
19+
- `bun run screenshots [target]`: Automatically capture all or matching documentation screenshots using Playwright.
1920
- `bun run screenshots:record [target]`: Open an interactive browser with session mocks to record user clicks for new screenshots.
2021
- `bun run screenshots:process <input.png> <target>`: Convert and resize external PNG/JPEG captures into standard (`800x450`) and large (`3200x1800`) WebP files with annotations.
2122

‎docs/guides/contribution/index.md‎

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,47 @@ Image requirements:
139139

140140
This repository includes automated tools to capture, record, and format screenshots to meet the requirements above:
141141

142+
#### Co-located screenshot scripts
143+
144+
Every screenshot has a dedicated `*.screenshot.ts` file placed alongside its `.webp` images in the same folder (for example, `docs/the-editor/overview/editor-overview.screenshot.ts` next to `editor-overview.webp` and `editor-overview-large.webp`).
145+
146+
Each script exports a screenshot target using `defineScreenshot`:
147+
148+
```typescript
149+
import { defineScreenshot } from '@/scripts/capture-screenshots'
150+
import type { Page } from 'playwright'
151+
152+
export default defineScreenshot({
153+
path: '/projects/docs_examples/branches/screenshots/components/screenshot-page?canvas-width=800&canvas-height=800&rightpanel=events',
154+
description: 'Editor overview showing canvas, panels, and bottom bar',
155+
setup: async (page: Page) => {
156+
await page.waitForTimeout(500)
157+
},
158+
annotations: [
159+
{ type: 'badge', x: 550, y: 35, text: '1' },
160+
{ type: 'badge', x: 450, y: 395, text: '2' },
161+
],
162+
})
163+
```
164+
165+
- **Output directory and target name**: Inferred automatically from the script's folder location and filename.
166+
- **Path alias**: Imports use the `@/scripts/...` alias from `tsconfig.json` so files can be moved between folders without breaking relative imports.
167+
- **Annotations**: Badges, boxes, highlights, and labels can be added to the `annotations` array using 800×450 reference coordinates. They are automatically scaled and composited onto both the standard and large images.
168+
142169
#### Generating screenshots
143170

144-
Run the screenshot automation script to generate the dual WebP files (standard `800×450` and large `3200×1800`):
171+
You can run individual screenshot scripts directly, or run all of them via the batch runner:
145172

146173
```bash
147-
bun run screenshots # Capture all documentation screenshots
148-
bun run screenshots editor-overview # Capture only a specific target
174+
# Run a single screenshot directly:
175+
bun docs/the-editor/overview/editor-overview.screenshot.ts
176+
177+
# Capture all configured documentation screenshots:
178+
bun run screenshots
179+
180+
# Capture matching targets by name or section directory:
181+
bun run screenshots editor-overview
182+
bun run screenshots the-editor
149183
```
150184

151185
#### Recording interactions for new screenshots
@@ -157,7 +191,7 @@ bun run screenshots:record
157191
bun run screenshots:record create-a-page
158192
```
159193

160-
This launches a headed Chromium browser with authenticated session mocks pre-applied and opens the **Playwright Inspector** GUI. Click the red **Record** button in the inspector, interact with the editor, and copy the recorded actions into `TARGETS` in `scripts/capture-screenshots.ts`.
194+
This launches a headed Chromium browser with authenticated session mocks pre-applied and opens the **Playwright Inspector** GUI. Click the red **Record** button in the inspector, interact with the editor, and copy the recorded actions into the `setup` function of your co-located `*.screenshot.ts` file.
161195

162196
#### Processing manual screenshots
163197

0 commit comments

Comments
 (0)