Skip to content
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

UI: Add configurable tags-based exclusion from sidebar/autodocs #25328

Merged
merged 19 commits into from
Jan 12, 2024

Conversation

shilman
Copy link
Member

@shilman shilman commented Dec 27, 2023

Closes N/A

What I did

  • Added a new parameter, docs.stories.filter to control which stories show up in the stories block
  • Added a new main.ts field called tags to configure tag behavior
    • tags['tag-name'].excludeFromSidebar to hide stories from the sidebar
    • tags['tag-name'].excludeFromDocsStories to hide stories from the Stories block
  • Added several built-in tags:
    • 'dev-only': { excludeFromDocsStories: true }
    • 'docs-only': { excludeFromSidebar: true }
    • 'test-only': { excludeFromSidebar: true, excludeFromDocsStories: true }

The default docs.stories.filter is backwards compatible with the previous behavior which filters out stories with a truthy docs.disable parameter.

Checklist for Contributors

Testing

Added e2e tests in the telescoping PR #25537

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  1. Open a sandbox
  2. Add tags: ['dev-only'] to a story & observe it disappear from autodocs
  3. Add tags: ['docs-only'] to a story & observe it disappear from the sidebar
  4. Add tags: ['test-only'] to a story & observe it disappear from both the sidebar and autodocs
  5. Add a new tag foo to the main.ts configuration & restart storybook:
// .storybook/main.js
export default {
  // stories, etc.
  tags: {
    foo: {  excludeFromSidebar: true,  excludeFromDocsStories: true },
  },
};

Documentation

👉 Needs docs

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-25328-sha-5fe992e9. Install it by pinning all your Storybook dependencies to that version.

More information
Published version 0.0.0-pr-25328-sha-5fe992e9
Triggered by @shilman
Repository storybookjs/storybook
Branch shilman/autodocs-filter
Commit 5fe992e9
Datetime Tue Jan 2 10:32:24 UTC 2024 (1704191544)
Workflow run 7384765903

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=25328

@shilman shilman changed the title Docs: Add autodocs filter function parameter UI: Add configurable tags-based exclusion from sidebar/autodocs Jan 6, 2024
@shilman
Copy link
Member Author

shilman commented Jan 12, 2024

Self-merging @tmeasday @JReinhold

@shilman shilman merged commit ee06c80 into next Jan 12, 2024
60 of 68 checks passed
@shilman shilman deleted the shilman/autodocs-filter branch January 12, 2024 16:14
@github-actions github-actions bot mentioned this pull request Jan 12, 2024
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants