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

style guide generation, react-styleguidist integration? #602

Closed
jurgob opened this issue Nov 3, 2016 · 32 comments
Closed

style guide generation, react-styleguidist integration? #602

jurgob opened this issue Nov 3, 2016 · 32 comments

Comments

@jurgob
Copy link
Contributor

jurgob commented Nov 3, 2016

Hi, is it possible to generate a style guide from the stories?
something like react-styleguidest (https://github.com/sapegin/react-styleguidist) do?
Does it make sense to write something from scratch? or maybe it make more sense to do some tools to "generate" the react-styleguidist files?

In my project I was using both react-styleguidest and react-storybook, so I wrote a storybook generator from the styleguidest examples. (here the code: https://gist.github.com/jurgob/58f6f46c34e991dc449effe5731dd693).

Maybe doing the opposite (from stories to markup files) it could be the fastest way?

Let me know what do you think

@jurgob
Copy link
Contributor Author

jurgob commented Nov 3, 2016

probably a static building could solve my problems, but as far as I can see, it miss 3 feat witch are present in react-styleguidist:

  1. on-the-fly code editor.
  2. markdown description for every story
  3. markdownd pages included in the generated styleguide (same format of github)

@cdaringe
Copy link

cdaringe commented Nov 4, 2016

can the addons not fill this role somehow already?

@jurgob
Copy link
Contributor Author

jurgob commented Nov 4, 2016

mmm, not sure. Btw have a longer description for the story could be a good idea?

@arunoda
Copy link
Member

arunoda commented Nov 5, 2016

Hey, we have some solutions in Storybook land for this. Let me show you them:

@sapegin
Copy link

sapegin commented Jan 13, 2017

Hey, React Styleguidist author is here ;-) Is anyone still interested in Storybooks and React Styleguidist integration?

@ghost
Copy link

ghost commented Jan 13, 2017

I might be yes :)

@jbovenschen
Copy link
Member

@sapegin I'm interested in the integration with styleguidist, also I'm happy to help or make the integration, happy to hear of your still interested.

@sapegin
Copy link

sapegin commented Feb 21, 2017

@jbovenschen Hi Jaco! I’m not very familiar how Storybook works but probably we could somehow convert stories to Styleguidist Markdown format. Probably it will require some changes in Styleguidist itself. I’m happy to discuss it ;-)

@logankoester
Copy link

I'm still interested in this as well, definitely!

@cdaringe
Copy link

I will definitely follow commits on such a thing. very interested!

@cdaringe
Copy link

cdaringe commented Feb 24, 2017

one idea is a styleguidist loader.

in that regard, storybook doesn't even need awareness of styleguidist. you just:

.add('widget', require('styleguidist!./my-widget.md'))

the loader would return the root react Component for the styleguide and blamo, we're on our way!

@sapegin, thoughts?

@jbovenschen
Copy link
Member

Currently I try to work out something where you get a link, like "Open isolated ->" in the examples generated by styleguidist.

@cdaringe Will the webpack example return the complete set of styleguidist stories? Or create new ones based on it's content, if so is it not better to create some kind of addon?

@cdaringe
Copy link

@jbovenschen, it would load only the content as defined by ./my-widget.md, so just the one styleguidist story, or set of stories defined therein. loading a full build probably wouldnt provide much value, IMHO

@sapegin
Copy link

sapegin commented Feb 28, 2017

Then what’s the difference with running Styleguidist separately if you still have to write docs in Styleguidist format?

@cdaringe
Copy link

Then what’s the difference with running Styleguidist separately if you still have to write docs in Styleguidist format?

great point, i dont know what i was thinking. my head's on straight now! perhaps a better approach would be an addon, providing a styleguidist wrapper thingy™:

import { styleguidist } from 'storybook-styleguidist'
import Button from './path/to/button'
.add('Button', styleguidist(
  Button,  // tells which props to inject into addon pane
  () => { /* story 1 */ }, // renders normal styleguidist experience
  () => { /* story 2 */ }
)

maybe not ideal, because in that approach, all stories share the same viewer. instead...

import { styleguidist } from 'storybook-styleguidist'
import Button from './path/to/button'
.add(styleguidist(
  Button,
  'story1', () => { /* story 1 */ },
  'story2', () => { /* story 2 */ }
)

^^ would load the props documentation into the story1 & story2 "styleguidist" addon panes, & the stories would be laid out per the below in the storybook:

├── Button
│   ├── story1
│   ├── story2

@usulpro
Copy link
Member

usulpro commented Mar 2, 2017

Hey! I like an idea to integrate them such a way that it could be possible to use Strorybook as a development tool and Styleguidist as a customizable static output.

I was looking for ways to seamlessly transfer stories data to styleguidist and now I can show the example how it's possible to create markdown from storybooks via addon.

storiesOf('Usual story', module)
    .addStyleGuide('Simple Example', () => (
      <div className="example-component">
        <Button title={text('Subtitle3', 'Knob1.SubTitle')} />
      </div>
    ), { getCode: storeCode })

It's possible to pass additional description to each story like in react-storybook-addon-info (actually it's a fork). And markdown could be devided by stories or any other way.

The big pros is that it's possible to use with other addons like Knobs. e.g. set all knobs and then generate a markdown with stored prop values. (I hope it'll be possible to support decorators as well)

Here're demo and repo

In this demo you can see markdown in the addon panel after selecting single story or do it automatically to generate all of them.
it's just an outline for now. I think if it's usefull it's possible to reduce excessive code and have something realy simple for usage and avoid .addStyleGuide (keep it only if we want to add some additional docs to the description, in all other cases - just usual .add)

@sapegin @cdaringe @jbovenschen @jurgob do you have any ideas is it possible to continue and how to pass this markdown (and everything else) to Styleguidist?

One of the problems could be is that do it in browser not server (now the most simple way is just save a file manually) or could we generate styleguide on a client side?

So I'll be happy if it could help with this work :)

@sapegin
Copy link

sapegin commented Mar 2, 2017

@usulpro That’s amazing! Exactly what I was thinking (but had no idea how to implement it ;–)

how to pass this markdown (and everything else) to Styleguidist?

That’s a good question. Generating real files is not the best way. But I don’t really know how can we connect Storybook and Styleguidist. Does Storybook have some API? Is it possible to have all Markdown snippets in Node?

@usulpro
Copy link
Member

usulpro commented Mar 3, 2017

Storybook has API for addons developing.

But maybe we can use this #435 ?

Asking to have Markdown snippets in Node do you mean to use this API? I'm confused that it needs to require everything from this Markdown as well.

@sapegin
Copy link

sapegin commented Mar 9, 2017

I should study Storybook API, right now I don’t understand how to connect two tools together ;-)

@pke
Copy link

pke commented Mar 14, 2017

I also always wondered what the difference between storybooks and styleguidist is. I think I favour the latter for its easy markdown readme and most of all, users of the guide can "write their own story", because styleguidist allows live editing of code from the (static) guide side.

@sapegin
Copy link

sapegin commented May 8, 2017

@pke Yeah, ability to generate a style guide with all components on the same page and different way of writing stories / examples are the main differences.

@stale
Copy link

stale bot commented Oct 31, 2017

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. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks!

@stale stale bot added the inactive label Oct 31, 2017
@stale
Copy link

stale bot commented Nov 2, 2017

Hey there, it's me again! I am going to help our maintainers close this issue so they can focus on development efforts instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Nov 2, 2017
@IanVS
Copy link
Member

IanVS commented Nov 5, 2018

This issue fits really well with this article comparing storybook and styleguidist: https://blog.hichroma.com/storybook-vs-styleguidist-2bd93d6dcc06. The TL;DR is that they both fill different needs. Storybook is great for developers creating components in isolation, and styleguidist is well-suited for creating documentation around them. The author ends by saying he he wishes the two could be combined. I agree.

To accomplish this, I think we need two pieces. One is to be able to create rich documentation about a component, and https://github.com/tuchk4/storybook-readme seems perfect for that. But the piece that is still missing, I think, is being able to generate a single page with all of the documentation for all of the components. Imagine a new developer on the team looking for a particular type of component, but not knowing what it's called. It is much easier to scroll through a single page looking for something that looks right, than it is to click through the elements in a sidebar, guessing from their names.

All that to say, does anyone think it might be possible to create a single page combining all of the stories together, using either info-addon or storybook-readme?

@pke
Copy link

pke commented Nov 5, 2018

I don't want to learn a new DSL for writing documentation. I still think styleguidist solves the problem at hand better and smoother.
Also by facilitating readme files in every component folder, that readme can be seen when browsing the github repo without even opening the styleguidist docu. So I can not see how both projects fill different needs, for me they do the same.

@IanVS
Copy link
Member

IanVS commented Nov 5, 2018

I agree that being able to pull in readme docs into stories with storybook-readme is awesome for the reasons you describe. I think the main thing still missing from storybook, is the ability to scroll down a single page and see all the components, without having to click once or twice through the scrollbar for each one.

@crash7
Copy link

crash7 commented Jan 10, 2019

I'm trying to build the same, just because I want the view-port feature that storybook has with that addon but couldn't find a way to load the stories from the readme or the other way around.

@QingLeiLi
Copy link

Any progress about this?

@IanVS
Copy link
Member

IanVS commented Jul 8, 2019

I'm hopeful that this will give us what we are looking for: https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a

@QingLeiLi
Copy link

I'm hopeful that this will give us what we are looking for: https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a

Thanks for the quick reply, I will take a look at the article. Also thanks for the hard work what you are doing on the SB.

@shilman
Copy link
Member

shilman commented Jul 8, 2019

@IanVS @QingLeiLi If you want to try it out, here's a more recent guide: https://docs.google.com/document/d/1un6YX7xDKEKl5-MVb-egnOYN8dynb5Hf7mq0hipk8JE/edit?usp=sharing

Currently in alpha, hustling to get it into beta this week 🤞

@QingLeiLi
Copy link

@IanVS @QingLeiLi If you want to try it out, here's a more recent guide: https://docs.google.com/document/d/1un6YX7xDKEKl5-MVb-egnOYN8dynb5Hf7mq0hipk8JE/edit?usp=sharing

Currently in alpha, hustling to get it into beta this week 🤞

Nine work! I will give it a try soon.

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