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

Web Components: methods not displayed #17147

Open
dmartinjs opened this issue Jan 6, 2022 · 6 comments
Open

Web Components: methods not displayed #17147

dmartinjs opened this issue Jan 6, 2022 · 6 comments

Comments

@dmartinjs
Copy link
Contributor

Describe the bug
I updated my custom-elements.json to follow the new format introduced in Storybook 6.4,
everything is displayed properly except methods who doesn't seems to be extracted from the file.
exemple of a method in the custom-elements.json.

To Reproduce

git clone https://gitlab.com/mobivia-design/roadtrip/components.git
git checkout develop
npm install
npm run build
npm run storybook

System

System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 16.13.1 - /usr/local/bin/node
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Edge: 96.0.1054.62
    Firefox: 94.0.2
    Safari: 15.0
  npmPackages:
    @storybook/addon-a11y: ^6.4.1 => 6.4.9 
    @storybook/addon-docs: ^6.4.1 => 6.4.9 
    @storybook/addon-essentials: ^6.4.1 => 6.4.9 
    @storybook/web-components: ^6.4.1 => 6.4.9 

Additional context
I don't know if its related but methods doesn't seems to be exported here.
https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/web-components/custom-elements.ts#L137

@mbulfair
Copy link

mbulfair commented Jan 7, 2022

This was working in a previous version of SB-WC, many of my components have public methods that need to be documented so +1 on this

@dmartinjs dmartinjs changed the title Web Component: methods not displayed Web Components docs: methods not displayed Jan 10, 2022
@dmartinjs dmartinjs changed the title Web Components docs: methods not displayed Web Components: methods not displayed Jan 10, 2022
@shilman
Copy link
Member

shilman commented Jan 10, 2022

@thepassle @gaetanmaisse perhaps a follow-up is needed for #15138 ?

@thepassle
Copy link
Contributor

I don't know if its related but methods doesn't seems to be exported here.

methods are listed under members along with fields, so I dont think thats the issue

@james-cavanagh
Copy link

Hello, is there an update on how to display methods please?

@jwloka
Copy link

jwloka commented Oct 25, 2022

We ran into a similar issue. A brief analysis seems to indicate that the problem is twofold:

  • (i) methods are ignored in the current implementation of custom-elements#mapData (and that might be for a reason?):

function mapData(data: TagItem[], category: string) {
return (
data &&
data
.filter((item) => item && item.name)
.reduce((acc, item) => {
if (item.kind === 'method') return acc;
switch (category) {
case 'events':

  • (ii) properties with clashing names are overridden, as their are used as key in the resulting object

We could live with the fact that properties with clashing names are overridden, but that might not be the case for everyone.

Would prefixing the property key with its kind in mapData be a valid solution, e.g. "method#close", "event#close"?

FYI @dreamora

jwloka added a commit to quatico-solutions/storybook that referenced this issue Oct 25, 2022
jwloka added a commit to quatico-solutions/storybook that referenced this issue Oct 25, 2022
@sebastian-kreft-simployer

Same thing for me. I need to manually add methods in ArgTypes and duplicate the description from JSDocs in order to have the methods displayed in the table

argTypes: {
    show: {
      control: false,
      table: { category: 'Methods' },
      description: 'Method that triggers the open dialog action',
    },
    hide: {
      control: false,
      table: { category: 'Methods' },
      description: 'Method that triggers the close dialog action',
    },
  }

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

7 participants