@storybook/addon-docs 5.3.14 → 5.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/angular/README.md +44 -1
- package/dist/frameworks/common/preset.js +7 -1
- package/jest-transform-mdx.js +5 -15
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -92,7 +92,15 @@ Storybook Docs supports all view layers that Storybook supports except for React
|
|
|
92
92
|
|
|
93
93
|
Want to add enhanced features to your favorite framework? Check out this [dev guide](./docs/multiframework.md)
|
|
94
94
|
|
|
95
|
-
##
|
|
95
|
+
## Framework specific installation needs
|
|
96
|
+
|
|
97
|
+
- [React](./react) (covered below)
|
|
98
|
+
- [Vue](./vue)
|
|
99
|
+
- [Angular](./angular)
|
|
100
|
+
- [Ember](./ember)
|
|
101
|
+
- [Web Components](./web-components)
|
|
102
|
+
|
|
103
|
+
## Installation in React
|
|
96
104
|
|
|
97
105
|
First add the package. Make sure that the versions for your `@storybook/*` packages match:
|
|
98
106
|
|
|
@@ -129,14 +137,6 @@ Add the following to your Jest configuration:
|
|
|
129
137
|
}
|
|
130
138
|
```
|
|
131
139
|
|
|
132
|
-
### Be sure to check framework specific installation needs
|
|
133
|
-
|
|
134
|
-
- [React](./react) (covered here)
|
|
135
|
-
- [Vue](./vue)
|
|
136
|
-
- [Angular](./angular)
|
|
137
|
-
- [Ember](./ember)
|
|
138
|
-
- [Web Components](./web-components)
|
|
139
|
-
|
|
140
140
|
## Preset options
|
|
141
141
|
|
|
142
142
|
The `addon-docs` preset has a few configuration options that can be used to configure its babel/webpack loading behavior. Here's an example of how to use the preset with options:
|
|
@@ -162,7 +162,7 @@ The `configureJSX` option is useful when you're writing your docs in MDX and you
|
|
|
162
162
|
|
|
163
163
|
## Manual configuration
|
|
164
164
|
|
|
165
|
-
If you don't want to use the preset, and prefer to configure "the long way" add the following configuration to `.storybook/main.js` (see comments inline for explanation):
|
|
165
|
+
We recommend using the preset, which should work out of the box. If you don't want to use the preset, and prefer to configure "the long way" add the following configuration to `.storybook/main.js` (see comments inline for explanation):
|
|
166
166
|
|
|
167
167
|
```js
|
|
168
168
|
const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin');
|
|
@@ -206,7 +206,7 @@ module.exports = {
|
|
|
206
206
|
};
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
You'll also need to set up the docs parameter in `.storybook/preview.js`. This includes the `DocsPage` for rendering the page, a container, and various configuration options, such as `extractComponentDescription` for manually extracting a component description:
|
|
210
210
|
|
|
211
211
|
```js
|
|
212
212
|
import { addParameters } from '@storybook/react';
|
package/angular/README.md
CHANGED
|
@@ -101,7 +101,7 @@ Then update your `.storybook/main.js` to make sure you load MDX files:
|
|
|
101
101
|
|
|
102
102
|
```ts
|
|
103
103
|
module.exports = {
|
|
104
|
-
stories: ['../src/stories/**/*.stories.(js|mdx)'],
|
|
104
|
+
stories: ['../src/stories/**/*.stories.(js|ts|mdx)'],
|
|
105
105
|
};
|
|
106
106
|
```
|
|
107
107
|
|
|
@@ -131,6 +131,49 @@ Yes, it's redundant to declare `component` twice. [Coming soon](https://github.c
|
|
|
131
131
|
|
|
132
132
|
Also, to use the `Props` doc block, you need to set up Compodoc, [as described above](#docspage).
|
|
133
133
|
|
|
134
|
+
When you are using `template`, `moduleMetadata` and/or `addDecorators` with `storiesOf` then you can easily translate your story to MDX, too:
|
|
135
|
+
|
|
136
|
+
```md
|
|
137
|
+
import { Meta, Story, Props } from '@storybook/addon-docs/blocks';
|
|
138
|
+
import { CheckboxComponent, RadioButtonComponent } from './my-components';
|
|
139
|
+
import { moduleMetadata } from '@storybook/angular';
|
|
140
|
+
|
|
141
|
+
<Meta title='Checkbox' decorators={[
|
|
142
|
+
moduleMetadata({
|
|
143
|
+
declarations: [CheckboxComponent]
|
|
144
|
+
})
|
|
145
|
+
]} />
|
|
146
|
+
|
|
147
|
+
# Basic Checkbox
|
|
148
|
+
|
|
149
|
+
<Story name='basic check' height='400px'>{{
|
|
150
|
+
template: `
|
|
151
|
+
<div class="some-wrapper-with-padding">
|
|
152
|
+
<my-checkbox [checked]="checked">Some Checkbox</my-checkbox>
|
|
153
|
+
</div>
|
|
154
|
+
`,
|
|
155
|
+
props: {
|
|
156
|
+
checked: true
|
|
157
|
+
}
|
|
158
|
+
}}</Story>
|
|
159
|
+
|
|
160
|
+
# Basic Radiobutton
|
|
161
|
+
|
|
162
|
+
<Story name='basic radio' height='400px'>{{
|
|
163
|
+
moduleMetadata: {
|
|
164
|
+
declarations: [RadioButtonComponent]
|
|
165
|
+
}
|
|
166
|
+
template: `
|
|
167
|
+
<div class="some-wrapper-with-padding">
|
|
168
|
+
<my-radio-btn [checked]="checked">Some Checkbox</my-radio-btn>
|
|
169
|
+
</div>
|
|
170
|
+
`,
|
|
171
|
+
props: {
|
|
172
|
+
checked: true
|
|
173
|
+
}
|
|
174
|
+
}}</Story>
|
|
175
|
+
```
|
|
176
|
+
|
|
134
177
|
## IFrame height
|
|
135
178
|
|
|
136
179
|
Storybook Docs renders all Angular stories inside IFrames, with a default height of `60px`. You can update this default globally, or modify the IFrame height locally per story in `DocsPage` and `MDX`.
|
|
@@ -20,6 +20,10 @@ require("core-js/modules/es.object.assign");
|
|
|
20
20
|
|
|
21
21
|
require("core-js/modules/es.object.to-string");
|
|
22
22
|
|
|
23
|
+
require("core-js/modules/es.regexp.constructor");
|
|
24
|
+
|
|
25
|
+
require("core-js/modules/es.regexp.exec");
|
|
26
|
+
|
|
23
27
|
require("core-js/modules/es.regexp.to-string");
|
|
24
28
|
|
|
25
29
|
require("core-js/modules/es.string.iterator");
|
|
@@ -35,6 +39,8 @@ exports.config = config;
|
|
|
35
39
|
|
|
36
40
|
var _mdxCompilerPlugin = _interopRequireDefault(require("@storybook/addon-docs/mdx-compiler-plugin"));
|
|
37
41
|
|
|
42
|
+
var _path = _interopRequireDefault(require("path"));
|
|
43
|
+
|
|
38
44
|
var _remarkSlug = _interopRequireDefault(require("remark-slug"));
|
|
39
45
|
|
|
40
46
|
var _remarkExternalLinks = _interopRequireDefault(require("remark-external-links"));
|
|
@@ -91,7 +97,7 @@ function webpack() {
|
|
|
91
97
|
module: Object.assign({}, module, {
|
|
92
98
|
rules: [].concat(_toConsumableArray(module.rules || []), [{
|
|
93
99
|
test: /\.js$/,
|
|
94
|
-
include:
|
|
100
|
+
include: new RegExp("node_modules\\".concat(_path["default"].sep, "acorn-jsx")),
|
|
95
101
|
use: [{
|
|
96
102
|
loader: 'babel-loader',
|
|
97
103
|
options: {
|
package/jest-transform-mdx.js
CHANGED
|
@@ -7,20 +7,6 @@ const createCompiler = require('./mdx-compiler-plugin');
|
|
|
7
7
|
|
|
8
8
|
const compilers = [createCompiler({})];
|
|
9
9
|
|
|
10
|
-
const getNextTransformer = (filename, config) => {
|
|
11
|
-
const extension = path.extname(filename);
|
|
12
|
-
const jsFileName = `${filename.slice(0, -extension.length)}.js`;
|
|
13
|
-
const self = config.transform.find(([pattern]) => new RegExp(pattern).test(filename));
|
|
14
|
-
const jsTransforms = config.transform.filter(([pattern]) => new RegExp(pattern).test(jsFileName));
|
|
15
|
-
return new ScriptTransformer({
|
|
16
|
-
...config,
|
|
17
|
-
transform: [
|
|
18
|
-
...config.transform.filter(entry => entry !== self),
|
|
19
|
-
...jsTransforms.map(([pattern, ...rest]) => [self[0], ...rest]),
|
|
20
|
-
],
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
10
|
module.exports = {
|
|
25
11
|
process(src, filename, config, { instrument }) {
|
|
26
12
|
const result = dedent`
|
|
@@ -29,6 +15,10 @@ module.exports = {
|
|
|
29
15
|
import { mdx } from '@mdx-js/react'
|
|
30
16
|
${mdx.sync(src, { compilers, filepath: filename })}
|
|
31
17
|
`;
|
|
32
|
-
|
|
18
|
+
|
|
19
|
+
const extension = path.extname(filename);
|
|
20
|
+
const jsFileName = `${filename.slice(0, -extension.length)}.js`;
|
|
21
|
+
|
|
22
|
+
return new ScriptTransformer(config).transformSource(jsFileName, result, instrument);
|
|
33
23
|
},
|
|
34
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.19",
|
|
4
4
|
"description": "Superior documentation for your components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"@mdx-js/loader": "^1.5.1",
|
|
47
47
|
"@mdx-js/mdx": "^1.5.1",
|
|
48
48
|
"@mdx-js/react": "^1.5.1",
|
|
49
|
-
"@storybook/addons": "5.3.
|
|
50
|
-
"@storybook/api": "5.3.
|
|
51
|
-
"@storybook/components": "5.3.
|
|
52
|
-
"@storybook/core-events": "5.3.
|
|
49
|
+
"@storybook/addons": "5.3.19",
|
|
50
|
+
"@storybook/api": "5.3.19",
|
|
51
|
+
"@storybook/components": "5.3.19",
|
|
52
|
+
"@storybook/core-events": "5.3.19",
|
|
53
53
|
"@storybook/csf": "0.0.1",
|
|
54
|
-
"@storybook/postinstall": "5.3.
|
|
55
|
-
"@storybook/source-loader": "5.3.
|
|
56
|
-
"@storybook/theming": "5.3.
|
|
54
|
+
"@storybook/postinstall": "5.3.19",
|
|
55
|
+
"@storybook/source-loader": "5.3.19",
|
|
56
|
+
"@storybook/theming": "5.3.19",
|
|
57
57
|
"acorn": "^7.1.0",
|
|
58
58
|
"acorn-jsx": "^5.1.0",
|
|
59
59
|
"acorn-walk": "^7.0.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "e26136f29d99fdcec82a25689f0f7a10ef418fe1",
|
|
93
93
|
"typesVersions": {
|
|
94
94
|
"<=3.5": {
|
|
95
95
|
"*": [
|