writing-s2-docs-pages
Skill131 starsChanged 10 days agoApache-2.0View on GitHub
Writes or updates a component page in the packages/docs-s2 docs site, including playgrounds, props tables, and stage badges. Use when documenting an S2 component or when a change alters its props, defaults, or behavior.
- Deletes or force-pushes
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adding-chart-marksSkill
- adding-child-componentsSkill
- adding-propsSkill
- chart-featuresSkill
- comparing-time-periodsSkill
- filing-issuesSkill
- fixing-bugsSkill
- implementing-milestonesSkill
- s2-design-tokensSkill
- summarizing-bugsSkill
- writing-rfcsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this skill when writing or updating a component page in packages/docs-s2, the S2 docs site.
- Distinctive: line 19
Before writing anything, list everything the page has to cover:
- Distinctive: line 41
Write the inventory down (session workspace or todo list) and check it off as the page is written.
- Distinctive: line 46
Every claim on the page must be checked against source or a running example: defaults, thresholds, interactions, what happens at edges.
- Distinctive: line 87
Put prop lists in bullets when a section introduces three or more props.
- Distinctive: line 88
Keep prose short. Don't repeat what the PropsTable already says.
- Very specific: line 89
Use :::note for unsupported features and known limits.
- Distinctive: line 146
Every playground renders, every control changes the chart, and disabled controls are disabled only when they should be.
- Very specific: line 155
Use the filing-issues skill for library bugs or missing behavior found while writing the page.
- Distinctive: line 156
Don't fix library bugs in the docs PR.
- Distinctive: line 160
When a feature or fix adds or changes a prop, child, or behavior of an S2 component:
- Very specific: line 162
Update the component's dev dashboard (packages/react-spectrum-charts-s2/src/dev/<Component>/Dashboards/) so the new variation is covered.
- Distinctive: line 165
Update the component's docs page: add or extend a playground control or section, and check the TSDoc so the PropsTable is right.
- Distinctive: line 167
If the change affects a sibling (Legend, Axis, ...), check that sibling's page and dashboard too.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Write an S2 Docs Page
Use this skill when writing or updating a component page in packages/docs-s2, the S2 docs
site. docs/donut.mdx and src/playgrounds/donut.tsx are the reference implementation; when
this skill and the Donut page disagree, follow this skill and fix the Donut page.
Also use it when a feature or bug fix changes a component's props, defaults, or behavior: the component's docs page and dev dashboard both need to reflect the change (Step 9).
Step 1 — Inventory the component
Before writing anything, list everything the page has to cover:
- Props — every prop in the component's S2 options type
(
packages/vega-spec-builder-s2/src/types/) and its React props type (packages/react-spectrum-charts-s2/src/types/). Include callbacks and props that only apply in combination (e.g.sortOrderwithvariant="semicircle"). - Children — every child component accepted in
childrenAdapter.tsfor this component. - Siblings — every
Chart-level prop and sibling component that changes this component's behavior:Axis,Legend,Title,ChartInspect,ChartPopover,ChartActionBar,hiddenSeries,highlightedSeries/highlightedItem,animationTypes,locale,loading,emptyStateText, sizing. - Data shapes — required fields, defaults (
value,series,datetime), edge cases (all zeros, empty array, single point, nulls, booleans, negatives). - Behavior — read the spec builder for defaults and rules a user can't infer from prop names (sort order, label collision, hover fading, what gets disabled when).
- Dev dashboard —
packages/react-spectrum-charts-s2/src/dev/<Component>/Dashboards/if one exists. Its coverage map lists every prop, child, and sibling the component interacts with; use it as a starting checklist, and every variation group there should map to a section or playground control on the page. - Gaps — compare against the S1 types (
packages/vega-spec-builder/src/types/) to find props S2 doesn't support yet. These go in a:::note.
Write the inventory down (session workspace or todo list) and check it off as the page is written. Nothing in it should be left uncovered unless it's listed as unsupported.
Step 2 — Verify behavior before describing it
Every claim on the page must be checked against source or a running example: defaults, thresholds, interactions, what happens at edges. If behavior looks wrong, don't document the bug as behavior; file it (Step 8) and either work around it in the example or leave it out.
Step 3 — Page structure
File: packages/docs-s2/docs/<component>.mdx, lowercase, hyphenated.
Frontmatter:
---
stage: alpha # lab | alpha | beta | rc | stable — matches the component's TSDoc tag
sidebar_position: 3
title: Donut
description: One sentence, what the component is for. Used by search and llms.txt.
---Body, in this order (omit sections that don't apply):
# Title, then<StageBadge />, then a one- or two-sentence intro, then the main playground.## Data— data shape, which props name the fields, defaults, one<DataCode>per dataset used, and a minimal code block. Subsections for special data (### Boolean data,### Zero, empty, and loading).- Sections for the component's own appearance and options, named by task or by the prop when
the prop name is the clearest label (
## Shape,### holeRatio,### Size). - One
##section per child component, named after the component (## DonutSummary,## SegmentLabel). - One
##section per relevant sibling (## Legend,## Axis), covering only how it behaves with this component. Link to the sibling's own page for the full reference. ## Interaction—ChartInspect/ChartPopover, highlighting, keyboard support (or a:::notethat it isn't supported).## Animation—animationTypesand what each animation does for this component.## API— one###per component with<PropsTable component="X" />, plus any prose about props that don't fit a section (e.g.name).
Writing rules:
- Lead with what the user wants to do, then the prop. Describe behavior, not implementation.
- Put prop lists in bullets when a section introduces three or more props.
- Keep prose short. Don't repeat what the PropsTable already says.
- Use
:::notefor unsupported features and known limits. - Link to other pages with relative links (
./legend.mdx#position).
Step 4 — Playgrounds
Playgrounds go in packages/docs-s2/src/playgrounds/<component>.tsx, one exported component
per example, named <Component><Topic>Playground. Each uses PropPlayground
(src/components/examples/PropPlayground.tsx) and the docs Chart wrapper (DocsChart).
- Coverage — every prop, child, and sibling from Step 1 is either a control in some
playground or shown in a dedicated example. Props that only apply in some states use
isDisabledso the control is disabled when it has no effect. - Controls — group controls by the component that owns the prop (
group: 'Legend'). Usedoc: 'Component.prop'so the info popover shows the prop's TSDoc. Defaults must match the library defaults so the generated code omits them. - Generated code — the code panel is generated from the rendered element. Check that it's minimal and copy-pasteable: no props equal to defaults, no docs-only props.
- Consistent size — add a
get<Component>PreviewSizehelper and pass it aspreviewSizeon every playground. Size examples to a preset from the component's dev dashboard (Donut uses L), leaving room for legends, titles, and labels. Previews never show the size in code. - Replay — set
replayon any playground where an animation is the point. - Data — add datasets to
src/components/examples/data.tsand show them with<DataCode name="..." />. Reuse existing datasets when they fit. Keep data realistic and small; avoid data that triggers known bugs. - Markdown export — agents implement from the page's
.mdexport, which is built from the rendered HTML. Wrap custom browser-only examples inClientOnlyand passmarkdownwith the code, data, and tables an agent needs;PropPlaygroundalready exports its code and controls. Wrap interaction-only instructions inWebOnly.
Step 5 — TSDoc
The PropsTable and control popovers read TSDoc through plugins/docgenPlugin.js. Every prop
of every component on the page needs a TSDoc description that states what it does and its
default. Fix missing or wrong TSDoc in the S2 types, not in the docs page.
Step 6 — Register the page
- Sidebar — add the doc id to
packages/docs-s2/sidebars.ts(lab components under a Lab category). - Search card — chart types get an entry in
src/search/chartExamples.tsx:docId,title,components(the chart and its children, so their prop names match),keywords(synonyms not in the title, e.g. "pie" for Donut), smalldata, andmarks. Non-chart components don't get a card; they're found through page search. - Stage —
stagein frontmatter must be a key insrc/stages.json.searchPluginfails the build otherwise.
Step 7 — Validate
From packages/docs-s2:
yarn -s typecheck
rm -rf .docusaurus && ../../node_modules/.bin/docusaurus build --out-dir /tmp/docs-s2-buildThen, from the repo root, yarn lint --quiet. In the built site, check:
- Every playground renders, every control changes the chart, and disabled controls are disabled only when they should be.
- Generated code matches the rendered chart.
/llms.txtlists the page and/<page>.mdreads cleanly as Markdown, with every example's code, data, and controls.- The page and its props show up in search, and the chart card appears.
Step 8 — File bugs found along the way
Use the filing-issues skill for library bugs or missing behavior found while writing the page.
Don't fix library bugs in the docs PR.
Step 9 — Keep docs and dashboards current
When a feature or fix adds or changes a prop, child, or behavior of an S2 component:
- Update the component's dev dashboard
(
packages/react-spectrum-charts-s2/src/dev/<Component>/Dashboards/) so the new variation is covered. - Update the component's docs page: add or extend a playground control or section, and check the TSDoc so the PropsTable is right.
- If the change affects a sibling (Legend, Axis, ...), check that sibling's page and dashboard too.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

