Skip to content

feat(docs): generate llms.txt and a Markdown reference per component (#20) - #52

Merged
YaelAnaya merged 1 commit into
mainfrom
feat/20-llms-docs
Dec 5, 2026
Merged

YaelAnaya merged 1 commit into
mainfrom
feat/20-llms-docs

Conversation

@YaelAnaya

Copy link
Copy Markdown
Contributor

Summary

Generates agent-readable docs from sources the repo already has. Nothing is written by hand a second time.

  • docs/generated/llms.txt: an index in the llmstxt.org format.
  • docs/generated/components/<slug>.md: one reference per component, 54 in total.

Closes #20.

What a reference contains

From the manifest (#19):

  • summary, import line (plus import type when the file exports types), category, built-on, source and package version;
  • When to use / When not to use. These print "Not documented yet." until [07b] DOC-05 · Write when-to-use guidance for every component #51 writes them;
  • anatomy table (part → data-slot → JSDoc), props per part (extends + a props table), variants with their default, controlled/uncontrolled props, and composition (foundation, composed components, parts taking asChild);
  • related components, linked to their references.

Then the page's prose, under Guide, converted from MDX to plain Markdown:

  • Frontmatter and imports are dropped, and headings move one level down.
  • <Preview demo="…"> becomes that demo file's source, verbatim, in a fence longer than any backtick run in the code.
  • <Callout> becomes > **Note/Warning: title**, <Guidelines> a Do/Don't list, and <Keyboard> a Key/Action table. Their props are read with the TypeScript parser, never evaluated.
  • Any other JSX outside a code fence fails the build, so a new docs component can't leak into agent docs as noise. Inline code like `<ScrollBar />` is prose and passes.

You can see the result in docs/generated/components/tabs.md.

llms.txt

Package summary, install/usage, the colour-role rule, then every reference grouped by sidebar category. Next come links to DESIGN.md, AGENTS.md, ADR 0001 and CONTRIBUTING, pinned to the v<version> tag so they match the version described. Under Optional it links the manifest.

Served by the docs site

Three Astro endpoints import the committed files with ?raw:

  • /llms.txt
  • /components/<slug>.md, beside each HTML page
  • /components.manifest.json

I checked the built dist/: all three are byte-identical to docs/generated/.

Commands

  • pnpm docs:agents regenerates the manifest and the agent docs in one go.
  • docs:check now also runs agents:check, which fails when anything is stale or orphaned.

Tests

tests/docs/agent-docs.test.ts, 11 tests:

  • one reference per component, and every component listed in llms.txt;
  • all local links resolve, including related links;
  • no JSX outside code fences in any reference;
  • every demo of Tabs, CodeBlock and FilterParamsBar is included verbatim;
  • the import/anatomy/variants/state lines are present, and Callout/Guidelines/Keyboard are converted;
  • unwritten guidance says "Not documented yet.";
  • unknown JSX throws, while inline and fenced JSX passes;
  • output is deterministic, and the committed copies are current.

Testing evidence

  • pnpm format:check ✓
  • pnpm lint ✓
  • pnpm test: 228 passed
  • pnpm docs:check: manifest current, agent docs current (55 files), 0 errors / 0 warnings, 62 pages.

Notes

  • The references total about 1.1 MB, mostly demo sources. Whether and how they ship in the npm package is [08] DOC-04 · Ship version-matched agent docs inside the npm package #21's decision.
  • AGENTS.md now lists llms.txt among the sources of truth, adds pnpm docs:agents to the commands, and tells agents to read a component's reference before choosing it. CONTRIBUTING documents the generator and adds a Scripts row. Releasing now says to run pnpm docs:agents after the version bump.

Public API / dependency changes

None.

scripts/build-agent-docs.ts writes docs/generated/llms.txt and
docs/generated/components/<slug>.md from the component manifest and the docs
pages, so there is no second documentation system to maintain.

Each reference carries the summary, import line, category, anatomy with
data-slots, props, variants, controlled/uncontrolled props and composition
from the manifest, the when-to-use guidance ("Not documented yet." until
#51 writes it), then the page's prose as plain Markdown: live demos become
their files' source verbatim, Callout a quote, Guidelines a do/don't list,
Keyboard a table. Unknown JSX outside a code fence fails the build.

llms.txt indexes every reference by sidebar category, plus the design
rules, AGENTS.md, ADR 0001 and the manifest (pinned to the version's tag).
The site serves all three at /llms.txt, /components/<slug>.md and
/components.manifest.json, from the committed files.

pnpm docs:agents regenerates docs/generated/; docs:check fails when it is
stale. AGENTS.md and CONTRIBUTING document both.

Closes #20
@YaelAnaya YaelAnaya added area: agent-tooling Agent instructions, skills, and workflows area: documentation Documentation and component catalog type: feature New functionality labels Dec 5, 2026
@YaelAnaya YaelAnaya self-assigned this Dec 5, 2026
@YaelAnaya
YaelAnaya merged commit a3cbb2e into main Dec 5, 2026
1 check passed
@YaelAnaya
YaelAnaya deleted the feat/20-llms-docs branch December 5, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: agent-tooling Agent instructions, skills, and workflows area: documentation Documentation and component catalog type: feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[07] DOC-03 · Generate llms.txt and per-component Markdown references

1 participant