react-docgen

A CLI and library to extract information from React component files for documentation generation purposes.

MIT License

Downloads
19.6M
Stars
3.6K
Committers
89

Bot releases are visible (Hide)

react-docgen -

Published by fkling about 7 years ago

(cherry picked changes released in v2.19.0)

New

See v2.19.0.

Fixed

  • 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!

Other


You can install this version via npm install react-docgen@next.

react-docgen -

Published by fkling about 7 years ago

New

  • The names of class declarations and function declarations are now used as displayNames (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)

Other

  • resolveToModule also resolvesJSXIdentifiers now (2c6e55aa838c1cb9a6755711a17ca4f108cbdf13)
react-docgen - v3.0.0-beta7

Published by danez about 7 years ago

(cherry picked changes released in v2.18.0)

New

See v2.18.0.

Fixed

See v2.18.0.

Other

See v2.18.0.

  • Upgraded babylon to v7.0.0-beta20.

You can install this version via npm install react-docgen@next.

react-docgen - v2.18.0

Published by danez about 7 years ago

New

  • Add support for flow >=0.53 and the new react definitions (#209).
  • Resolve Object.keys in PropType.oneOf() (#211).
    For example:
    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"
    
    
react-docgen -

Published by fkling about 7 years ago

(cherry picked changes released in v2.17.0)

New

See v2.17.0.

Fixed

See v2.17.0.

Other

See v2.17.0.

  • Upgraded babylon to v7.0.0-beta17.

You can install this version via npm install react-docgen@next.

react-docgen -

Published by fkling about 7 years ago

New

  • 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.

Fixed

  • Using array destructuring in class method parameters doesn't throw an error anymore. ( #197 )

Other

  • Upgraded dependencies, especially recast ( 760c426 ).
react-docgen -

Published by fkling over 7 years ago

(cherry picked changes from v2.16.0)

New

  • -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.

react-docgen -

Published by fkling over 7 years ago

New

  • -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).

Thank you @wallaroo for your contribution!

react-docgen -

Published by fkling over 7 years ago

New

  • @wcjordan added support for the create-react-class module! ( #179 ) (cherry picked) from v2.15.0

You can install this version via npm install react-docgen@next.

react-docgen -

Published by fkling over 7 years ago

New

  • @wcjordan added support for the create-react-class module! ( #179 )
react-docgen -

Published by fkling over 7 years ago

Fixed

  • Revert Babel setting changes ( #174 , #175 , @danez )
react-docgen -

Published by fkling over 7 years ago

  • Upgraded to babylon v7.0.0-beta.8
  • Cherry-picked some changes released with v2.14.0
    • 34ab2aef215e2c557a25e952540ed868334dd349
    • d19d73d064cfa804157aa5afe979ba9e1ef8f6cb
    • 51e0938d06b092a09b79b0da87afff02cc322508

You can install this version via npm install react-docgen@next.

react-docgen -

Published by fkling over 7 years ago

New

  • Added support for developit/proptypes ( #163, @eduardoboucas) and prop-types ( #172, @sawyerh) packages.
  • Recognize functions calling React.Children.only as React components ( #169, @damian )

Improvement

  • Ignore coverage/ folder when publishing to npm, reducing package size by more than 50%! ( #166, @fabiosantoscode )
react-docgen -

Published by fkling over 7 years ago

Upgrade babylon to v7.0-beta.4 ( #165 )


You can install this release via

npm install react-docgen@next
# or
yarn add react-docgen@next
react-docgen -

Published by fkling over 7 years ago

While this a new major version, there shouldn't be any breaking changes. We switched to babylon v7(beta) ( #158 ) internally, which supports most flow type annotations. It is published as a prerelease so you can test it on your codebase first.

Other changes:

  • The proptypes package is recognized as proptypes definition provider ( #163 ).

You can install this release via

npm install react-docgen@next
# or
yarn add react-docgen@next
react-docgen -

Published by fkling almost 8 years ago

New / changed

  • Ignore __mocks__ directories by default (#135) (@aitherios)
  • Recognized functions that call React.cloneElement as stateless components (#138) (@khankuan)

Fixes

  • Infinite loop issue with MemberExpressions inside stateless components ( #136, #139, #143 ) (@tchon, @danez)
  • Crash when a SpreadProperty is used in shape propTypes (#145) (@arktes)

Internal changes

react-docgen -

Published by fkling almost 8 years ago

Fixed

  • Fixed an issue where props without default value would be reported as having computed default values. This only affected stateless components. Reported by @arunoda in #131 and fixed by @CompuIves in #132.
react-docgen -

Published by fkling almost 8 years ago

New

  • Support for objectOf prop type (86b167f) (reported as #74)
  • Treat default arguments as default props in stateless components ( #108, @CompuIves)

Improved

  • When passing an unknown value to shape(...), react-docgen will now report that value as computed.

    Example: shape(Child.propTypes)
    Before:

    "type": {
      "name": "shape",
      "value": "unkown"
    }
    

    Now:

    "type": {
      "name": "shape",
      "value": "Child.propTypes",
      "computed": true
    }
    

    (eb0edaa) (reported as #87)

  • Resolve static values passed to oneOf. Examples:

    React.PropTypes.oneOf([TYPES.FOO, TYPES.BAR]);
    // or:
    var TYPES = ["FOO", "BAR"];
    React.PropTypes.oneOf(TYPES);
    // or:
    var TYPES = ["A", "B"];
    var MORE = [...TYPES, "C"];
    React.PropTypes.oneOf(MORE);
    

    (#122, @ZauberNerd)

Fixed

  • Fixed an issue with the output of react-docgen being truncated when piping to another command (#127, @mmeineke)
react-docgen -

Published by fkling about 8 years ago

New

Detect exported components passed to HOCs

Until now, react-docgen didn’t find components that are passed to a higher order component (HOC):

function MyComponent() { /* ... */ }
export default hoc(MyComponent);

The workaround was to change the resolver to find all component definitions in the file, something that is not always desirable.

With #124, @rtsao extended the default resolver to be able to handle these cases.

Fixes

  • findAllExportedComponentDefinitions can now be selected in the CLI.
    (reported as issue #119)

  • The static variable resolution process was fixed to consider assignments to variables. The following example didn’t work before and works now:

    var Component;
    Component = React.createClass(...);
    module.exports = Component;
    

    (reported as issue #58)

  • The display name handler now takes displayName getters in class definitions into account:

    class Component extends React.Component {
      static get displayName() {
        return 'Name';
      }
    }
    

    (reported as issue #61)

Internal improvements

To guard ourselves better against regressions, we are using jest’s snapshot tests to test component definitions that are reported as broken.

react-docgen -

Published by fkling about 8 years ago

New

  • New findAllExportedComponentDefinitions resolver. As the name suggests, it finds all exported component definitions. This complements the resolvers for finding all component definitions and the default exported definition ( #114, @ZauberNerd )
  • New CLI option: -e, --exclude PATTERN, allows you to skip files that match the provided pattern ( #102, @wallaroo )

Fixed / improved

  • Currently resolve namespace imports to their module ( #109, @ZauberNerd )
  • Resolve MemberExpressions (such as propTypes of a stateless component) to the correct object ( #111, @ZauberNerd )
  • Handle intersection and union flow types for prop types definitions. Intersection types are supported, union types are silently ignored. Before react-docgen would throw an error. ( #118, @danez )
  • If a default prop value references an imported value, the value of the prop will now be the variable name ( #99 , @nathanmarks )
  • The jsdoc type declarations @param {x|y} and @param {*} now correctly resolve to their equivalent flow type declarations (union and mixed). ( #95 , @dickeylth )

Thanks to everyone who contributed, this is great!