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

Automatically render Description / Prop Tables / Components Methods #170

Open
tuchk4 opened this issue May 29, 2019 · 4 comments
Open

Automatically render Description / Prop Tables / Components Methods #170

tuchk4 opened this issue May 29, 2019 · 4 comments

Comments

@tuchk4
Copy link
Owner

tuchk4 commented May 29, 2019

The same way as <!-- PROPS --> works.
Support

  • <!-- DESCRIPTION --> component's description
  • <!-- METHODS --> component's methods
  • <!-- DOCS --> aggregate & description & methods & props

Also would be nice to automatically generate default readmes

/**
 * This is an awesome looking button for React.
 */
export default class Button extends React.Component {
  static propTypes = {
    /**
     * Button label
     */
    label: PropTypes.string.isRequired,
    /** on click event handler */
    onClick: PropTypes.func,
    /**  Button type */
    variant: PropTypes.oneOf(['success', 'normal', 'warning', 'alert']),
  };

  /**
   * Trigger button click
   */
  click() {
    // ...
  }

  /**
   * Update button variant
   * @param {string} alert | success
   */
  updateVariant(variant) {
    // ...
  }

  render() {
    const { label, ...props } = this.props;
    return <StyledButton {...props}>{label}</StyledButton>;
  }
}

image

@tuchk4
Copy link
Owner Author

tuchk4 commented May 29, 2019

Or we can use jsdoc or similar tool to generate markdown docs on all sources related to story and automatically render at addons panel.

@lonyele What do you think?

@tuchk4 tuchk4 changed the title JSDoc/similar tool support Extend docgen support May 29, 2019
@tuchk4 tuchk4 pinned this issue May 29, 2019
@lonyele
Copy link
Collaborator

lonyele commented Jun 3, 2019

@tuchk4 This looks super cool! How come I couldn't see your mention on my gmail? It's Monday here(weekend is over...), so I'll check this one and #171 over this week(probably coming weekends)

@lonyele
Copy link
Collaborator

lonyele commented Jun 9, 2019

@tuchk4 I maybe can implement this feature as I've understood more about placeholder part of code base while looking at #171. If this feature is implemented and became stable, storybook-readme can have full power on React components that are used here. I think filtering prop tables can be improved by covering more practical cases such as HOC, Render prop or showing whatever propTables if it is specified.

Sunday is almost over here, I think I can do it in coming week. As I know of, you are busy for 1~2 month and preparing for next release. So maybe I can take a look at it?

@tuchk4
Copy link
Owner Author

tuchk4 commented Jun 18, 2019

Yeah, I would like to start with #171 and then add support of all features described here.

According to #171 Proof of concept implemented at #178 for such story:

## TItle
\```js
const value = state.counter || 0;

<Button
  onClick={() => {
    setState({
      counter: value + 1,
    });
  }}
>
  Hello World {value}
</Button>;
\```

### Footer

We will have:

  • Full AST of the story
  • Rendered component's tree (so it is possible to get props/methods/description as implemented in current version)
  • If instead of imports we will pass components as arguments to the story (as I wrote at [Proof of Concept] Multiple Stories inside one MD  #178) -- we will have map of all used components and this is good advantage

So it is possible to render prop table, methods table, description right after story and make it configurable.

So maybe I can take a look at it?

This would be perfect 🔥


Also we should think:

  • Support all of these features (automatically render prop tables / description / methods) for MDX only?
  • Also add support for current implementation?

@tuchk4 tuchk4 changed the title Extend docgen support Automatically render Description / Prop Tables / Components Methods Jun 18, 2019
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

2 participants