|
| 1 | +# Component Docs Format Spec |
| 2 | + |
| 3 | +Canonical reference for the structure, section order, writing rules, and review checklist of jalco ui component documentation pages. |
| 4 | + |
| 5 | +## Page anatomy |
| 6 | + |
| 7 | +Every component docs page MUST use `ComponentDocsPage` from `components/docs/component-docs-page.tsx` and follow this section order: |
| 8 | + |
| 9 | +1. **Metadata** — `export const metadata: Metadata` with `title` and `description` |
| 10 | +2. **Header** — rendered by `ComponentDocsPage`: title, description, AiCopyButton, DependencyBadges |
| 11 | +3. **Preview** — live component inside `ComponentPreview` with source file tabs |
| 12 | +4. **Installation** — `InstallCommand` with registry name; `installNote` for bundled exports |
| 13 | +5. **Usage** — import snippet via `CodeLine`, minimal usage example, server/client rendering context |
| 14 | +6. **Children** (optional, order as needed): |
| 15 | + - Playground |
| 16 | + - Examples (variants, sizes, configurations, etc.) |
| 17 | + - API Reference |
| 18 | + - Notes |
| 19 | + |
| 20 | +## ComponentDocsPage props |
| 21 | + |
| 22 | +| Prop | Type | Required | Purpose | |
| 23 | +|---|---|---|---| |
| 24 | +| `title` | `string` | yes | Display name (e.g. "GitHub Stars Button") | |
| 25 | +| `description` | `string` | yes | One-sentence summary | |
| 26 | +| `registryName` | `string` | no | Registry item name; enables install block and badges | |
| 27 | +| `sourceFiles` | `(string \| { path, name?, language? })[]` | no | Source file paths for the code tab | |
| 28 | +| `preview` | `ReactNode` | no | Live component for the Preview section | |
| 29 | +| `installNote` | `ReactNode` | no | Note below install command (e.g. bundled-in explanation) | |
| 30 | +| `usage` | `ReactNode` | no | Usage section content | |
| 31 | +| `children` | `ReactNode` | no | Everything after Usage | |
| 32 | + |
| 33 | +## Writing rules |
| 34 | + |
| 35 | +### Descriptions |
| 36 | + |
| 37 | +- MUST be one sentence, capability-first |
| 38 | +- MUST NOT start with "A", "An", or "A React component for..." |
| 39 | +- MUST NOT contain implementation details, subjective adjectives, or unnecessary jargon |
| 40 | +- MUST match across: page `metadata.description`, `ComponentDocsPage` `description` prop, and `registry.json` description |
| 41 | + |
| 42 | +### Usage section |
| 43 | + |
| 44 | +- MUST include an import snippet via `CodeLine` |
| 45 | +- MUST include a minimal usage example via `CodeLine` |
| 46 | +- Server/client rendering context MUST be stated here (e.g. "Async server component") |
| 47 | +- The first example SHOULD be minimal — layer complexity in the Examples section |
| 48 | + |
| 49 | +### Examples section |
| 50 | + |
| 51 | +- MUST use `VariantGrid` with labeled items when showing multiple visual states |
| 52 | +- MUST group items by meaning: Variants, Sizes, Icon Styles, Configurations, etc. |
| 53 | +- MUST NOT label everything as a "variant" — use the most accurate grouping label |
| 54 | +- SHOULD use realistic, polished content over placeholder text |
| 55 | + |
| 56 | +### Playground section |
| 57 | + |
| 58 | +- MAY be included when the component has multiple interactive props worth exploring |
| 59 | +- SHOULD be a client component that lets users toggle props and see results |
| 60 | + |
| 61 | +### API Reference section |
| 62 | + |
| 63 | +- SHOULD be included when the component has a non-obvious public API |
| 64 | +- MUST use `ApiRefTable` from `registry/api-ref-table/api-ref-table` |
| 65 | +- SHOULD list all public props with name, type, required flag, and description |
| 66 | + |
| 67 | +### Notes section |
| 68 | + |
| 69 | +- MUST contain only caveats, limitations, and external service behavior |
| 70 | +- MUST NOT contain architecture decisions, feature highlights, or rendering context |
| 71 | +- SHOULD be brief — a short bulleted list |
| 72 | + |
| 73 | +### Bundled exports |
| 74 | + |
| 75 | +- When a component is bundled inside another registry item, MUST use `installNote` to explain |
| 76 | +- MUST set `bundledIn` on the nav item in `lib/docs.ts` |
| 77 | + |
| 78 | +## Section heading style |
| 79 | + |
| 80 | +All `<h2>` headings inside `ComponentDocsPage` children MUST use: |
| 81 | + |
| 82 | +```tsx |
| 83 | +<h2 className="text-xl font-semibold tracking-tight">Section Title</h2> |
| 84 | +``` |
| 85 | + |
| 86 | +Sub-headings (`<h3>`) inside example groups MUST use: |
| 87 | + |
| 88 | +```tsx |
| 89 | +<h3 className="text-base font-medium">Group Label</h3> |
| 90 | +``` |
| 91 | + |
| 92 | +## Naming alignment |
| 93 | + |
| 94 | +These MUST all refer to the same artifact using consistent naming: |
| 95 | +- page `metadata.title` |
| 96 | +- `ComponentDocsPage` `title` prop |
| 97 | +- `registry.json` item `title` |
| 98 | +- sidebar nav title in `lib/docs.ts` |
| 99 | +- preview file name in `components/docs/previews/` |
| 100 | +- component export name |
| 101 | + |
| 102 | +## File header and comment rules |
| 103 | + |
| 104 | +- Public Jalco-authored component source files SHOULD use the compact Jalco-style header |
| 105 | +- Headers MUST be compact and human-written in tone |
| 106 | +- Headers MUST NOT duplicate the docs page content |
| 107 | +- Decorative separator banners MUST NOT appear in source code |
| 108 | +- Inline comments MUST be minimal and useful |
| 109 | +- Comments MUST NOT narrate straightforward code |
| 110 | + |
| 111 | +## Review checklist |
| 112 | + |
| 113 | +Before shipping a component docs page, verify: |
| 114 | + |
| 115 | +- [ ] Page uses `ComponentDocsPage` |
| 116 | +- [ ] `metadata.description` matches `ComponentDocsPage` `description` and `registry.json` |
| 117 | +- [ ] Preview renders a realistic default state |
| 118 | +- [ ] Usage includes import, minimal example, and server/client context |
| 119 | +- [ ] Examples use `VariantGrid` with accurate group labels |
| 120 | +- [ ] Notes contains only caveats (no features, no architecture) |
| 121 | +- [ ] Sidebar entry in `lib/docs.ts` is correct (title, order, badge, bundledIn) |
| 122 | +- [ ] Card preview exists at `components/docs/previews/<registry-name>.tsx` |
| 123 | +- [ ] Screenshots exist at `public/previews/<name>-dark.png` and `<name>-light.png` |
| 124 | +- [ ] `pnpm previews:generate` has been run |
| 125 | +- [ ] `pnpm registry:build` and `pnpm build` pass |
0 commit comments