-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index: Fix MDX to override project-level autodocs #28461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Updated
chooseDuplicate
method in/code/core/src/core-server/utils/StoryIndexGenerator.ts
to handle project-level autodocs tags. - Enhanced
getProjectTags
method in/code/core/src/core-server/utils/StoryIndexGenerator.ts
to correctly parse and include autodocs tags. - Added test cases in
/code/core/src/core-server/utils/StoryIndexGenerator.test.ts
for scenarios with 'autodocs' tags at project and component levels. - Verified that MDX files can override project-level autodocs settings in new tests.
- Ensured autogenerated docs entries correctly include 'autodocs' tags.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
@@ -709,7 +712,7 @@ export class StoryIndexGenerator { | |||
} | |||
|
|||
getProjectTags(previewCode?: string) { | |||
let projectTags = []; | |||
let projectTags = [] as Tag[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪶 style: Explicitly typed projectTags as Tag[].
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 14ef5cc. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
@@ -506,7 +506,7 @@ export class StoryIndexGenerator { | |||
} | |||
} | |||
|
|||
chooseDuplicate(firstEntry: IndexEntry, secondEntry: IndexEntry): IndexEntry { | |||
chooseDuplicate(firstEntry: IndexEntry, secondEntry: IndexEntry, projectTags: Tag[]): IndexEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjustment in src/core-server/utils/StoryIndexGenerator.test.ts:1530:21
also necessary
Closes N/A
What I did
Fixed a regression introduced by the 8.1 tags work. Previously, you could set
docsOptions.autodocs = true
in main.js and then override the autodocs at a component level by adding MDX.Starting in 8.1, we deprecated
docsOptions.autodocs
and converted to tags. We automigrateddocsOptions.autodocs = true
totags: ['autodocs']
in.storybook/preview.js
, which is the new equivalent. However, the code to allow overriding project-level autodocs with MDX was not updated.I also updated all the
docsOptions.autodocs = true
tests to havetags = ['autodocs']
equivalents. We can delete the old ones in 9.0.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
In a sandbox, write MDX for the button component:
You created a component docs page for '${worseEntry.title}', but also tagged the CSF file with '${AUTODOCS_TAG}'. This is probably a mistake.
,autodocs
.Now set
tags: ['autodocs']
in.storybook/preview.ts
🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>