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

Is there any official parser of CSF JS/TS modules? #63

Closed
krutoo opened this issue Feb 4, 2023 · 4 comments
Closed

Is there any official parser of CSF JS/TS modules? #63

krutoo opened this issue Feb 4, 2023 · 4 comments

Comments

@krutoo
Copy link

krutoo commented Feb 4, 2023

Hi, in my app i want to write stories modules according to CSF but without Storybook.

I want to parse my stories files and get some info:

  • title
  • parameters
  • story names
  • story source code
  • story parameters
  • ...

Currently i use babel parser and just search some basic data.

Is there any official parser for it?

@kasperpeulen
Copy link
Contributor

@shilman I think it is this package right?
https://www.npmjs.com/package/@storybook/csf-tools

@shilman
Copy link
Contributor

shilman commented Feb 4, 2023

That's the one. Use loadCsf, which will give you a CsfFile object back. It's pretty hacked together, so the interface might change in the future. But it's fairly well tested and used thoughout the storybook codebase

@krutoo
Copy link
Author

krutoo commented Feb 9, 2023

@shilman I try to read tsx file in utf8 and pass it code as first argument to loadCsf but result has empty array in stories property and undefined in meta property

Is there an examples of using?

UPD

turns out I had to call parse before reading properties

@krutoo
Copy link
Author

krutoo commented Feb 18, 2023

Thank you all for answers

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

No branches or pull requests

3 participants