Skip to content

FRD: createComponentDocs Coverage

FieldValue
IDFRD-040
OwnerDavid Holmes
StatusDraft
PriorityP1 — Developer Experience
SizeL (Refactor)
Target Releasev2.0.0
Last Updated2026-05-26

Document Summary

Achieve 100% coverage of createComponentDocs across every story file in the design system. Every *.stories.tsx file must call createComponentDocs with meaningful values for summary, whenToUse, whenNotToUse, and accessibility fields. The pnpm run dx:audit command must report zero violations for missing or empty documentation fields.


Introduction

Overview

createComponentDocs (defined in src/lib/storybook-docs.ts) is the canonical way to attach structured documentation metadata to a Storybook story. It powers the docs page summary, “When to use” / “When not to use” guidance, accessibility notes, and the LLM MCP contract. Today, many story files either do not call createComponentDocs at all or call it with empty/placeholder values, leaving developers without the guidance they need to choose and use components correctly.

Goals

  • Every *.stories.tsx file calls createComponentDocs in its meta configuration.
  • The summary field contains a concise 1-2 sentence description of the component’s purpose.
  • The whenToUse field describes at least two concrete scenarios where the component is appropriate.
  • The whenNotToUse field describes at least one scenario where a different component is a better choice.
  • The accessibility field documents keyboard behavior, ARIA roles, and screen reader expectations.
  • pnpm run dx:audit enforces all of the above with zero tolerance.

Non-Goals

  • Rewriting component implementations or APIs.
  • Adding new components.
  • Changing the createComponentDocs function signature (unless a field is missing).
  • Migrating to a different documentation framework.

Scope

In Scope

ItemDescription
Story file auditIdentify every *.stories.tsx file missing createComponentDocs or with empty required fields
Documentation authoringWrite summary, whenToUse, whenNotToUse, and accessibility content for each component
Audit script rulesAdd detection for missing createComponentDocs call and empty required fields to scripts/checks/audit-story-dx.mjs
CI enforcementpnpm run dx:audit blocks merge on missing documentation

Out of Scope

ItemReason
Optional createComponentDocs fieldsFields like dummyData, motion, courtRules are domain-specific and not universally required
MDX documentation pagesMDX pages are authored separately and not governed by createComponentDocs
Component visual changesThis is a documentation-only effort

Users and Pain Points

UserPain Point
Application developerOpens a component docs page and sees no usage guidance — unclear when to use vs. alternatives
Application developerNo accessibility notes — must read source code to understand keyboard and screen reader behavior
Design system maintainerInconsistent documentation quality across components
LLM agent (MCP consumer)Missing summary and whenToUse fields degrade the quality of LLM-generated integration code

Definitions

TermDefinition
createComponentDocsFactory function in src/lib/storybook-docs.ts that generates Storybook parameters.docs configuration
Required fieldssummary, whenToUse, whenNotToUse, accessibility — must be non-empty strings
LLM MCP contractStructured metadata emitted by createComponentDocs for consumption by LLM tool-use agents

Current State

  • createComponentDocs exists and is used by some story files (observed in widgets like user-menu.stories.tsx, activity-feed-widget.stories.tsx, global-search-bar.stories.tsx).
  • Many UI component stories in src/components/ui/ do not use createComponentDocs at all.
  • The dx:audit script checks some documentation aspects but does not enforce the presence of all four required fields.
  • There is no inventory of coverage percentage.

Proposed Solution

Phase 1: Inventory

Extend scripts/checks/audit-story-dx.mjs to report on createComponentDocs coverage:

  • Detect story files that do not import or call createComponentDocs.
  • Detect calls where summary, whenToUse, whenNotToUse, or accessibility is missing or empty.
  • Produce a coverage report with counts and percentages.

Phase 2: Author documentation

For each non-compliant story file:

  1. Read the component source to understand its purpose, API, and accessibility behavior.
  2. Write a summary (1-2 sentences describing what the component does and when it is useful).
  3. Write whenToUse (2+ concrete scenarios as a markdown list).
  4. Write whenNotToUse (1+ scenarios with recommended alternatives).
  5. Write accessibility (keyboard interactions, ARIA roles, screen reader announcements).
  6. Add the createComponentDocs call to the story meta’s parameters.

Phase 3: Enforce in CI

Remove any --warn-only exception for documentation coverage rules. Ensure pnpm run dx:audit exits non-zero on any missing documentation.


Requirements

IDRequirementPriority
REQ-01Every *.stories.tsx file must call createComponentDocsMust
REQ-02summary field must be a non-empty string of at least 20 charactersMust
REQ-03whenToUse field must be a non-empty stringMust
REQ-04whenNotToUse field must be a non-empty stringMust
REQ-05accessibility field must be a non-empty stringMust
REQ-06pnpm run dx:audit must detect and report all violationsMust
REQ-07Optional fields (dummyData, motion, etc.) should be filled when applicableShould

Functional Requirements

IDDescriptionAcceptance
FR-01Audit script detects story files without createComponentDocsLists all non-compliant files
FR-02Audit script detects empty required fieldsLists file, field name, and current value
FR-03Audit script reports coverage percentageOutputs X/Y stories compliant (Z%)
FR-04Each component’s docs page shows summary, when to use, when not to use, and accessibility sectionsVisual verification on 10 sample components

Non-Functional Requirements

IDDescriptionTarget
NFR-01Audit script execution timeUnder 10 seconds
NFR-02Documentation accuracyEvery summary and whenToUse must be reviewed by a human for correctness
NFR-03ConsistencyDocumentation follows a consistent voice and format across all components

API/Interface Requirements

InterfaceRequirement
createComponentDocsNo API changes required; existing signature supports all required fields
scripts/checks/audit-story-dx.mjsNew rules: missing-component-docs, empty-summary, empty-when-to-use, empty-when-not-to-use, empty-accessibility

Accessibility Requirements

IDRequirement
A11Y-01Every component’s accessibility field must document keyboard interactions (Tab, Enter, Escape, Arrow keys as applicable)
A11Y-02Every component’s accessibility field must document ARIA roles and properties used
A11Y-03Every component’s accessibility field must document screen reader announcements and live region behavior where applicable

Content and Documentation Requirements

IDRequirement
DOC-01Create a style guide for writing createComponentDocs fields (tone, length, format)
DOC-02Add createComponentDocs requirement to the “How to Write a Story” guide
DOC-03Document the new audit rules in the scripts/checks/audit-story-dx.mjs JSDoc header

Dependencies

DependencyTypeRisk
src/lib/storybook-docs.tsInternalFunction signature must remain stable during the documentation push
scripts/checks/audit-story-dx.mjsInternalMust be extended before bulk authoring begins
Component source codeInternalDocumentation accuracy depends on reading current implementation

Risks and Tradeoffs

RiskImpactMitigation
Large number of story files (~150+)Slow deliveryBatch by component directory; prioritize high-usage components first
Documentation may become stale as APIs evolveInaccurate guidanceCI audit catches empty fields; PR reviewers check accuracy on component changes
Subjective quality of documentation contentInconsistencyPublish a style guide before bulk authoring; review a sample set for calibration
LLM-authored documentation may have inaccuraciesMisleading guidanceHuman review required for every batch

Open Questions

#QuestionStatus
1Should accessibility be required for purely decorative components (Divider, Skeleton)?Open
2Should we require relatedComponents as a fifth required field?Open
3What minimum character count should be enforced for whenToUse and whenNotToUse?Open

Acceptance Criteria

  • pnpm run dx:audit reports zero violations for createComponentDocs coverage.
  • Every *.stories.tsx file imports and calls createComponentDocs.
  • Every summary field is a non-empty, accurate description (20+ characters).
  • Every whenToUse field lists at least two concrete use cases.
  • Every whenNotToUse field lists at least one alternative with rationale.
  • Every accessibility field documents keyboard behavior and ARIA usage.
  • CI pipeline blocks merge on any new missing-documentation violation.

LLM Handoff Instructions

When an LLM agent picks up this FRD:

  1. Run pnpm run dx:audit to get the current list of non-compliant story files.
  2. Read src/lib/storybook-docs.ts to understand the createComponentDocs API and its field semantics.
  3. For each non-compliant story file, read the corresponding component .tsx file to understand its purpose, props, and accessibility behavior.
  4. Write documentation following these guidelines:
    • summary: “A [component type] that [what it does]. Use it to [primary use case].”
    • whenToUse: Markdown list of 2+ scenarios with brief explanations.
    • whenNotToUse: Markdown list of 1+ scenarios with recommended alternatives.
    • accessibility: Document keyboard interactions, ARIA roles, and screen reader behavior.
  5. After fixing a batch, run pnpm run dx:audit and pnpm typecheck to verify.
  6. Do not modify component implementations — only story files and the audit script.

Decision Log

DateDecisionRationale
2026-05-26Require four fields: summary, whenToUse, whenNotToUse, accessibilityThese four provide the minimum useful documentation for component selection and integration
2026-05-26Extend existing audit script rather than a separate linterSingle tool for all DX audit rules reduces CI complexity

Document History

DateVersionAuthorChanges
2026-05-260.1David HolmesInitial draft