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

Rename docsOptions.enabled to docsOptions.disable #20363

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const storyIndexers = (indexers: StoryIndexer[] | null) => {
const docs = (docsOptions: DocsOptions) => {
return {
...docsOptions,
enabled: true,
disable: false,
defaultName: 'Docs',
docsPage: true,
};
Expand Down
6 changes: 3 additions & 3 deletions code/lib/core-server/src/utils/StoryIndexGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('StoryIndexGenerator', () => {

const generator = new StoryIndexGenerator([specifier], {
...options,
docs: { enabled: false },
docs: { disable: true },
});
await generator.initialize();

Expand Down Expand Up @@ -700,7 +700,7 @@ describe('StoryIndexGenerator', () => {
...options,
docs: {
...options.docs,
enabled: false,
disable: true,
},
});
await generator.initialize();
Expand Down
4 changes: 2 additions & 2 deletions code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/src/utils/stories-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class StoryStoreFacade<TRenderer extends Renderer> {
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);
Expand Down
10 changes: 5 additions & 5 deletions code/lib/preview-api/src/modules/core-client/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jest.mock('@storybook/global', () => ({
breakingChangesV7: true,
},
DOCS_OPTIONS: {
enabled: true,
disable: false,
},
},
}));
Expand Down Expand Up @@ -111,7 +111,7 @@ function makeRequireContext(importMap: Record<Path, ModuleExports>) {

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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions code/lib/types/src/modules/core-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/writing-docs/docs-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ By default, Storybook offers zero-config support for documentation and automatic

| Option | Description |
| ------------- | ------------------------------------------------------------------------------------------------------ |
| `enabled` | Toggles support for all documentation pages <br/> `docs: { enabled:false }` |
| `disable` | Toggles support for all documentation pages <br/> `docs: { disable:true }` |
| `docsPage` | Disables auto-generated documentation pages created via `tags` <br/> `docs: { docsPage: false }` |
| `automatic` | Enables auto-generated documentation pages for every component <br/> `docs: { docsPage: 'automatic' }` |
| `defaultName` | Renames the auto-generated documentation page<br/> `docs: { defaultName: 'Documentation' }` |
Expand Down