diff --git a/app/react/src/server/config/babel.prod.js b/app/react/src/server/config/babel.prod.js index 59a87fe49bc3..c2914f4ce748 100644 --- a/app/react/src/server/config/babel.prod.js +++ b/app/react/src/server/config/babel.prod.js @@ -16,6 +16,12 @@ module.exports = { require.resolve('babel-preset-minify'), ], plugins: [ + [ + require.resolve('babel-plugin-react-docgen'), + { + DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES', + }, + ], require.resolve('babel-plugin-transform-regenerator'), [ require.resolve('babel-plugin-transform-runtime'), diff --git a/examples/cra-kitchen-sink/src/components/ImportedPropsButton.js b/examples/cra-kitchen-sink/src/components/ImportedPropsButton.js new file mode 100644 index 000000000000..6ee56cbca6d1 --- /dev/null +++ b/examples/cra-kitchen-sink/src/components/ImportedPropsButton.js @@ -0,0 +1,14 @@ +import React from 'react'; +import DocgenButton from './DocgenButton'; + +/** Button component description */ +const ImportedPropsButton = ({ disabled, label, onClick }) => + ; + +ImportedPropsButton.defaultProps = DocgenButton.defaultProps; + +ImportedPropsButton.propTypes = DocgenButton.propTypes; + +export default ImportedPropsButton; diff --git a/examples/cra-kitchen-sink/src/stories/__snapshots__/index.storyshot b/examples/cra-kitchen-sink/src/stories/__snapshots__/index.storyshot index 3b27e86a5a5c..70e110e98387 100644 --- a/examples/cra-kitchen-sink/src/stories/__snapshots__/index.storyshot +++ b/examples/cra-kitchen-sink/src/stories/__snapshots__/index.storyshot @@ -150,7 +150,7 @@ exports[`Storyshots AddonInfo.DocgenButton DocgenButton 1`] = ` } } > - Some Description + Button with PropTypes and doc comments
+ Button with PropTypes imported from another file. Should fallback to using PropTypes for data. +
++++ + < + ImportedPropsButton + + + + + + onClick + + + = + + + + clicked() + + + + + + + + + label + + + = + + + " + Docgen Button + " + + + + + + + + /> + ++
+ property + | ++ propType + | ++ required + | ++ default + | ++ description + | +
---|---|---|---|---|
+ disabled + | ++ bool + | ++ no + | ++ + + false + + + | ++ |
+ label + | ++ string + | ++ yes + | ++ - + | ++ |
+ onClick + | ++ func + | ++ no + | ++ + + onClick() + + + | ++ |
+ one + | ++ other + | ++ no + | ++ - + | ++ |
+ two + | ++ other + | ++ no + | ++ - + | ++ |
+ msg + | ++ other + | ++ no + | ++ - + | ++ |
+ enm + | ++ other + | ++ no + | ++ - + | ++ |
+ union + | ++ other + | ++ no + | ++ - + | ++ |