BXUP Track progress & test yourself — free
Frontend & Mobile · Playbook · Foundation · ~4 min read
FRONTEND & MOBILE · PLAYBOOK · FOUNDATION

Generate Design-System Docs and Migration Guides from Component Source

Component docs rot because they are written apart from the code. Generate them from what cannot lie — the component source, its types, and its stories — and the docs stay a projection of reality: usage guidelines, do/don't examples, and migrate-off-the-old-component guides, all reviewable in one sitting.

Tier: Foundation · Workflow area: Design-to-code & design systems

This playbook produces two artifacts your design system is probably missing: per-component usage docs that answer "which variant, when?", and migration guides that finally let you delete the deprecated component.

USE THIS WHEN

Docs are the bottleneck

  • The design system has good components and no prose — adoption stalls on "how do I use this?" Slack threads.
  • A component is deprecated but 60 call sites still import it because nobody wrote the migration path.
  • Storybook autodocs shows props tables, but nothing explains intent, composition, or accessibility contract.
  • New joiners keep building look-alikes because they cannot find or understand the real component.
SKIP IT WHEN

Generation cannot help

  • The component's API is still churning weekly — generated docs would rot as fast as handwritten ones; wait for stability.
  • The source itself is the problem (untyped props, any everywhere) — fix the types first; docs generated from props: any are fiction.
  • You need conceptual system-level docs (theming philosophy, layout principles) — that is authored thinking, not extraction.

Prerequisites

  • Typed component source (TypeScript props, or PropTypes at minimum) and ideally existing stories.
  • Storybook with autodocs available (tags: ['autodocs']) if you want the output rendered next to the live component.
  • One real consumer of the component open in a tab — you will need it to sanity-check the generated examples.

The recipe

  1. Feed the model evidence, not adjectives. For each component, provide the four files that constrain the truth:

    Context: Button.tsx (source), Button.stories.tsx, Button.test.tsx, and
    grep output of 12 real call sites across the repo. Write usage docs as
    MDX with sections: Purpose (2 sentences), When to use / When not to
    (link the alternative component for each "not"), Props worth explaining
    (skip the autodocs table — only props with non-obvious behavior),
    Do/Don't pairs (4, each with a code snippet), Accessibility contract
    (keyboard behavior, ARIA it manages, what the CONSUMER must still
    provide). Every claim must be derivable from the provided files — if
    the source doesn't show it, don't write it.
    

    The call-site grep matters most: real usage teaches the model your team's idioms, so examples come out in your patterns instead of generic React.

  2. Make the do/don'ts concrete pairs. Vague guidance ("use appropriately") is filler. Demand the failure mode:

    Each Don't must show code someone on this team actually might write
    (check the call sites for near-misses) and name the consequence:
    broken focus ring, off-token color, double padding. Pair it with the
    Do that fixes it, using the same scenario.
    

    A generated pair worth keeping looks like:

    // Don't: onClick on a styled div — invisible to keyboard and AT
    <div className="btn-primary" onClick={save}>Save</div>
    
    // Do: variant prop carries the styling, semantics come free
    <Button variant="primary" onClick={save}>Save</Button>
    
  3. Verify against the source, not your memory. Read the draft with the component open. Three checks per doc: does every named prop exist with that exact name and type; does the accessibility contract match what the code does (if docs say "manages aria-expanded", find that line); do the examples compile — paste one into the repo and typecheck it. Models write plausible props (isDisabled for disabled) constantly; this five-minute pass catches them.

  4. Generate the migration guide from both sources. For the deprecated-component problem, give the model old source, new source, and the diff of one already-migrated call site if you have one:

    OldModal.tsx is deprecated in favor of Dialog.tsx. Produce
    MIGRATION.md with: (1) a prop-mapping table — old prop | new prop |
    notes, flagging every behavioral difference (default changed, prop
    removed, event signature changed); (2) three before/after examples
    covering the common, the composed, and the gnarly call-site patterns
    you see in the attached grep of all 60 current usages; (3) a
    "cannot migrate mechanically" list for call sites using removed
    behavior, each with the recommended rewrite.
    

    The prop-mapping table is the load-bearing part — it is what turns 60 manual migrations into a checklist, and what a codemod (or a follow-up agent sweep) can execute against.

  5. Wire the output where engineers already look. Paste the MDX into the story file's docs page or a co-located Button.mdx so Storybook autodocs renders prose and live props table together. Migration guides live next to the deprecated component with a @deprecated JSDoc tag linking to them — that puts the guide in the editor tooltip at every one of the 60 call sites.

  6. Regenerate on API change, not on a schedule. Add a CI reminder (or a PR-template checkbox) that fires when Button.tsx's props change: "props changed — regenerate or amend Button.mdx." Generated docs are cheap to refresh; stale docs are expensive to trust.

Note

Generation order matters — source and stories first, call sites second, old docs last if at all. A model given the stale docs first will faithfully reproduce their errors with new formatting.

Tool variations

  • Claude with files attached: best prose quality for the guideline sections; paste the four evidence files per component.
  • Copilot Chat in VS Code: convenient for the per-component loop — @workspace finds call sites for you; verify it actually pulled them rather than summarizing from the source alone.
  • Storybook autodocs: keep it as the rendered home; your generated MDX complements the automatic props table — never hand-generate what autodocs derives.
  • Compose / SwiftUI systems: same recipe; evidence is the @Composable source plus @Preview functions, or the SwiftUI view plus #Preview blocks, and output lands in KDoc/DocC instead of MDX.

Quality check

  • Zero invented APIevery prop, value, and behavior in the docs exists in the source at the stated name; you checked each one.
  • Examples typecheckat least one generated example per doc was pasted into the repo and compiled.
  • Don'ts are realeach Don't reflects a pattern found in actual call sites or reviews, not a strawman.
  • Migration table is exhaustiveevery prop of the old component appears in the mapping table, including the removed ones.
  • Docs live in the workflowrendered in Storybook and linked from the @deprecated tag, not in a wiki nobody opens.
Pro Tip

Run the migration guide against one real call site yourself before publishing — convert it using only the guide, no source-diving. Every place you got stuck is a missing row or example; fix the guide, not the reader.

This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in