Skip to content

docs: consumer README for every block and sub-block#1484

Open
dgaponov wants to merge 4 commits into
mainfrom
docs/block-readme
Open

docs: consumer README for every block and sub-block#1484
dgaponov wants to merge 4 commits into
mainfrom
docs/block-readme

Conversation

@dgaponov

Copy link
Copy Markdown

Summary

Adds a consistent, consumer-facing README.md to every page block (23) and sub-block (12) — back-filling the per-block README that the root README's "How to add a new block" step mandates but was never applied to existing blocks.

Each README follows the same template:

  • what the block renders + when to reach for it
  • the type: string
  • a copy-pasteable JSON example
  • a properties table (Property | Type | Default | Description) sourced from each block's schema.ts + TS models
  • inherited common properties, themed-values notes, and a Storybook link

Verification

New harness test-utils/readme-examples.test.tsx checks every README's example:

  1. Schema — validates the JSON against the library's own generateDefaultSchema() (ajv).
  2. Render — renders it through <PageConstructor> in jsdom and asserts it doesn't throw.

Result: all 35 examples render without errors; every non-gap example passes schema validation (61 passed, 9 skipped, 0 failed). typecheck, eslint, and prettier are clean.

The 9 skipped cases are pre-existing gaps in the library's schema bundle (not doc bugs) — each documented in the harness:

  • hero-block, foldable-list-block — not registered in the schema bundle at all
  • form-block (formData), tabs-block (media) — ambiguous oneOf
  • info-block — over-strict required
  • basic-card (icon), image-card (image) — accept themed values at runtime but schema declares plain ImageProps
  • content, hubspot-form — nested structures, not standalone children

Note: src/blocks/Security/ is skipped intentionally — it's orphan i18n stubs, not a real block (no schema.ts/component, security-block is unused).

🤖 Generated with Claude Code

Add a consistent, consumer-facing README.md to each page block (23) and
sub-block (12), describing what it renders, its `type` string, when to use
it, a copy-pasteable JSON example, and a full properties table (type /
default / description) sourced from each block's schema.ts and TS models.

Each example is verified by a new harness (test-utils/readme-examples.test.tsx)
that, for every README, (1) validates the JSON example against the library's
own generateDefaultSchema() via ajv, and (2) renders it through
<PageConstructor> in jsdom to assert it does not throw. All 35 examples render
without errors; non-gap examples pass schema validation.

The harness also documents pre-existing gaps in the schema bundle that reject
otherwise-valid configs (hero-block/foldable-list-block not registered;
form-block/tabs-block ambiguous oneOf; info-block over-strict required;
basic-card/image-card themed values; content/hubspot-form are nested, not
standalone children) so they are skipped explicitly rather than silently.

Co-Authored-By: Claude <noreply@anthropic.com>
@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Playwright Test Component is ready.

dgaponov and others added 3 commits July 15, 2026 23:39
Make the per-block README.md the single source of truth and stop
duplicating its content in the Storybook .mdx docs pages.

- Each block/sub-block .mdx now imports its README.md and renders it via
  <Markdown> from @storybook/blocks (GFM tables included), keeping the
  <Meta> + <StoryTemplate> wrapper so live stories still render below.
- Add a webpack `asset/source` rule for .md in .storybook/main.ts so
  README.md can be imported as a raw string (.mdx files are unaffected).
- Add docs .mdx for Icons and PromoFeaturesBlock (they had stories but
  no docs page), so every block's storybook docs come from its README.
- Drop ~1.4k lines of hand-maintained parameter prose from the .mdx files.

Verified with `npm run storybook:build` (clean build).

Co-Authored-By: Claude <noreply@anthropic.com>
…d README

The README.md is now rendered verbatim in each docs page, which duplicated
the page title and added a self-referential Storybook link.

- Add a small <Readme> wrapper (.storybook/readme.tsx) that removes the
  leading `# Title` H1 (Storybook already renders its own <Title/>) and the
  trailing `## Storybook` section before passing the markdown to <Markdown>.
- Point every block/sub-block .mdx at <Readme> instead of <Markdown>.

The README files themselves are unchanged — GitHub still shows the full
document; only the Storybook render is trimmed.

Verified with `npm run storybook:build` and `npm run lint:js`.

Co-Authored-By: Claude <noreply@anthropic.com>
- Storybook links were generated from the block `type` string
  (e.g. `blocks-banner-block--docs`), but Storybook URLs are derived from
  the story `title` in each stories.tsx (`Blocks/Banner` → `blocks-banner--docs`).
  Recompute every link from the actual title, including the `Components/...`
  sub-block titles, and add a `## Storybook` section to the sub-block READMEs
  that lacked one.
- `\|` inside inline code in prose rendered as a literal backslash-pipe on
  GitHub; keep the escape only where it is required (inside table cells) and
  use a plain `|` everywhere else.

Co-Authored-By: Claude <noreply@anthropic.com>
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