From b1c802279463e749766aabdafbcf5282c008ee09 Mon Sep 17 00:00:00 2001 From: Darius Cepulis Date: Fri, 13 Feb 2026 14:04:55 -0600 Subject: [PATCH] chore(site): audit and encode docs patterns (#535) Co-authored-by: Claude Opus 4.6 --- .claude/skills/README.md | 10 +- .claude/skills/api-reference/SKILL.md | 101 ++++ .../references/builder-conventions.md | 85 ++++ .../api-reference/references/demo-patterns.md | 274 +++++++++++ .../api-reference/references/mdx-structure.md | 225 +++++++++ .claude/skills/api/SKILL.md | 2 +- .claude/skills/aria/SKILL.md | 2 +- .claude/skills/claude-update/SKILL.md | 2 +- .claude/skills/component/SKILL.md | 3 +- .claude/skills/create-skill/SKILL.md | 2 +- .claude/skills/design/SKILL.md | 2 +- .claude/skills/docs/SKILL.md | 435 +++++++---------- .claude/skills/docs/examples/good-bad.md | 310 ------------ .claude/skills/docs/examples/tone-samples.md | 282 ----------- .claude/skills/docs/patterns/ai-readiness.md | 332 ------------- .claude/skills/docs/patterns/code-examples.md | 382 +++++++-------- .../docs/patterns/progressive-disclosure.md | 303 ------------ .claude/skills/docs/patterns/props-tables.md | 255 ---------- .../docs/references/component-libraries.md | 15 +- .../skills/docs/references/multi-framework.md | 28 -- .../skills/docs/references/state-tooling.md | 3 +- .../skills/docs/references/writing-style.md | 149 ++++++ .claude/skills/docs/review/agents.md | 236 +++------ .claude/skills/docs/review/checklist.md | 59 +++ .claude/skills/docs/review/issue-format.md | 96 ---- .claude/skills/docs/review/merge-template.md | 120 ----- .claude/skills/docs/review/templates.md | 168 +++++++ .claude/skills/docs/review/workflow.md | 93 ++-- .../skills/docs/templates/api-reference.md | 460 ------------------ .../skills/docs/templates/component-page.md | 421 ---------------- .claude/skills/docs/templates/concept.md | 90 ++++ .claude/skills/docs/templates/guide.md | 330 ------------- .claude/skills/docs/templates/handbook.md | 251 ---------- .claude/skills/docs/templates/how-to.md | 98 ++++ .../skills/docs/templates/migration-guide.md | 313 ------------ .claude/skills/docs/templates/readme.md | 278 +++-------- .claude/skills/gh-issue/SKILL.md | 3 +- .claude/skills/review-branch/SKILL.md | 7 +- .claude/skills/rfc/SKILL.md | 2 +- CLAUDE.md | 17 +- CONTRIBUTING.md | 2 +- .../html/css/BasicUsage.css | 10 +- .../html/css/BasicUsage.html | 6 +- .../react/css/BasicUsage.css | 10 +- .../react/css/BasicUsage.tsx | 6 +- .../demos/controls/html/css/BasicUsage.css | 24 +- .../demos/controls/html/css/BasicUsage.html | 10 +- .../demos/controls/react/css/BasicUsage.css | 16 +- .../demos/controls/react/css/BasicUsage.tsx | 10 +- .../fullscreen-button/html/css/BasicUsage.css | 14 +- .../html/css/BasicUsage.html | 4 +- .../react/css/BasicUsage.css | 6 +- .../react/css/BasicUsage.tsx | 4 +- .../demos/mute-button/html/css/BasicUsage.css | 14 +- .../mute-button/html/css/BasicUsage.html | 4 +- .../mute-button/html/css/VolumeLevels.astro | 10 + .../mute-button/html/css/VolumeLevels.css | 41 ++ .../mute-button/html/css/VolumeLevels.html | 15 + .../mute-button/html/css/VolumeLevels.ts | 2 + .../mute-button/react/css/BasicUsage.css | 6 +- .../mute-button/react/css/BasicUsage.tsx | 4 +- .../mute-button/react/css/VolumeLevels.css | 21 + .../mute-button/react/css/VolumeLevels.tsx | 35 ++ .../demos/pip-button/html/css/BasicUsage.css | 14 +- .../demos/pip-button/html/css/BasicUsage.html | 4 +- .../demos/pip-button/react/css/BasicUsage.css | 6 +- .../demos/pip-button/react/css/BasicUsage.tsx | 4 +- .../demos/play-button/html/css/BasicUsage.css | 26 +- .../play-button/html/css/BasicUsage.html | 6 +- .../play-button/react/css/BasicUsage.css | 6 +- .../play-button/react/css/BasicUsage.tsx | 9 +- .../docs/demos/poster/html/css/BasicUsage.css | 20 +- .../demos/poster/html/css/BasicUsage.html | 6 +- .../demos/poster/react/css/BasicUsage.css | 10 +- .../demos/poster/react/css/BasicUsage.tsx | 6 +- .../demos/seek-button/html/css/BasicUsage.css | 16 +- .../seek-button/html/css/BasicUsage.html | 8 +- .../seek-button/react/css/BasicUsage.css | 8 +- .../seek-button/react/css/BasicUsage.tsx | 8 +- .../demos/time/html/css/CurrentDuration.css | 6 +- .../demos/time/html/css/CurrentDuration.html | 4 +- .../docs/demos/time/html/css/CurrentTime.css | 6 +- .../docs/demos/time/html/css/CurrentTime.html | 4 +- .../time/html/css/CustomNegativeSign.css | 6 +- .../time/html/css/CustomNegativeSign.html | 4 +- .../demos/time/html/css/CustomSeparator.css | 6 +- .../demos/time/html/css/CustomSeparator.html | 4 +- .../docs/demos/time/html/css/Remaining.css | 6 +- .../docs/demos/time/html/css/Remaining.html | 4 +- .../demos/time/react/css/CurrentDuration.css | 6 +- .../demos/time/react/css/CurrentDuration.tsx | 4 +- .../docs/demos/time/react/css/CurrentTime.css | 6 +- .../docs/demos/time/react/css/CurrentTime.tsx | 4 +- .../time/react/css/CustomNegativeSign.css | 6 +- .../time/react/css/CustomNegativeSign.tsx | 4 +- .../demos/time/react/css/CustomSeparator.css | 6 +- .../demos/time/react/css/CustomSeparator.tsx | 4 +- .../docs/demos/time/react/css/Remaining.css | 6 +- .../docs/demos/time/react/css/Remaining.tsx | 4 +- site/src/content/docs/how-to/write-guides.mdx | 52 +- .../docs/reference/buffering-indicator.mdx | 8 + site/src/content/docs/reference/controls.mdx | 33 ++ .../docs/reference/fullscreen-button.mdx | 61 ++- .../content/docs/reference/mute-button.mdx | 62 +++ .../src/content/docs/reference/pip-button.mdx | 27 + .../content/docs/reference/play-button.mdx | 30 ++ site/src/content/docs/reference/poster.mdx | 20 + .../content/docs/reference/seek-button.mdx | 8 + site/src/content/docs/reference/time.mdx | 36 ++ .../docs/reference/write-references.mdx | 205 ++++++++ site/src/docs.config.ts | 5 + 111 files changed, 2680 insertions(+), 4642 deletions(-) create mode 100644 .claude/skills/api-reference/SKILL.md create mode 100644 .claude/skills/api-reference/references/builder-conventions.md create mode 100644 .claude/skills/api-reference/references/demo-patterns.md create mode 100644 .claude/skills/api-reference/references/mdx-structure.md delete mode 100644 .claude/skills/docs/examples/good-bad.md delete mode 100644 .claude/skills/docs/examples/tone-samples.md delete mode 100644 .claude/skills/docs/patterns/ai-readiness.md delete mode 100644 .claude/skills/docs/patterns/progressive-disclosure.md delete mode 100644 .claude/skills/docs/patterns/props-tables.md delete mode 100644 .claude/skills/docs/references/multi-framework.md create mode 100644 .claude/skills/docs/references/writing-style.md create mode 100644 .claude/skills/docs/review/checklist.md delete mode 100644 .claude/skills/docs/review/issue-format.md delete mode 100644 .claude/skills/docs/review/merge-template.md create mode 100644 .claude/skills/docs/review/templates.md delete mode 100644 .claude/skills/docs/templates/api-reference.md delete mode 100644 .claude/skills/docs/templates/component-page.md create mode 100644 .claude/skills/docs/templates/concept.md delete mode 100644 .claude/skills/docs/templates/guide.md delete mode 100644 .claude/skills/docs/templates/handbook.md create mode 100644 .claude/skills/docs/templates/how-to.md delete mode 100644 .claude/skills/docs/templates/migration-guide.md create mode 100644 site/src/components/docs/demos/mute-button/html/css/VolumeLevels.astro create mode 100644 site/src/components/docs/demos/mute-button/html/css/VolumeLevels.css create mode 100644 site/src/components/docs/demos/mute-button/html/css/VolumeLevels.html create mode 100644 site/src/components/docs/demos/mute-button/html/css/VolumeLevels.ts create mode 100644 site/src/components/docs/demos/mute-button/react/css/VolumeLevels.css create mode 100644 site/src/components/docs/demos/mute-button/react/css/VolumeLevels.tsx create mode 100644 site/src/content/docs/reference/write-references.mdx diff --git a/.claude/skills/README.md b/.claude/skills/README.md index 4c7ef226..f18bde6e 100644 --- a/.claude/skills/README.md +++ b/.claude/skills/README.md @@ -10,8 +10,9 @@ Specialized knowledge for AI agents working on Video.js 10. | Building HTML components | `component` + `aria` | | Building React components | `component` + `aria` | | Writing documentation | `docs` | -| Writing Design Docs / RFCs | `design` or `rfc` | -| Reviewing API/architecture | `api` → `review/workflow.md` | +| Writing component reference| `api-reference` | +| Writing Design Docs / RFCs | `design` or `rfc` | +| Reviewing API/architecture | `api` → `review/workflow.md` | | Reviewing documentation | `docs` → `review/workflow.md` | | Reviewing components | `component` → `review/workflow.md` | | Reviewing accessibility | `aria` → `review/workflow.md` | @@ -33,7 +34,8 @@ Specialized knowledge for AI agents working on Video.js 10. | [component](component/SKILL.md) | Build headless UI components — compound patterns, state, styling | Yes | | [create-skill](create-skill/SKILL.md) | Create new skills with proper structure and conventions | No | | [design](design/SKILL.md) | Write Design Docs — decisions you own, component specs, feature designs| No | -| [docs](docs/SKILL.md) | Write Video.js 10 documentation | Yes | +| [api-reference](api-reference/SKILL.md) | Scaffold component API reference pages | No | +| [docs](docs/SKILL.md) | Write Video.js 10 documentation (concepts, how-to, READMEs) | Yes | | [gh-issue](gh-issue/SKILL.md) | Analyze GitHub issues and create implementation plans | No | | [git](git/SKILL.md) | Git workflow — commit messages, PRs, branch naming, scope inference | No | | [review-branch](review-branch/SKILL.md) | Review branch changes and suggest improvements | No | @@ -56,7 +58,7 @@ skill/ | Skill | Review Focus | | ------------------- | ------------------------------------------------- | | `api/review/` | API design, architecture, DX, type safety | -| `docs/review/` | Documentation quality — tone, structure, examples | +| `docs/review/` | Documentation quality — tone, structure, examples | | `component/review/` | Component architecture, state, props, styling | | `aria/review/` | Accessibility — ARIA, keyboard, focus, WCAG | diff --git a/.claude/skills/api-reference/SKILL.md b/.claude/skills/api-reference/SKILL.md new file mode 100644 index 00000000..f4c42557 --- /dev/null +++ b/.claude/skills/api-reference/SKILL.md @@ -0,0 +1,101 @@ +--- +name: api-reference +description: >- + Scaffold API reference documentation for Video.js 10 components. Validates + the api-docs-builder output, checks design docs and linked PRs for context, + creates the MDX reference page with anatomy, prose sections, demos, and the + ApiReference component. Triggers: "api reference", "reference page", + "scaffold api docs", "add api docs", "component reference". +--- + +# API Reference + +Scaffold a complete API reference page for a Video.js 10 component. + +## Usage + +``` +/api-reference [component-name] +``` + +- `component-name` (optional): kebab-case component name (e.g., `play-button`). If omitted, will prompt. + +## Arguments + +$ARGUMENTS + +## Reference Material + +Load these files based on task: + +| Need | Load | +|------|------| +| Builder naming conventions | `references/builder-conventions.md` | +| MDX page structure | `references/mdx-structure.md` | +| Demo file patterns | `references/demo-patterns.md` | +| Component libraries reference | `docs` skill → `references/component-libraries.md` | +| Component patterns | `component` skill | +| Accessibility | `aria` skill | +| Design docs | `internal/design/` | + +## Your Tasks + +### Step 1: Gather context + +Accept component name as argument (kebab-case). + +1. Read the core file at `packages/core/src/core/ui/{name}/{name}-core.ts` — extract Props, State, behavior +2. Read data-attrs file at `packages/core/src/core/ui/{name}/{name}-data-attrs.ts` — extract data attributes +3. Check `packages/react/src/ui/{name}/index.parts.ts` — detect if multi-part +4. Search `internal/design/` for matching design doc: `internal/design/**/*{name}*`. If no design doc is found, proceed — the core file is the primary source of truth; design docs are supplementary context. +5. Read the HTML element file(s) for tag names at `packages/html/src/ui/{name}/` +6. (Optional) Use `git log --oneline --all -- packages/core/src/core/ui/{name}` to find the commit that added the component, then check linked PRs via `gh pr list --search` for additional context. This enriches understanding but steps 1-3 and 5 are sufficient to build the reference page. + +### Step 2: Validate api-docs-builder compatibility + +1. Run `pnpm -F site api-docs` and check for errors +2. Read the generated JSON at `site/src/content/generated-api-reference/{name}.json` +3. Verify the JSON has expected sections (props, state, dataAttributes, platforms.html.tagName) +4. For multi-part: verify each part appears in `parts` with correct names + +If JSON is missing or incomplete, diagnose which convention isn't met. Load `references/builder-conventions.md` for the full list of naming requirements and common failures. Propose fixes: either adjust the component to match conventions, or add a name override — prefer aligning with conventions unless there's good reason not to. + +### Step 3: Determine relevant prose sections + +Based on design docs, core logic, and component complexity, decide which sections to include between `## Anatomy` and `## Examples`. Not all are required — include only what adds value: + +- **Behavior** — include when the component has state transitions, timing, interaction logic, or non-obvious behavior (e.g., Controls auto-hide, BufferingIndicator delay, Time formatting). Skip for trivial components. +- **Styling** — include when the component has data attributes for CSS targeting. Show CSS selector patterns. Always include for components with 2+ data attributes. +- **Accessibility** — include when the component has ARIA attributes, keyboard interactions, or screen reader considerations. Always include for interactive components (buttons, sliders). +- Other sections may be relevant depending on the component (e.g., "Platform Support" for features with availability detection). + +### Step 4: Create demos + +Create at least a BasicUsage demo in both HTML and React. Load `references/demo-patterns.md` for the full file structure and conventions. + +- HTML demo: 4 files (`.astro`, `.html`, `.css`, `.ts`) +- React demo: 2 files (`.tsx`, `.css`) +- Follow BEM naming: `{framework}-{component}-{variant}__{element}` +- CSS uses data-attribute selectors for state-based styling +- React uses `render` prop for state-based rendering +- Video source: `https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4` +- Poster image: `https://image.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/thumbnail.jpg` +- Consider additional demos for features not covered by BasicUsage + +### Step 5: Create MDX reference page + +Load `references/mdx-structure.md` for the full structure template. + +1. Create `site/src/content/docs/reference/{name}.mdx` +2. Add to sidebar in `site/src/docs.config.ts` (alphabetically within Components section) +3. Structure: frontmatter → imports → Anatomy → prose sections → Examples → `` +4. Run `pnpm dev` from root and verify the page renders in both HTML and React framework modes + +## Related Skills + +| Need | Use | +|------|-----| +| Building UI components | `component` skill | +| Accessibility patterns | `aria` skill | +| Documentation standards | `docs` skill | +| API design principles | `api` skill | diff --git a/.claude/skills/api-reference/references/builder-conventions.md b/.claude/skills/api-reference/references/builder-conventions.md new file mode 100644 index 00000000..6e4fa088 --- /dev/null +++ b/.claude/skills/api-reference/references/builder-conventions.md @@ -0,0 +1,85 @@ +# Builder Conventions + +Naming and file placement conventions required by the api-docs-builder at `site/scripts/api-docs-builder/`. + +## File Locations + +| File | Path | Purpose | +|------|------|---------| +| Core | `packages/core/src/core/ui/{name}/{name}-core.ts` | Props, State, defaultProps | +| Data attrs | `packages/core/src/core/ui/{name}/{name}-data-attrs.ts` | Data attribute definitions | +| HTML element | `packages/html/src/ui/{name}/{name}-element.ts` | Custom element with `static tagName` | +| React parts | `packages/react/src/ui/{name}/index.parts.ts` | Multi-part detection (optional) | + +## Naming Requirements + +The builder derives PascalCase from kebab-case using `kebabCase` from es-toolkit. All interfaces and exports must follow this pattern: + +| Convention | Example (play-button) | +|-----------|----------------------| +| Props interface | `PlayButtonProps` | +| State interface | `PlayButtonState` | +| Core class | `PlayButtonCore` | +| Data attrs export | `PlayButtonDataAttrs` | +| HTML element class | `PlayButtonElement` | +| HTML tag name | `static tagName = 'media-play-button'` | + +## NAME_OVERRIDES + +When kebab-to-pascal conversion doesn't produce the correct name, add an override in `site/scripts/api-docs-builder/src/index.ts`: + +```ts +const NAME_OVERRIDES: Record = { + 'pip-button': 'PiPButton', +}; +``` + +Use overrides only when the standard conversion fails (e.g., acronyms like PiP). Prefer aligning component naming with the standard conversion when possible. + +## Multi-Part Components + +**Detection**: Presence of `packages/react/src/ui/{name}/index.parts.ts`. + +**Primary part identification**: The part whose HTML element file is `{name}-element.ts` (not `{name}-{part}-element.ts`). The primary part receives the shared core props/state/data-attrs. + +**Non-primary parts**: Each gets its own element file at `{name}-{part}-element.ts`. Element class must be `{Name}{Part}Element` (e.g., `TimeGroupElement`). + +**Part descriptions**: Extracted from JSDoc on the React component export: +```tsx +/** Displays a formatted time value. */ +export const Value = ...; +``` + +## JSDoc Extraction + +- **Data attribute descriptions**: From JSDoc comments on each property in the data-attrs export object +- **Part descriptions**: From JSDoc on React component exports in their `.tsx` files +- **Prop/state descriptions**: From JSDoc on interface properties in the core file + +## Common Failures + +The builder fails silently for many issues — data just won't appear in the JSON: + +| Symptom | Cause | +|---------|-------| +| No JSON generated | Core file missing or Props interface not found | +| Empty props | Interface not named `{PascalCase}Props` | +| Empty state | Interface not named `{PascalCase}State` | +| No data attributes | File missing or export not named `{PascalCase}DataAttrs` | +| No HTML tag | Element file missing or no `static tagName` | +| No part descriptions | Missing JSDoc on React component exports | +| Wrong PascalCase | Need a `NAME_OVERRIDES` entry | + +## Validation + +```bash +# Generate JSON +pnpm -F site api-docs + +# Check output +cat site/src/content/generated-api-reference/{name}.json + +# Verify schema +# The builder validates against ComponentApiReferenceSchema before writing. +# Schema errors are logged as errors and cause exit code 1. +``` diff --git a/.claude/skills/api-reference/references/demo-patterns.md b/.claude/skills/api-reference/references/demo-patterns.md new file mode 100644 index 00000000..45d64079 --- /dev/null +++ b/.claude/skills/api-reference/references/demo-patterns.md @@ -0,0 +1,274 @@ +# Demo Patterns + +File structure and conventions for interactive component demos. + +## Directory Structure + +``` +site/src/components/docs/demos/{component}/ +├── html/css/ +│ ├── BasicUsage.astro # Astro wrapper (renders HTML, imports CSS, bundles script) +│ ├── BasicUsage.html # Markup only (no