A CLI and library to extract information from React component files for documentation generation purposes.
MIT License
Bot releases are hidden (Show)
Published by danez over 5 years ago
elementType
in proptypes correctly (#330)Thanks to @eps1lon for fixing it.
Published by danez over 5 years ago
In this version we focused on allowing our internals to be more flexible when it comes to allowing different configurations for @babel/parser
. This will make it easier to introduce support for different javascript flavors (like TypeScript 🎉) in the future.
Thanks to @jquense for working on this changes.
--legacy-decorators
and --decorators-before-export
. (#327)legacyDecorators
and decoratorsBeforeExport
. (#327)parserOptions
option you could still set this configuration, for example: react-docgen.parse(code, null, null, {
- decoratorsBeforeExport: true
+ parserOptions: {
+ plugins: [
+ ["decorators", { decoratorsBeforeExport: true }],
+ ],
+ },
});
@babel/parser
we use. This was a necessary step as a lot of recent proposals in babel have configuration options, so we cannot simply activate everything. This change is not breaking unless your babel configuration is broken and does not enable all necessary features (which should throw already in your project).fs
, net
and module
are correctly mocked, as babel uses them. (see our website configuration)fileName
(#320)cwd
(#320)process.cwd()
.@babel/parser
options through the react-docgen
API with the newly added option parserOptions
. See our README for more information.Published by danez over 5 years ago
forwardRef
as a valid component definition (#311)$Keys
to union when typeParameter is an ObjectTypeAnnotation
(#290)PropTypes.exact
Object.values()
in PropType.oneOf()
(#318)babylon@5
to @babel/parser@7
. This should not break anything, but will support a lot more newer javascript syntax features as well as newer flow syntaxes.--legacy-decorators
or the programmatic options { legacyDecorators: true }
passed as 4th parameter to ReactDocgen.parse().Published by danez almost 6 years ago
Published by danez almost 6 years ago
Published by danez over 6 years ago
--legacy-decorators
or the programmatic options { legacyDecorators: true }
passed as 4th parameter to ReactDocgen.parse()
.@extends React.Component
support to mark classes which do not extend from React.Component
as valid react components (#269)Published by danez over 6 years ago
@extends React.Component
support to isReactComponentClass (#269)Published by danez over 6 years ago
Published by danez over 6 years ago
Published by danez almost 7 years ago
(merged changes released in v2.20.0
)
See v2.20.0
.
Update babylon to latest beta. This allows a lot new syntax proposal which were added to babylon (see babylon changes)
Enable more babylon plugins (#220)
Enables the following new plugins in babylon:
You can install this version via npm install react-docgen@next
.
Published by danez almost 7 years ago
Add support for typeof types and React.* types (#224)
Adds support for all the types described in the react flow docs
Resolve flow $Keys<> to union type (#225)
const CONTENTS = {
'apple': '🍎',
'banana': '🍌',
};
type Props = {
fruit: $Keys<typeof CONTENTS>,
};
(cherry picked changes released in v2.19.0
)
See v2.19.0
.
See v2.19.0
.
Flow: Function type definitions without parameter names are now supported. For example:
type Props = {
callback: (string) => void,
}
In such a case the parameter name will simply be empty. See the commit ( #218 ) for an example of the output. Thank you @odinuge!
v2.19.0
.getMemberValuePath
now understands TaggedTemplateExpression
s. This is used by @Jmeyering's custom annotation resolver. Check it out at https://github.com/Jmeyering/react-docgen-annotation-resolver ! Thank you @Jmeyering!You can install this version via npm install react-docgen@next
.
The names of class declarations and function declarations are now used as displayName
s (3f22b3c49f4056ad725bec8d9908cc1027bf45dc).
In classes, static get propTypes(){}
is now inspected for propTypes. I.e. instead of
class MyComponent extends React.Component {}
MyComponent.propTypes = {
disabled: PropTypes.boolean,
};
you can now write
class MyComponent extends React.Component {
static get propTypes() {
return {
disabled: PropTypes.boolean,
};
}
}
(23aa0feeff512ea841907e75598798de65bedd4a)
resolveToModule
also resolvesJSXIdentifiers
now (2c6e55aa838c1cb9a6755711a17ca4f108cbdf13)Published by danez about 7 years ago
Published by danez about 7 years ago
Object.keys
in PropType.oneOf()
(#211).Component.propTypes = { foo: PropTypes.oneOf(Object.keys({ a: 1, b: 2 }))};
// react-docgen will now correctly extract the type of foo being "a" or "b"
Classes that define a render
public class field are now considered React components. For example:
class Component extends SomeBaseComponent {
render = someFunction;
}
See #193 and fe55485. Thank you @birjolaxew!
Functions assigned to public class fields are now considered as methods. I.e. both function in the following example will be picked up by react-docgen:
class Component extends React.Component {
method1() {}
method2 = () => {
};
}
See 1ff84b7 and #182.
recast
( 760c426 ).(cherry picked changes from v2.16.0)
-e
, --exclude
now accepts a regular expression to filter out files by name: -e /.*-test\.js/
The argument will only be treated as a regular expression if the parameter is only passed once ( #164).You can install this version via npm install react-docgen@next
.