Repository navigation
fix(mcp): surface component @deprecated JSDoc tags in get-documentation - #368
rachelslurs wants to merge 4 commits into
Conversation
✅ Deploy Preview for storybook-mcp-self-host-example canceled.
|
🦋 Changeset detectedLatest commit: a7841ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughComponent docgen parsing now preserves normalized JSDoc tags. Documentation formatting resolves component and subcomponent ChangesComponent deprecation notices
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ReactDocgenTypescript
participant parseComponentDocLike
participant formatComponentManifest
participant MarkdownOutput
ReactDocgenTypescript->>parseComponentDocLike: Component metadata and JSDoc tags
parseComponentDocLike->>formatComponentManifest: Normalized tags
formatComponentManifest->>MarkdownOutput: Deprecated callout before description
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
get-documentation drops component-level @deprecated JSDoc tags: the tag is extracted into the manifest but never rendered by formatComponentManifest. These tests assert the tag is surfaced as a callout for components and subcomponents (from both the docgen-server jsDocTags and the legacy react-docgen-typescript tags), and fail against current code (5 failing: 4 formatter, 1 parser). Ref: storybookjs#367
Render component @deprecated as a "> **Deprecated:** <reason>" callout under the component and subcomponent headings. The tag is resolved from the docgen-server manifest (top-level jsDocTags.deprecated) and recovered from react-docgen-typescript / reactComponentMeta output (the engine's tags.deprecated). An absent tag or an empty deprecated array renders nothing. Fixes storybookjs#367
75b6322 to
107ca87
Compare
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #368 +/- ##
==========================================
+ Coverage 79.66% 79.74% +0.07%
==========================================
Files 50 50
Lines 2095 2113 +18
Branches 624 631 +7
==========================================
+ Hits 1669 1685 +16
Misses 220 220
- Partials 206 208 +2 ☔ View full report in Codecov by Harness. |
Codecov flagged two partial branches in normalizeTags: the empty-`out` path (a tags object with no string values) and the branch that skips a non-string tag value. Both are documented defensive guards that no test exercised. Add cases for a present-but-empty tags bag and a bag mixing a string and a non-string value. Claude-Session: https://claude.ai/code/session_01LRFizy8RJNrVzYDfkxWGmV
|
Superseded by storybookjs/storybook#35963 |
Fixes #367. Reproduction: https://github.com/rachelslurs/storybook-mcp-jsdoctags-repro
Summary
get-documentationnow renders a component's@deprecatedJSDoc tag. The tag was extracted into the manifest but never printed, so an agent callingget-documentationcould not see that a component was deprecated unless the deprecation was also written into the prose description by hand.Problem
formatComponentManifestprints the component name, id, description, subcomponents, stories, props, and attached docs. It never readsjsDocTags. The tag reaches the formatter by two paths, and both drop it:experimentalDocgenServer, the deprecation sits on the manifest's top-leveljsDocTags.deprecated(astring[]).adaptCoreComponentpasses it through, and the formatter ignores it.reactDocgenTypescript.tags.deprecated(a string), andparseComponentDocLikereads onlyprops, so it is gone before the formatter runs.I reproduced both on a react-vite project with Storybook 10.5.3 and addon-mcp 0.7.0. The
get-documentationoutput carried the description and no deprecation, flag on and flag off.Changes
packages/mcp/src/utils/parse-react-docgen.tstags: Record<string, string[]>toParsedDocgen, populated only when the engine reports tags, so parser output is unchanged for components without tags.parseComponentDocLike(react-docgen-typescript andreactComponentMeta) normalizes the engine'stagsinto that field.packages/mcp/src/utils/manifest-formatter/markdown.tsformatDeprecationNotice, which readsjsDocTags.deprecatedfirst and falls back toparsedDocgen.tags.deprecated.formatComponentManifestandformatSubcomponentsSectionprint a> **Deprecated:** <reason>line under the component or subcomponent heading, above the description. A tag with no message prints a bare> **Deprecated**. A component with no tag, or an emptydeprecatedarray, prints nothing. Non-deprecated components render byte for byte as before.Output for a deprecated
Button:Scope
jsDocTags) and react-docgen-typescript /reactComponentMeta(tags) paths, for components and subcomponents, verified end to end.Documentationtype carries no component-leveltags, and this code does not read tags if Storybook attaches them downstream.list-all-documentationstill shows only the component summary line. Deprecation appears once you fetch the component withget-documentation.Test plan
pnpm vitest --project=@storybook/mcp: 205 pass, including new tests for both resolution paths, the bare-notice case, the empty-array guard, subcomponent deprecation, and a guard that a non-deprecated component renders unchanged.pnpm --filter @storybook/mcp typecheckandoxlint --type-aware: clean.@storybook/mcp, loaded it into the reproduction project, and confirmed the callout appears on the flag-on and flag-off paths.Summary by CodeRabbit
@deprecatednotices as callouts beneath the relevant headings.