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

Addon-docs: Story source not shown when a variable named parameters is declared within CSF story #8055

Closed
enagy27 opened this issue Sep 12, 2019 · 9 comments

Comments

@enagy27
Copy link
Contributor

enagy27 commented Sep 12, 2019

Describe the bug
"No code available" is shown in docs preview when a variable, parameters, is declared at the top level in a CSF file.

To Reproduce
Uncomment the commented lines in this code snippet:

import React from 'react';
import { text } from '@storybook/addon-knobs';
import FormatSentence from '.';
// import { packageName } from '../../constants/stories';

// const componentSubtitle = `import FormatSentence from '${packageName}/lib/elements/format_sentence';`;

// const parameters = {
//   componentSubtitle,
// };

export const basic = () => {
  const sentence = text('sentence', 'This is a \uE000test\uE001 sentence.');
  return <FormatSentence sentence={sentence} />;
};

export default {
  title: 'Elements|FormatSentence',
  component: FormatSentence,
  // parameters,
};

Expected behavior
Both the commented and uncommented version of the snippet should behave the same.

System:
Environment Info:

System:
OS: macOS 10.14.5
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 10.16.0 - /usr/local/opt/node@10/bin/node
Yarn: 1.17.3 - ~/workspace/component-library/node_modules/.bin/yarn
npm: 6.5.0 - ~/workspace/component-library/node_modules/.bin/npm
Browsers:
Chrome: 76.0.3809.132
Safari: 12.1.1
npmPackages:
@storybook/addon-a11y: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addon-actions: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addon-docs: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addon-knobs: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addon-links: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addon-viewport: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/addons: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/preset-scss: 1.0.2 => 1.0.2
@storybook/preset-typescript: 1.1.0 => 1.1.0
@storybook/react: ^5.2.0-rc.11 => 5.2.0-rc.11
@storybook/source-loader: 5.2.0-rc.11 => 5.2.0-rc.11
@storybook/theming: ^5.2.0-rc.11 => 5.2.0-rc.11

@shilman
Copy link
Member

shilman commented Sep 12, 2019

@enagy27 Can repro. @enagy27 There's something about the source-loader generated code that doesn't like the parameters variable.

@shilman shilman changed the title [addon-docs] Story source not shown when a variable named parameters is declared within CSF story Addon-docs: Story source not shown when a variable named parameters is declared within CSF story Sep 12, 2019
@stale stale bot added the inactive label Oct 3, 2019
@stale stale bot closed this as completed Nov 2, 2019
@shilman shilman added the todo label Nov 2, 2019
@shilman shilman reopened this Nov 2, 2019
@stale stale bot removed the inactive label Nov 2, 2019
@storybookjs storybookjs deleted a comment from stale bot Nov 2, 2019
@storybookjs storybookjs deleted a comment from stale bot Nov 2, 2019
@patdryburgh
Copy link

@shilman Just wanted to let you know that I'm experiencing this as well, but I haven't added a parameters variable to any of my default exports.

@shilman
Copy link
Member

shilman commented Nov 14, 2019

@patdryburgh can you try the latest 5.3 prerelease on the next NPM tag and let me know more details if it still fails? we've made a handful of improvements to the source-loader during the alpha

@tolerance-go
Copy link

tolerance-go commented Jan 9, 2020

same problem, and I use storiesOf method, still is not ok
image

tried to upgrade "@ storybook / source-loader": "^ 5.3.0-rc.12", not solved

@shilman
Copy link
Member

shilman commented Jan 9, 2020

@tolerance-go do you have a repro?

@tolerance-go
Copy link

tolerance-go commented Jan 10, 2020

@shilman https://github.com/tolerance-go/markv/blob/d53c41486275730118731e932a456dad6abd73aa/src/components/MarkdownEditor/stories/index.stories.js#L15

i upgraded to CSF ​​story export,and all the packages have been upgraded to ^ 5.3.0-rc.12,still shown "No code available"

@shilman
Copy link
Member

shilman commented Jan 10, 2020

@tolerance-go Source-loader doesn't support fully dynamic titles. Please use a string constant or template literal.

export default {
  title: "components|MarkdownEditor",
  // title: route,
  component: MarkdownEditor
};

@whatwg6
Copy link

whatwg6 commented Apr 7, 2020

@tolerance-go Source-loader doesn't support fully dynamic titles. Please use a string constant or template literal.

export default {
  title: "components|MarkdownEditor",
  // title: route,
  component: MarkdownEditor
};

😔

@shilman
Copy link
Member

shilman commented Jun 7, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid.

Please open a new issue referencing this one if:

@shilman shilman closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants