babel-plugin-react-docgen
Advanced tools
Comparing version 4.1.0 to 4.2.0
128
CHANGELOG.md
# ChangeLog | ||
### v4.2.0 | ||
24-09-2020 | ||
New Features: | ||
- Allow more configuration of react-docgen #88 | ||
Dependencies: | ||
- Bump acorn from 5.7.3 to 5.7.4 #89 | ||
- Bump yargs-parser from 13.1.1 to 13.1.2 #87 | ||
- Bump lodash from 4.17.15 to 4.17.19 #86 | ||
### v4.1.0 | ||
14-01-2020 | ||
New Features: | ||
* Pass filename to React Docgen for better babel transpilation #81 | ||
- Pass filename to React Docgen for better babel transpilation #81 | ||
### v4.0.0 | ||
03-01-2020 | ||
Breaking changes: | ||
* Upgrade to `react-docgen@5.0.0` | ||
- Upgrade to `react-docgen@5.0.0` | ||
Maintenance: | ||
* Overhaul tests to use jest instead of mocha | ||
- Overhaul tests to use jest instead of mocha | ||
### v3.1.0 | ||
16-04-2019 | ||
New Features: | ||
* Add support for custom React Docgen handlers #64, #65 | ||
- Add support for custom React Docgen handlers #64, #65 | ||
### v3.0.0 | ||
27-03-2019 | ||
Breaking changes: | ||
* Upgrade to `react-docgen@4.1.0` | ||
- Upgrade to `react-docgen@4.1.0` | ||
Bug fixes: | ||
* Fixes #67 where `forwardRef` wrapped components are not detected | ||
* Upgrade to `lodash@4.17.10` to fix security vulnerability | ||
- Fixes #67 where `forwardRef` wrapped components are not detected | ||
- Upgrade to `lodash@4.17.10` to fix security vulnerability | ||
### v2.0.2 | ||
29-01-2019 | ||
* Fixes #62 where `recast` is not in the right dependency tree | ||
- Fixes #62 where `recast` is not in the right dependency tree | ||
### v2.0.1 | ||
29-01-2019 | ||
* Updated to use release version of `react-docgen@^3.0.0` | ||
- Updated to use release version of `react-docgen@^3.0.0` | ||
@@ -47,25 +73,29 @@ ### v2.0.0 | ||
Breaking changes: | ||
* Use `findAllExportedComponentDefinitions` by default to generate info for named exports | ||
* Default to not remove method info and changed `.babelrc` key to `removeMethods` | ||
- Use `findAllExportedComponentDefinitions` by default to generate info for named exports | ||
- Default to not remove method info and changed `.babelrc` key to `removeMethods` | ||
Bug fixes: | ||
* Fix for named export using incorrect local name in `export default ComponentName` | ||
[PR38](https://github.com/storybooks/babel-plugin-react-docgen/pull/38) | ||
* Relies on `react-docgen` for more React component detection functionalities | ||
[PR54](https://github.com/storybooks/babel-plugin-react-docgen/pull/54) | ||
* Fix crash on `name` | ||
[PR58](https://github.com/storybooks/babel-plugin-react-docgen/pull/58) | ||
* Upgraded to Babel 7 and react-docgen 3.0-rc.1 | ||
[PR59](https://github.com/storybooks/babel-plugin-react-docgen/pull/59) | ||
- Fix for named export using incorrect local name in `export default ComponentName` | ||
[PR38](https://github.com/storybooks/babel-plugin-react-docgen/pull/38) | ||
- Relies on `react-docgen` for more React component detection functionalities | ||
[PR54](https://github.com/storybooks/babel-plugin-react-docgen/pull/54) | ||
- Fix crash on `name` | ||
[PR58](https://github.com/storybooks/babel-plugin-react-docgen/pull/58) | ||
- Upgraded to Babel 7 and react-docgen 3.0-rc.1 | ||
[PR59](https://github.com/storybooks/babel-plugin-react-docgen/pull/59) | ||
### v1.9.0 | ||
04-April-2018 | ||
* Use react-docgen 3.0-beta for enhanced Flow support | ||
- Use react-docgen 3.0-beta for enhanced Flow support | ||
### v1.8.3 | ||
28-February-2018 | ||
* Add support for `module.exports = className` declaration | ||
[PR47](https://github.com/storybooks/babel-plugin-react-docgen/pull/44) | ||
- Add support for `module.exports = className` declaration | ||
[PR47](https://github.com/storybooks/babel-plugin-react-docgen/pull/44) | ||
@@ -75,37 +105,44 @@ ### v1.8.2 | ||
14-January-2018 | ||
* Add support for stateless functional components declared as `function(){ }` | ||
[PR41](https://github.com/storybooks/babel-plugin-react-docgen/pull/41) | ||
- Add support for stateless functional components declared as `function(){ }` | ||
[PR41](https://github.com/storybooks/babel-plugin-react-docgen/pull/41) | ||
### v1.8.1 | ||
24-September-2017 | ||
* Suppress errors caught during babel traversal | ||
[PR37](https://github.com/storybooks/babel-plugin-react-docgen/pull/37) | ||
- Suppress errors caught during babel traversal | ||
[PR37](https://github.com/storybooks/babel-plugin-react-docgen/pull/37) | ||
### v1.8.0 | ||
24-September-2017 | ||
* Add support for custom resolvers | ||
* Add option to keep method info from docgen | ||
[PR35](https://github.com/storybooks/babel-plugin-react-docgen/pull/35) | ||
- Add support for custom resolvers | ||
- Add option to keep method info from docgen | ||
[PR35](https://github.com/storybooks/babel-plugin-react-docgen/pull/35) | ||
### v1.7.0 | ||
11-August-2017 | ||
* Add support for Higher Order Components with arbitrary depth | ||
[PR32](https://github.com/storybooks/babel-plugin-react-docgen/pull/32) | ||
- Add support for Higher Order Components with arbitrary depth | ||
[PR32](https://github.com/storybooks/babel-plugin-react-docgen/pull/32) | ||
### v1.6.0 | ||
26-July-2017 | ||
* Add support for React.createElement | ||
[PR31](https://github.com/storybooks/babel-plugin-react-docgen/pull/31) | ||
- Add support for React.createElement | ||
[PR31](https://github.com/storybooks/babel-plugin-react-docgen/pull/31) | ||
### v1.5.0 | ||
06-June-2017 | ||
* Uses docgen 2.15.0 and babel-types 6.24.1 | ||
* Add support for components created with React.createClass or createReactClass [PR27](https://github.com/storybooks/babel-plugin-react-docgen/pull/27) | ||
- Uses docgen 2.15.0 and babel-types 6.24.1 | ||
- Add support for components created with React.createClass or createReactClass [PR27](https://github.com/storybooks/babel-plugin-react-docgen/pull/27) | ||
### v1.4.2 | ||
03-January-2017 | ||
@@ -116,2 +153,3 @@ | ||
### v1.4.1 | ||
03-November-2016 | ||
@@ -122,2 +160,3 @@ | ||
### v1.4.0 | ||
01-November-2016 | ||
@@ -128,7 +167,9 @@ | ||
### v1.3.1 | ||
23-October-2016 | ||
* Restrict JSX lookup only for direct JSX returns. [PR15](https://github.com/kadirahq/babel-plugin-react-docgen/pull/15) | ||
- Restrict JSX lookup only for direct JSX returns. [PR15](https://github.com/kadirahq/babel-plugin-react-docgen/pull/15) | ||
### v1.3.1 | ||
21-October-2016 | ||
@@ -139,9 +180,11 @@ | ||
### v1.3.0 | ||
20-October-2016 | ||
* Use docgen version 2.11.0. [PR11](https://github.com/kadirahq/babel-plugin-react-docgen/pull/11) | ||
* Rename DOC_GEN_GLOBAL to DOC_GEN_COLLECTION_NAME. [PR12](https://github.com/kadirahq/babel-plugin-react-docgen/pull/12) | ||
* Update the README. [PR13](https://github.com/kadirahq/babel-plugin-react-docgen/pull/13) | ||
- Use docgen version 2.11.0. [PR11](https://github.com/kadirahq/babel-plugin-react-docgen/pull/11) | ||
- Rename DOC_GEN_GLOBAL to DOC_GEN_COLLECTION_NAME. [PR12](https://github.com/kadirahq/babel-plugin-react-docgen/pull/12) | ||
- Update the README. [PR13](https://github.com/kadirahq/babel-plugin-react-docgen/pull/13) | ||
### v1.1.0 | ||
20-October-2016 | ||
@@ -152,6 +195,7 @@ | ||
### v1.2.0 | ||
20-October-2016 | ||
* Stateless component support | ||
* Global object with all the component docs | ||
* `__docgenInfo` is now an actual object instead of a JSON string | ||
- Stateless component support | ||
- Global object with all the component docs | ||
- `__docgenInfo` is now an actual object instead of a JSON string |
@@ -14,4 +14,2 @@ "use strict"; | ||
var reactDocgenHandlers = _interopRequireWildcard(require("react-docgen/dist/handlers")); | ||
var _actualNameHandler = _interopRequireDefault(require("./actualNameHandler")); | ||
@@ -27,2 +25,8 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -36,3 +40,7 @@ | ||
var defaultHandlers = Object.values(reactDocgenHandlers).map(function (handler) { | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var defaultHandlers = Object.values(ReactDocgen.handlers).map(function (handler) { | ||
return handler; | ||
@@ -57,2 +65,9 @@ }); | ||
var program = path.scope.getProgramParent().path; | ||
var _state$opts = state.opts, | ||
resolverOpt = _state$opts.resolver, | ||
handlersOpt = _state$opts.handlers, | ||
DOC_GEN_COLLECTION_NAME = _state$opts.DOC_GEN_COLLECTION_NAME, | ||
opts = _objectWithoutProperties(_state$opts, ["resolver", "handlers", "DOC_GEN_COLLECTION_NAME"]); | ||
var docgenResults = []; | ||
@@ -63,4 +78,6 @@ | ||
if (state.opts.resolver) { | ||
resolver = ReactDocgen.resolver[state.opts.resolver]; | ||
if (typeof resolverOpt === 'string') { | ||
resolver = ReactDocgen.resolver[resolverOpt]; | ||
} else if (typeof resolverOpt === 'function') { | ||
resolver = resolverOpt; | ||
} | ||
@@ -70,5 +87,9 @@ | ||
if (state.opts.handlers) { | ||
state.opts.handlers.forEach(function (handler) { | ||
customHandlers.push(require(handler)); | ||
if (handlersOpt) { | ||
handlersOpt.forEach(function (handler) { | ||
if (typeof handler === 'string') { | ||
customHandlers.push(require(handler)); | ||
} else if (typeof handler === 'function') { | ||
customHandlers.push(handler); | ||
} | ||
}); | ||
@@ -78,6 +99,10 @@ } | ||
var handlers = [].concat(_toConsumableArray(defaultHandlers), customHandlers, [_actualNameHandler["default"]]); | ||
docgenResults = ReactDocgen.parse(code, resolver, handlers, { | ||
docgenResults = ReactDocgen.parse(code, resolver, handlers, _objectSpread({}, opts, { | ||
filename: filename | ||
}); | ||
})); | ||
if (docgenResults && !Array.isArray(docgenResults)) { | ||
docgenResults = [docgenResults]; | ||
} | ||
if (state.opts.removeMethods) { | ||
@@ -84,0 +109,0 @@ docgenResults.forEach(function (docgenResult) { |
{ | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"name": "babel-plugin-react-docgen", | ||
@@ -4,0 +4,0 @@ "description": "Babel plugin to add react-docgen info into your code", |
@@ -90,4 +90,7 @@ # babel-plugin-react-docgen | ||
| --- | --- | --- | | ||
| resolver | [react-docgen](https://github.com/reactjs/react-docgen) has 3 built in resolvers which may be used. Resolvers define how/what the doc generator will inspect. You may inspect the existing resolvers in [react-docgen/tree/master/src/resolver](https://github.com/reactjs/react-docgen/tree/master/src/resolver). | ```"findAllExportedComponentDefinition"``` | | ||
| removeMethods | optionally remove docgen information about methods | ```false``` | | ||
| resolver | You may use the 3 built-in [react-docgen resolvers](https://github.com/reactjs/react-docgen#resolver-1) by specifying its name as a `string`, or you may specify a custom resolver by specifying the function explicitly. | ```"findAllExportedComponentDefinition"``` | | ||
| handlers | All [react-docgen handlers](https://github.com/reactjs/react-docgen#handlers-1) are automatically applied. However, custom handlers can be added by specifying them here. Any `string` value will be loaded by `require`, and a `function` will be used directly. | | | ||
| removeMethods | Used to remove docgen information about methods. | ```false``` | | ||
| DOC_GEN_COLLECTION_NAME | The name of a global variable where all docgen information can be stored. See [below](#collect-all-docgen-info) for more information. | | | ||
| ...options | Remaining options will be passed directly as [react-docgen options](https://github.com/reactjs/react-docgen#options). Any options they allowed will be passed through, but the `filename` will be overwritten by the filename provided by babel. | | | ||
@@ -109,3 +112,3 @@ ## Collect All Docgen Info | ||
"removeMethods": true, // optional (default: false) | ||
"handlers:": ["react-docgen-deprecation-handler"] // optional array of custom handlers (use the string name of the package in the array) | ||
"handlers": ["react-docgen-deprecation-handler"] // optional array of custom handlers | ||
} | ||
@@ -132,6 +135,5 @@ ] | ||
Now, we parse your code with `react-docgen` to get these info. | ||
But we only do it for files which has a React component. | ||
We parse your code with `react-docgen` to get this info, but we only do it for files which contain a React component. | ||
Yes, this will add some overhead to your project. But once you turned on [babel cache directory](http://stackoverflow.com/a/30384710) this won't be a big issue. | ||
There will be some overhead to your project, but you can leverage [babel's cache directory](http://stackoverflow.com/a/30384710) to avoid this a huge performance hit. | ||
@@ -138,0 +140,0 @@ ## Output Size |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25592
237
146