storybook: Addon-docs: Bad source for CSF with MDX Docs

Is your feature request related to a problem? Please describe. When using MDX with stories defined in CSF, the Show Code button does not display the actual code, but only the imported method name.

Describe the solution you’d like As with CSF or full MDX, I would expect the Show Code button to display the actual story reference code.

Describe alternatives you’ve considered From the recipe pages there’s two other options I’ve considered:

Pure MDX. This works, however it seems like you give up a lot of the benefits of the CSF: its portability and ability to be written in plain JS/JSX, with all its benefits.

CSF only. This also works, but you obviously don’t get the benefit of being able to define longer documentation. Especially interspersed within specific stories.

Are you able to assist bring the feature to reality? Potentially.

Additional context Reference to the Issue discussion here: https://github.com/storybookjs/storybook/issues/8377#issuecomment-540839675

MDX with story defined in CSF Screen Shot 2019-10-15 at 3 18 38 PM

<Preview>
  <Story name="Secondary">{stories.secondary()}</Story>
</Preview>

Just CSF Screen Shot 2019-10-15 at 3 18 22 PM

export const secondary = () => (
  <Button variant="secondary">Click me</Button>
);

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Yes! You can get the dynamically rendered source in two different ways:

  1. Convert it to an args story
  2. Set the docs.source.type parameter to ‘dynamic’ (default is ‘auto’)

Huzzah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.38 containing PR #11332 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there’s still more to do.

Hi everyone! Seems like there hasn’t been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don’t have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!