Skip to content
Discussion options

You must be logged in to vote

So after checkouting and saw that test suits was 🟢 with importing prop-types, it appears that the filename property is indicated in README.md, is indeed highly recommended 🙂

So for posterity, correct script is :

const docgen = require('react-docgen'); const path = 'src/Button/Button.jsx' const src = require('fs').readFileSync(path); const componentInfo = docgen.parse(src, null, null, { importer: docgen.importers.makeFsImporter(), filename: path } ); console.log(componentInfo);

and output is 🎉 :

{ description: '', displayName: 'Button', methods: [], props: { baz: { type: [Object], required: true, description: '' }, foo: { type: [Object], required: true, description: '' }

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@csaunier
Comment options

@phated
Comment options

Comment options

You must be logged in to vote
1 reply
@danez
Comment options

Answer selected by csaunier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants