diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 5e1ce6146199..ffdfa1007975 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -150,7 +150,7 @@ const storyIndexers = (indexers: StoryIndexer[] | null) => { const docs = (docsOptions: DocsOptions) => { return { ...docsOptions, - enabled: true, + disable: false, defaultName: 'Docs', docsPage: true, }; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index cb89b28b6094..924a897dd3c5 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -53,7 +53,7 @@ const options = { ] as StoryIndexer[], storiesV2Compatibility: false, storyStoreV7: true, - docs: { enabled: true, defaultName: 'docs', docsPage: false }, + docs: { disable: false, defaultName: 'docs', docsPage: false }, }; describe('StoryIndexGenerator', () => { @@ -279,7 +279,7 @@ describe('StoryIndexGenerator', () => { const generator = new StoryIndexGenerator([specifier], { ...options, - docs: { enabled: false }, + docs: { disable: true }, }); await generator.initialize(); @@ -700,7 +700,7 @@ describe('StoryIndexGenerator', () => { ...options, docs: { ...options.docs, - enabled: false, + disable: true, }, }); await generator.initialize(); diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index e070440166c6..496db833959b 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -165,7 +165,7 @@ export class StoryIndexGenerator { this.isDocsMdx(absolutePath) ? false : this.extractStories(specifier, absolutePath) ); - if (this.options.docs.enabled) { + if (!this.options.docs.disable) { await this.updateExtracted(async (specifier, absolutePath) => this.extractDocs(specifier, absolutePath) ); @@ -234,7 +234,7 @@ export class StoryIndexGenerator { } }); - if (this.options.docs.enabled && csf.stories.length) { + if (!this.options.docs.disable && csf.stories.length) { const { docsPage } = this.options.docs; const docsPageOptedIn = docsPage === 'automatic' || (docsPage && componentTags.includes('docsPage')); diff --git a/code/lib/core-server/src/utils/stories-json.test.ts b/code/lib/core-server/src/utils/stories-json.test.ts index 528d270936b6..e6499d77ad42 100644 --- a/code/lib/core-server/src/utils/stories-json.test.ts +++ b/code/lib/core-server/src/utils/stories-json.test.ts @@ -62,7 +62,7 @@ const getInitializedStoryIndexGenerator = async ( workingDir, storiesV2Compatibility: false, storyStoreV7: true, - docs: { enabled: true, defaultName: 'docs', docsPage: false }, + docs: { disable: false, defaultName: 'docs', docsPage: false }, ...overrides, }); await generator.initialize(); diff --git a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts index 3dcdb605f707..1a9b6a88675d 100644 --- a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts +++ b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts @@ -198,7 +198,7 @@ export class StoryStoreFacade { const docsPageOptedIn = docsOptions.docsPage === 'automatic' || (docsOptions.docsPage && componentTags.includes('docsPage')); - if (docsOptions.enabled && storyExports.length) { + if (!docsOptions.disable && storyExports.length) { if (componentTags.includes('mdx') || docsPageOptedIn) { const name = docsOptions.defaultName; const docsId = toId(componentId || title, name); diff --git a/code/lib/preview-api/src/modules/core-client/start.test.ts b/code/lib/preview-api/src/modules/core-client/start.test.ts index 5183f13c0775..e1ff3478fc32 100644 --- a/code/lib/preview-api/src/modules/core-client/start.test.ts +++ b/code/lib/preview-api/src/modules/core-client/start.test.ts @@ -35,7 +35,7 @@ jest.mock('@storybook/global', () => ({ breakingChangesV7: true, }, DOCS_OPTIONS: { - enabled: true, + disable: false, }, }, })); @@ -111,7 +111,7 @@ function makeRequireContext(importMap: Record) { describe('start', () => { beforeEach(() => { - global.DOCS_OPTIONS = { enabled: false }; + global.DOCS_OPTIONS = { disable: true }; // @ts-expect-error (setting this to undefined is indeed what we want to do) global.__STORYBOOK_CLIENT_API__ = undefined; // @ts-expect-error (setting this to undefined is indeed what we want to do) @@ -962,7 +962,7 @@ describe('start', () => { describe('docs', () => { beforeEach(() => { - global.DOCS_OPTIONS = { enabled: true }; + global.DOCS_OPTIONS = { disable: false }; }); // NOTE: MDX files are only ever passed as CSF @@ -1150,7 +1150,7 @@ describe('start', () => { describe('docsPage', () => { beforeEach(() => { - global.DOCS_OPTIONS = { enabled: true, docsPage: true, defaultName: 'Docs' }; + global.DOCS_OPTIONS = { disable: false, docsPage: true, defaultName: 'Docs' }; }); it('adds stories for each component with docsPage tag', async () => { @@ -1312,7 +1312,7 @@ describe('start', () => { }); describe('when docsOptions.docsPage = automatic', () => { beforeEach(() => { - global.DOCS_OPTIONS = { enabled: true, docsPage: 'automatic', defaultName: 'Docs' }; + global.DOCS_OPTIONS = { disable: false, docsPage: 'automatic', defaultName: 'Docs' }; }); it('adds stories for each component with docsPage tag', async () => { diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 61dc1826649e..cde04dbffd1b 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -245,9 +245,9 @@ type CoreCommon_StorybookRefs = Record< export type DocsOptions = { /** - * Should we generate docs entries at all under any circumstances? (i.e. can they be rendered) + * Should we disable generate docs entries at all under any circumstances? (i.e. can they be rendered) */ - enabled?: boolean; + disable?: boolean; /** * What should we call the generated docs entries? */ diff --git a/docs/writing-docs/docs-page.md b/docs/writing-docs/docs-page.md index 5567d290c985..23514474557c 100644 --- a/docs/writing-docs/docs-page.md +++ b/docs/writing-docs/docs-page.md @@ -55,7 +55,7 @@ By default, Storybook offers zero-config support for documentation and automatic | Option | Description | | ------------- | ------------------------------------------------------------------------------------------------------ | -| `enabled` | Toggles support for all documentation pages
`docs: { enabled:false }` | +| `disable` | Toggles support for all documentation pages
`docs: { disable:true }` | | `docsPage` | Disables auto-generated documentation pages created via `tags`
`docs: { docsPage: false }` | | `automatic` | Enables auto-generated documentation pages for every component
`docs: { docsPage: 'automatic' }` | | `defaultName` | Renames the auto-generated documentation page
`docs: { defaultName: 'Documentation' }` |