Skip to content

Commit

Permalink
Replace docs tag by autodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed May 6, 2024
1 parent d89ff2e commit 149dd06
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/addons/docs/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const parameters: any = {
filter: (story: PreparedStory) => {
const tags = story.tags || [];
return (
tags.includes('docs') &&
tags.includes('autodocs') &&
tags.filter((tag) => excludeTags[tag]).length === 0 &&
!story.parameters.docs?.disable
);
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ export class StoryIndexGenerator {

getProjectTags(previewCode: string) {
const projectAnnotations = loadConfig(previewCode).parse();
const defaultTags = ['dev', 'docs', 'test'];
const defaultTags = ['dev', 'test'];
const extraTags = this.options.docs.autodocs === true ? [AUTODOCS_TAG] : [];
const projectTags = projectAnnotations.getFieldValue(['tags']) ?? [];
return [...defaultTags, ...projectTags, ...extraTags];
Expand Down
14 changes: 3 additions & 11 deletions code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ describe('prepareStory', () => {
{ render }
);

expect(tags).toEqual([
'dev',
'docs',
'test',
'component-1',
'component-2',
'story-1',
'story-2',
]);
expect(tags).toEqual(['dev', 'test', 'component-1', 'component-2', 'story-1', 'story-2']);
});

it('component tags work if story are unset', () => {
Expand All @@ -66,13 +58,13 @@ describe('prepareStory', () => {
{ render }
);

expect(tags).toEqual(['dev', 'docs', 'test', 'component-1', 'component-2']);
expect(tags).toEqual(['dev', 'test', 'component-1', 'component-2']);
});

it('sets a value even if annotations do not have tags', () => {
const { tags } = prepareStory({ id, name, moduleExport }, { id, title }, { render });

expect(tags).toEqual(['dev', 'docs', 'test']);
expect(tags).toEqual(['dev', 'test']);
});
});

Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/csf/prepareStory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function preparePartialAnnotations<TRenderer extends Renderer>(
// anything at render time. The assumption is that as we don't load all the stories at once, this
// will have a limited cost. If this proves misguided, we can refactor it.

const defaultTags = ['dev', 'docs', 'test'];
const defaultTags = ['dev', 'test'];
if (typeof globalThis.DOCS_OPTIONS?.autodocs !== 'undefined') {
once.warn(dedent`
The \`docs.autodocs\` setting in '.storybook/main.js' is deprecated. Use \`tags: ['autodocs']\` in \`.storybook/preview.js\` instead.
Expand Down

0 comments on commit 149dd06

Please sign in to comment.