Coder Social home page Coder Social logo

Comments (7)

bartvde avatar bartvde commented on April 28, 2024 4

@tizmagik I'm using a small script, here is the code snippet:

var reactDocs = require('react-docgen');
var fs = require('fs');
var path = require('path');
var generateMarkdown = require('./generateMarkdown');

var dir = 'js/components/';
var output = 'docs/api/';

fs.readdir(dir, function(err, files) {
  if (err) {
    throw err;
  }
  files.forEach(function(file) {
    if (path.extname(file) === '.js' || path.extname(file) === '.jsx') {
      fs.readFile(dir + file, 'utf-8', function(err,src) {
        if (err) {
          throw err;
        }
        var componentInfo;
        try {
          componentInfo = reactDocs.parse(src, reactDocs.resolver.findAllComponentDefinitions);
        } catch(e) {
        }
        if (componentInfo  && componentInfo[0].description !== '') {
          var name = file.split('.')[0];
          var markdown = generateMarkdown(name, componentInfo[0]);
          fs.writeFileSync(output + name + '.md', markdown);
        }
      });
    }
  });
});

from react-docgen.

fkling avatar fkling commented on April 28, 2024

You could either create your own resolver with the utility functions that react-docgen provides, or you could use the findAllReactComponents resolver.

However, I do think this use case is not uncommon and it might be worth it to have better support for this by default.

from react-docgen.

bartvde avatar bartvde commented on April 28, 2024

@fkling where do I find the findAllReactComponents resolver?

from react-docgen.

fkling avatar fkling commented on April 28, 2024

https://github.com/reactjs/react-docgen/blob/master/src/resolver/findAllComponentDefinitions.js is what I mean.

from react-docgen.

bartvde avatar bartvde commented on April 28, 2024

Ah thanks, a github search did not find this one, probably because I searched for findAllReactComponents.

from react-docgen.

bartvde avatar bartvde commented on April 28, 2024

Thanks I managed to resolve my issue per your suggestion.

from react-docgen.

tizmagik avatar tizmagik commented on April 28, 2024

@bartvde do you mind sharing where you landed with this? I'm having a similar issue and can't seem to use the component found by findAllComponentDefinitions()

from react-docgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.