Skip to content

feat: add readme generator preset#397

Closed
ALagoni97 wants to merge 2 commits into
mainfrom
feat/readme-generator-preset
Closed

feat: add readme generator preset#397
ALagoni97 wants to merge 2 commits into
mainfrom
feat/readme-generator-preset

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

What

Adds a native readme generator preset that produces a README.md documenting how to install and use the generated code. Usage sections are derived from the other configured generators, so the README always matches what was actually generated.

Why

A README is standard for any generated SDK/package, but the CLI had no way to emit one — consumers had to hand-write install/usage docs, or (as in the platform that embeds this CLI) reverse-engineer the CLI's internal render output to build the README externally, which drifts whenever the CLI changes. This makes the CLI the owner of "document what I generated," with injectable slots for packaging voice.

How it works

  • Reads sibling generators' render output via typed generator-id references (channelsGeneratorId, payloadsGeneratorId, typesGeneratorId, clientGeneratorId) — the same mechanism client uses for channels.
  • Renders a section per referenced generator whose output is present: HTTP operations, per-protocol messaging (NATS/Kafka/…), client, message payloads, types.
  • Content options: packageName/packageVersion (title + npm/yarn/pnpm install), introduction (custom Markdown prepended above the generated content), suffix (final section; defaults to a CLI attribution line).
  • No auto-injection of other generators — list referenced generator ids in dependencies so their output renders first. This keeps the preset usable standalone and avoids pulling generation into configs that didn't ask for it.

Notes for reviewers

  • Registered for asyncapi and openapi inputs. Placed before custom in the discriminated unions because the public-schema builder strips the disabled custom preset by anyOf index and relies on it staying last.
  • getDefaultConfiguration refactored from a nested switch to a lookup map (readme pushed cognitive complexity over the lint threshold otherwise).
  • Regenerated schemas/ from Zod; new docs page docs/generators/readme-generator.md (named to avoid colliding with the README.md index on case-insensitive filesystems); new example under examples/; MCP server metadata updated.
  • OpenAPI http_client path-parameter documentation lights up fully once the separate fix/openapi-http-client-readme-parameters change lands on main (this preset reads parameterType from channel functions, which that fix populates); the preset degrades gracefully without it.

Testing

  • 15 new unit tests in test/codegen/generators/typescript/readme.spec.ts (install, per-preset sections, introduction/suffix, primary-op selection, relative vs package imports).
  • Full suite green: 650 passed, 76 snapshots, lint + typecheck clean.

🤖 Generated with Claude Code

Add a native `readme` preset that generates a README.md documenting how to
install and use the generated code. Usage sections are derived from the other
configured generators via typed generator-id references (channels, payloads,
types, client), so the README always matches what was actually generated:
HTTP operations, per-protocol messaging, client, payloads and types each get
their own section when the referenced generator's output is present.

Options: packageName/packageVersion (title + install section), introduction
(prepended custom Markdown), suffix (final section; defaults to a CLI
attribution line), and channels/payloads/types/client generator-id references.
The preset does not auto-inject dependencies — list referenced generator ids
in `dependencies` so their output renders first.

Registered for asyncapi and openapi inputs (placed before `custom` in the
discriminated unions so the disabled-preset schema filter stays correct).
Includes docs, an example, MCP server metadata, regenerated schemas, and unit
tests covering install, per-preset usage sections, introduction/suffix, and
relative vs package-based import paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Jul 9, 2026 1:26pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 9, 2026 1:26pm

@ALagoni97

Copy link
Copy Markdown
Contributor Author

Based on the fact that a README file like this one in the CLI project isn't very usuable for most consumers, we will opt to not support this feature for now.

@ALagoni97 ALagoni97 closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants