Skip to content

Commit

Permalink
Merge pull request #30345 from storybookjs/yann/fix-syntax-issues-in-…
Browse files Browse the repository at this point in the history
…docs

Docs: Fix syntax issues in documentation snippets
  • Loading branch information
kylegach authored Jan 22, 2025
2 parents 4d2989d + d015b17 commit 0fd545b
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 131 deletions.
8 changes: 4 additions & 4 deletions docs/_snippets/addon-actions-action-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { action } from '@storybook/addon-actions';

import Button from './button.component';

const meta: Meta<Button> {
const meta: Meta<Button> = {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
Expand Down Expand Up @@ -36,7 +36,7 @@ import { action } from '@storybook/addon-actions';

import Button from './Button';

const meta {
const meta = {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
Expand All @@ -54,7 +54,7 @@ import { action } from '@storybook/addon-actions';

import Button from './Button';

const meta: Meta<typeof Button> {
const meta: Meta<typeof Button> = {
component: Button,
args: {
// 👇 Create an action that appears when the onClick event is fired
Expand All @@ -81,7 +81,7 @@ export default {
import type { Meta } from '@storybook/angular';
import { action } from '@storybook/addon-actions';

const meta: Meta {
const meta: Meta = {
component: 'demo-button',
args: {
// 👇 Create an action that appears when the onClick event is fired
Expand Down
2 changes: 1 addition & 1 deletion docs/_snippets/api-doc-block-canvas-parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Basic: Story = {
```

```js filename="Button.stories.js|jsx" renderer="common" language="js"
export const Basic {
export const Basic = {
parameters: {
docs: {
canvas: { sourceState: 'shown' },
Expand Down
56 changes: 28 additions & 28 deletions docs/_snippets/api-doc-block-description-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Button } from './button.component';
* These stories showcase the button
*/
const meta: Meta<Button> = {
component: Button
component: Button,
parameters: {
docs: {
description: {
component: 'Another description, overriding the comments'
component: 'Another description, overriding the comments',
},
},
},
Expand All @@ -29,7 +29,7 @@ export const Primary: Story = {
parameters: {
docs: {
description: {
story: 'Another description on the story, overriding the comments'
story: 'Another description on the story, overriding the comments',
},
},
},
Expand All @@ -44,15 +44,15 @@ import { Button } from './Button';
* These stories showcase the button
*/
export default {
component: Button
component: Button,
parameters: {
docs: {
description: {
component: 'Another description, overriding the comments'
}
}
}
}
component: 'Another description, overriding the comments',
},
},
},
};

/**
* Primary Button
Expand All @@ -62,11 +62,11 @@ export const Primary = {
parameters: {
docs: {
description: {
story: 'Another description on the story, overriding the comments'
}
}
}
}
story: 'Another description on the story, overriding the comments',
},
},
},
};
```

```ts filename="Button.stories.ts|tsx" renderer="common" language="ts-4-9"
Expand All @@ -80,18 +80,18 @@ import { Button } from './Button';
* These stories showcase the button
*/
const meta = {
component: Button
component: Button,
parameters: {
docs: {
description: {
component: 'Another description, overriding the comments'
}
}
}
component: 'Another description, overriding the comments',
},
},
},
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>
type Story = StoryObj<typeof meta>;

/**
* Primary Button
Expand All @@ -101,11 +101,11 @@ export const Primary: Story = {
parameters: {
docs: {
description: {
story: 'Another description on the story, overriding the comments'
}
}
}
}
story: 'Another description on the story, overriding the comments',
},
},
},
};
```

```ts filename="Button.stories.ts|tsx" renderer="common" language="ts"
Expand All @@ -119,11 +119,11 @@ import { Button } from './Button';
* These stories showcase the button
*/
const meta: Meta<typeof Button> = {
component: Button
component: Button,
parameters: {
docs: {
description: {
component: 'Another description, overriding the comments'
component: 'Another description, overriding the comments',
},
},
},
Expand All @@ -140,7 +140,7 @@ export const Primary: Story = {
parameters: {
docs: {
description: {
story: 'Another description on the story, overriding the comments'
story: 'Another description on the story, overriding the comments',
},
},
},
Expand Down
8 changes: 7 additions & 1 deletion docs/_snippets/api-doc-block-source-parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export const Basic: Story = {
```

```js filename="Button.stories.js|jsx" renderer="common" language="js"
export const Basic {
const meta = {
component: Button,
};

export default meta;

export const Basic = {
parameters: {
docs: {
source: { language: 'jsx' },
Expand Down
7 changes: 6 additions & 1 deletion docs/_snippets/api-doc-block-story-parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export const Basic: Story = {
```

```js filename="Button.stories.js|jsx" renderer="common" language="js"
export const Basic {
const meta = {
component: Button,
};
export default meta;

export const Basic = {
parameters: {
docs: {
story: { autoplay: true },
Expand Down
16 changes: 8 additions & 8 deletions docs/_snippets/button-story-click-handler-simplificated.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import { Button } from './Button';

export default {
component: Button,
}
};

export const Text = {
args: {...},
args: {/* ... */},
};
```

Expand Down Expand Up @@ -66,10 +66,10 @@ import { Button } from './Button';

export default {
component: Button,
}
};

export const Text = {
args: {...},
args: {/* ... */},
};
```

Expand Down Expand Up @@ -115,7 +115,7 @@ export default {
};

export const Text = {
args: {...},
args: {/* ... */},
};
```

Expand All @@ -132,7 +132,7 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const Text: Story = {
args: {...},
args: {/* ... */},
};
```

Expand All @@ -149,7 +149,7 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const Text: Story = {
args: {...},
args: {/* ... */},
};
```

Expand Down Expand Up @@ -219,7 +219,7 @@ export default {
};

export const Text = {
args: {...},
args: {/* ... */},
};
```

Expand Down
24 changes: 12 additions & 12 deletions docs/_snippets/main-config-indexers-jsonstories.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const jsonStoriesIndexer = {

const stories = generateStoryIndexesFromJson(content);

return stories.map((story) => {
return stories.map((story) => ({
type: 'story',
importPath: `virtual:jsonstories--${fileName}--${story.componentName}`,
exportName: story.name
});
exportName: story.name,
}));
},
};

Expand All @@ -24,7 +24,7 @@ const config = {
// 👇 Make sure files to index are included in `stories`
'../src/**/*.stories.json',
],
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer],
};

export default config;
Expand All @@ -44,11 +44,11 @@ const jsonStoriesIndexer: Indexer = {

const stories = generateStoryIndexesFromJson(content);

return stories.map((story) => {
return stories.map((story) => ({
type: 'story',
importPath: `virtual:jsonstories--${fileName}--${story.componentName}`,
exportName: story.name
});
exportName: story.name,
}));
},
};

Expand All @@ -60,7 +60,7 @@ const config: StorybookConfig = {
// 👇 Make sure files to index are included in `stories`
'../src/**/*.stories.json',
],
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer],
};

export default config;
Expand All @@ -80,11 +80,11 @@ const jsonStoriesIndexer: Indexer = {

const stories = generateStoryIndexesFromJson(content);

return stories.map((story) => {
return stories.map((story) => ({
type: 'story',
importPath: `virtual:jsonstories--${fileName}--${story.componentName}`,
exportName: story.name
});
exportName: story.name,
}));
},
};

Expand All @@ -96,7 +96,7 @@ const config: StorybookConfig = {
// 👇 Make sure files to index are included in `stories`
'../src/**/*.stories.json',
],
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer],
};

export default config;
Expand Down
10 changes: 7 additions & 3 deletions docs/_snippets/main-config-indexers-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const combosIndexer = {
const title = fileName.match(/\/(.*)\.stories/)[1];

// Read file and generate entries ...
let entries = [];
// Read file and generate entries...

return entries.map((entry) => ({
type: 'story',
Expand All @@ -20,7 +22,7 @@ const combosIndexer = {
const config = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer],
};

export default config;
Expand All @@ -38,6 +40,7 @@ const combosIndexer: Indexer = {
const title = fileName.match(/\/(.*)\.stories/)[1];

// Read file and generate entries ...
const entries = [];

return entries.map((entry) => ({
type: 'story',
Expand All @@ -52,7 +55,7 @@ const combosIndexer: Indexer = {
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer],
};

export default config;
Expand All @@ -70,6 +73,7 @@ const combosIndexer: Indexer = {
const title = fileName.match(/\/(.*)\.stories/)[1];

// Read file and generate entries ...
const entries = [];

return entries.map((entry) => ({
type: 'story',
Expand All @@ -84,7 +88,7 @@ const combosIndexer: Indexer = {
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer];
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer],
};

export default config;
Expand Down
Loading

0 comments on commit 0fd545b

Please sign in to comment.