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

[Bug] JSDoc description disappears with lang="ts" #175

Open
rChaoz opened this issue Apr 15, 2024 · 6 comments
Open

[Bug] JSDoc description disappears with lang="ts" #175

rChaoz opened this issue Apr 15, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@rChaoz
Copy link

rChaoz commented Apr 15, 2024

According to the documentation, to set the description of a component you should use a JSDoc comment above the meta variable or above the component. The first variant does not work and the second one doesn't make sense (what is "above" a Svelte component)?

The only variant remaining is to set the string manually in meta like so:

export const meta = {
    ...other,
    parameters: {
        docs: {
            description: {
                component: "Description here"
            }
        }
    }
}
@rChaoz rChaoz added the bug Something isn't working label Apr 15, 2024
@JReinhold
Copy link
Collaborator

Storybook has a Vite plugin that extracts the JSDoc comments and puts them on parameters.docs.description.component:

https://github.com/storybookjs/storybook/blob/next/code/lib/csf-tools/src/enrichCsf.ts/#L135-L140
https://github.com/storybookjs/storybook/blob/next/code/builders/builder-vite/src/vite-config.ts/#L99

I suspect what's happening here is that the Svelte CSF Vite plugin is added after the CSF plugin, meaning that it will first extract comments from all stories.js files, and then convert stories.svelte files to stories.js, thus never extract comments from those.

@JReinhold
Copy link
Collaborator

I think I'm wrong here, there's plenty of code in this addon to handle this specifically, so this should work actually.

@JReinhold
Copy link
Collaborator

I actually have this working fine with the example from https://github.com/storybookjs/addon-svelte-csf/blob/main/stories/metaexport.stories.svelte

See https://stackblitz.com/~/edit/github-5qdaww

Can you provide a minimal reproduction?

It doesn't work with HMR, maybe that threw you off?

@rChaoz
Copy link
Author

rChaoz commented May 4, 2024

It seems like adding lang="ts" to the style tag causes the issue, I cloned your stackblitz, added that and it stops working (see here).

I'm not even using any types in the code, just the lang tag. But I think that should narrow it down a lot.

@JReinhold JReinhold changed the title [Bug] Can't set component description [Bug] JSDoc description disappears with lang="ts" May 4, 2024
xeho91 added a commit that referenced this issue May 14, 2024
@xeho91
Copy link
Collaborator

xeho91 commented May 14, 2024

I am not sure what the heck happened. Upgrading pnpm and adding svelte-package to the CI step possibly fixed the issue (at least when I tried to reproduce locally), the demonstration can be seen at #180

Or in the Chromatic preview - the story uses lang="ts" now:
https://6042cb92fd1bb200234586ee-mpuazznpwt.chromatic.com/?path=%2Fdocs%2Fdemo-metaexport-metaexport--docs

@JReinhold
Copy link
Collaborator

I'm not sure either, but I don't think the "fix" is propagated to user projects. I tried upgrading my reproduction to the canary from that branch, and it still doesn't show JSDocs when lang="ts".

https://stackblitz.com/~/edit/github-5qdaww?file=src/stories/Batton.stories.svelte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants