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

Addon-docs: Snapshot testing and bug reporting for props tables #9838

Merged
merged 39 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
61545c3
Addon-docs: React properties snapshot testing
shilman Feb 13, 2020
4e73945
Addon-docs: Document prop tables bug reporting and known limitations
shilman Feb 13, 2020
8297083
Merge branch 'next' into 9690-component-properites
shilman Feb 13, 2020
676a597
Merge branch 'next' into 9690-component-properites
shilman Feb 13, 2020
90b97a5
Fix typo
shilman Feb 13, 2020
92bfc1a
Addon-docs: Angular properties snapshot testing POC
shilman Feb 13, 2020
659dc82
Cleanup :joy:
shilman Feb 13, 2020
eeab514
Addon-docs: Cleanup angular properties tests
shilman Feb 14, 2020
ed4b831
Addon-docs: Web-components properties tests
shilman Feb 14, 2020
8063b52
Props: #9399 repro test
shilman Feb 14, 2020
14456b2
Props: #8663 repro
shilman Feb 14, 2020
3cfe6e1
Props: #9626 repro
shilman Feb 14, 2020
b467fa8
Addon-docs: React props extraction stories
shilman Feb 14, 2020
8219af1
Props: #9668 attempted repro
shilman Feb 14, 2020
e3927d9
Props: #8143 repro
shilman Feb 14, 2020
4129773
Props: #8143 repro for imported types
shilman Feb 14, 2020
eaa147a
Props: #8279 repro
shilman Feb 14, 2020
964d40d
Props: #8180 repro
shilman Feb 14, 2020
e3ab757
Props: #9023 repro
shilman Feb 14, 2020
85e4f6d
Props: #8740 repro
shilman Feb 14, 2020
822f3df
Props: #8894 forward-ref repro
shilman Feb 14, 2020
92f8c43
Props: #9556 repro
shilman Feb 14, 2020
c8c19a2
Props: #9592 styled repro
shilman Feb 14, 2020
82ee3a3
Props: #9591 repro
shilman Feb 14, 2020
94a8ae7
Props: #9721 repro
shilman Feb 14, 2020
3e90384
Props: #9832 repro
shilman Feb 14, 2020
05f44c1
Props: #9827 repro
shilman Feb 14, 2020
ee4144a
Props: #9586 repro
shilman Feb 14, 2020
03a2693
Props: #9575 repro
shilman Feb 14, 2020
ed714ba
Props: #9493 repro
shilman Feb 14, 2020
57e571c
Props: #9493 update snapshots
shilman Feb 14, 2020
1032b77
Props: #9511 repro
shilman Feb 14, 2020
dd10817
Props: #9465 repro
shilman Feb 14, 2020
28f7a7e
Props: #8428 repro
shilman Feb 14, 2020
249de2c
Update docgen.snapshot
shilman Feb 14, 2020
ce8a9f2
Props: #9764 repro
shilman Feb 14, 2020
5d942d1
Props: Fix crash on 9399-js-proptypes-shape
shilman Feb 15, 2020
62de2a6
Props: Fix test typings
shilman Feb 15, 2020
b64e3cf
Addon-docs: Fix props tests
shilman Feb 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
{
files: [
'**/__tests__/**',
'**/__testfixtures__/**',
'**/*.test.*',
'**/*.stories.*',
'**/storyshots/**/stories/**',
Expand Down
Binary file added addons/docs/docs/media/props-tables-hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions addons/docs/docs/props-tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<center>
<img src="./media/props-tables-hero.png" width="100%" />
</center>

<h1>Storybook Docs Props Tables</h1>

Storybook Docs automatically generates props tables for components in supported frameworks. This document is a consolidated summary of prop tables, provides instructions for reporting bugs, and list known limitations for each framework.

- [Usage](#usage)
- [Reporting a bug](#reporting-a-bug)
- [Known limitations](#known-limitations)
- [React](#react)
- [Vue](#vue)
- [Angular](#angular)
- [Web components](#web-components)
- [Ember](#ember)
- [More resources](#more-resources)

## Usage

For framework-specific setup instructions, see the framework's README: [React](../../react/README.md), [Vue](../../vue/README.md), [Angular](../../angular/README.md), [Web Components](../../web-components/README.md), [Ember](../../ember/README.md).

To use the props table in [DocsPage](./docspage.md), simply export a component property on your stories metadata:

```js
// MyComponent.stories.js
import { MyComponent } from './MyComponent';

export default {
title: 'MyComponent',
component: MyComponent,
};
// stories etc...
```

To use the props table in [MDX](./mdx.md), use the `Props` block:

```js
// MyComponent.stories.mdx
import { Props } from '@storybook/addon-docs/blocks';
import { MyComponent } from './MyComponent';

# My Component!

<Props of={MyComponent} />
```

## Reporting a bug

Extracting component properties from source is a tricky problem with thousands of corner cases. We've designed this package and its tests to accurately isolate problems, since the cause could either be in this package or (likely) one of the packages it depends on.

If you're seeing a problem with your prop table, here's what to do.

First, look to see if there's already a test case that corresponds to your situation. If there is, it should be documented in the [Known Limitations](#known-limitations) section above. There should also be one or more corresponding test fixtures contained in this package. For example, if you are using React, look under the directory `./src/frameworks/react/__testfixtures__`.

If your problem is not already represented here, do the following:

1. Create a **MINIMAL** repro for your problem. Each case should be just a few lines of code.
2. Place it in the appropriate directory `./src/frameworks/<framework>/__testfixtures__/`, e.g. `./src/frameworks/react/__testfixtures__/XXXX-some-description`, where `XXXX` is the corresponding github issue.
3. Run the tests for your `<framework>`, e.g. `yarn jest --testPathPattern=react-properties.test.ts --watch`
4. Inspect the output files for your test case.
5. Add the example to the appropriate stories file, e.g. `react-properties.stories.ts` for `react`, for a visual repro

If the problem appears to be an issue with this library, file an issue and include a PR that includes your repro.

If the problem appears to be an issue with the sub-package, please file an issue on the appropriate sub-package, document the limitation in [Known Limitations](#known-limitations) below, link to that issue, and submit a PR including the updated documentation and fixtures/snapshots.

## Known limitations

This package relies on a variety of sub-packages to extract property information from components. Many of the bugs in this package correspond to bugs in a sub-package. Since we don't maintain the sub-packages, the best we can do for now is (1) document these limitations, (2) provide clean reproductions to the sub-package, (3) optionally provide PRs to those packages to fix the problems.

### React

SB Docs for React uses `babel-plugin-react-docgen`/`react-docgen` for both JS PropTypes prop tables and, as of 6.0, TypeScript-driven props tables.

### Vue

SB Docs for Vue uses `vue-docgen-loader`/`vue-docgen-api` for SFC and JSX components.

### Angular

SB Docs for Angular uses `compodoc` for prop table information.

### Web components

SB Docs for Web-components uses `custom-elements.json` for prop table information.

### Ember

SB Docs for Ember uses `yui-doc` for prop table information.

## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
15 changes: 12 additions & 3 deletions addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,25 @@
"remark-slug": "^5.1.2",
"ts-dedent": "^1.1.1",
"util-deprecate": "^1.0.2",
"vue-docgen-api": "^4.1.0",
"vue-docgen-loader": "^1.3.0-beta.0"
"vue-docgen-api": "^4.7.0",
"vue-docgen-loader": "^1.4.0"
},
"devDependencies": {
"@storybook/react": "6.0.0-alpha.11",
"@storybook/web-components": "6.0.0-alpha.11",
"@types/doctrine": "^0.0.3",
"@types/enzyme": "^3.10.3",
"@types/jest": "^25.1.1",
"@types/prop-types": "^15.5.9",
"@types/util-deprecate": "^1.0.0",
"jest-specific-snapshot": "^2.0.0"
"babel-plugin-react-docgen": "^4.1.0",
"cross-spawn": "^7.0.1",
"jest-specific-snapshot": "^2.0.0",
"lit-html": "^1.0.0",
"require-from-string": "^2.0.2",
"styled-components": "^5.0.1",
"tmp": "^0.1.0",
"web-component-analyzer": "^1.0.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0",
Expand Down
Loading