react-docgen
react-docgen copied to clipboard
Better documentation on resolvers
I am trying to write a script to generate markdown from the generated JSON output. I have reviewed the documentation for parse()
and I am trying to use the findAllComponentDefinitions
resolver similar to react-docgen ./myfile.js --resolver findAllComponentDefinitions -o ./docs
in the command line. This is what I attempted, but it doesnt work.
const componentAPI = reactDocs.parse(data, reactDocs.findAllComponentDefinitions)
const markdown = generateMarkdown(components[i], componentAPI)
The current documentation does not seem very clear to me.
Hi @acondiff -- I had the same issue, and had to dig around in the source code to find something that worked.
The resolvers are exposed on a property called "resolver":
const reactDocs = require('react-docgen')
const resolvers = reactDocs.resolver
I think you can get your stuff working if you change your first line to this:
const componentAPI = reactDocs.parse(data, reactDocs.resolver.findAllComponentDefinitions)
Thanks a bunch for this. Made a PR to update the docs with this info (and fix the broken description in the table): https://github.com/reactjs/react-docgen/pull/328