src/simple-react-docgen.js
/**
 * write documentation from a directory files
 */
write documentation from a directory files
write documentation from a directory files
function writeDocFromDirectory(directoryPath) {
  let templateData = { files: [] }
  dir.readFiles(
    directoryPath,
    {
      match: new RegExp('\\.(?:' + argv.extensions.join('|') + ')$'),
      exclude: argv.excludePatterns,
      excludeDir: argv.ignoreDirs,
    },
    function(err, content, filename, next) {
      if (err) { throw err }
      try {
        let components = parse(content, resolver.findAllExportedComponentDefinitions)
        templateData.files.push({ filename, components })
      } catch (e) {
        if (!argv.ignoreDocgenErrors) {
          console.error(`Error from react-docgen at ${filename}:`)
          console.error(e)
        }
      }
      next()
    },
    function(err) {
      if (err) { throw err }
      output.write(template(templateData))
    }
  )
}
function writeDocFromDirectory ( directoryPath ) { let templateData = { files : [ ] } dir . readFiles ( directoryPath , { match : new RegExp ( '\\.(?:' + argv . extensions . join ( '|' ) + ')$' ) , exclude : argv . excludePatterns , excludeDir : argv . ignoreDirs , } , function ( err , content , filename , next ) { if ( err ) { throw err } try { let components = parse ( content , resolver . findAllExportedComponentDefinitions ) templateData . files . push ( { filename , components } ) } catch ( e ) { if ( ! argv . ignoreDocgenErrors ) { console . error ( ` ${ filename } ` ) console . error ( e ) } } next ( ) } , function ( err ) { if ( err ) { throw err } output . write ( template ( templateData ) ) } ) }
write documentation from a directory files
write documentation from a directory files
// write the template filled in