@storybook/addon-docs 5.3.17 → 5.3.21
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 +9 -9
- package/angular/README.md +43 -0
- package/dist/frameworks/common/preset.js +13 -3
- package/jest-transform-mdx.js +5 -15
- package/package.json +9 -9
- package/vue/README.md +1 -1
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:
|
package/angular/README.md
CHANGED
|
@@ -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"));
|
|
@@ -55,11 +61,15 @@ function createBabelOptions(babelOptions, configureJSX) {
|
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
var babelPlugins = babelOptions && babelOptions.plugins || [];
|
|
64
|
+
var jsxPlugin = ['@babel/plugin-transform-react-jsx', {
|
|
65
|
+
pragma: 'React.createElement',
|
|
66
|
+
pragmaFrag: 'React.Fragment'
|
|
67
|
+
}];
|
|
58
68
|
return Object.assign({}, babelOptions, {
|
|
59
69
|
// for frameworks that are not working with react, we need to configure
|
|
60
70
|
// the jsx to transpile mdx, for now there will be a flag for that
|
|
61
71
|
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
|
|
62
|
-
plugins: [].concat(_toConsumableArray(babelPlugins), [
|
|
72
|
+
plugins: [].concat(_toConsumableArray(babelPlugins), [jsxPlugin])
|
|
63
73
|
});
|
|
64
74
|
}
|
|
65
75
|
|
|
@@ -72,7 +82,7 @@ function webpack() {
|
|
|
72
82
|
|
|
73
83
|
var babelOptions = options.babelOptions,
|
|
74
84
|
_options$configureJSX = options.configureJSX,
|
|
75
|
-
configureJSX = _options$configureJSX === void 0 ?
|
|
85
|
+
configureJSX = _options$configureJSX === void 0 ? true : _options$configureJSX,
|
|
76
86
|
_options$sourceLoader = options.sourceLoaderOptions,
|
|
77
87
|
sourceLoaderOptions = _options$sourceLoader === void 0 ? {} : _options$sourceLoader;
|
|
78
88
|
var mdxLoaderOptions = {
|
|
@@ -91,7 +101,7 @@ function webpack() {
|
|
|
91
101
|
module: Object.assign({}, module, {
|
|
92
102
|
rules: [].concat(_toConsumableArray(module.rules || []), [{
|
|
93
103
|
test: /\.js$/,
|
|
94
|
-
include:
|
|
104
|
+
include: new RegExp("node_modules\\".concat(_path["default"].sep, "acorn-jsx")),
|
|
95
105
|
use: [{
|
|
96
106
|
loader: 'babel-loader',
|
|
97
107
|
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.21",
|
|
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.21",
|
|
50
|
+
"@storybook/api": "5.3.21",
|
|
51
|
+
"@storybook/components": "5.3.21",
|
|
52
|
+
"@storybook/core-events": "5.3.21",
|
|
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.21",
|
|
55
|
+
"@storybook/source-loader": "5.3.21",
|
|
56
|
+
"@storybook/theming": "5.3.21",
|
|
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": "a939e7204a448e9d24e5431f1c9dba8dd7ec05e9",
|
|
93
93
|
"typesVersions": {
|
|
94
94
|
"<=3.5": {
|
|
95
95
|
"*": [
|
package/vue/README.md
CHANGED
|
@@ -19,7 +19,7 @@ To learn more about Storybook Docs, read the [general documentation](../README.m
|
|
|
19
19
|
First add the package. Make sure that the versions for your `@storybook/*` packages match:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
yarn add -D @storybook/addon-docs
|
|
22
|
+
yarn add -D @storybook/addon-docs
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Then add the following to your `.storybook/main.js` addons:
|