lib/rcs.js
function RCS (input, opts) {
  opts = opts || {}

  this.log = require('./logger')('rcs-lib', {debug: opts.verbose || false})

  var config

  // If feeding in a direct config object
  if (opts.config !== null && typeof opts.config === 'object') {
    config = opts.config
  } else {
    config = this.readConfig(opts.config)
  }

  opts = assign(config, opts)

  opts.output = path.resolve(process.cwd(), (opts.output || 'styleguide').replace(/\/+$/, ''))
  opts.title = opts.title || 'Style Guide'
  opts.root = opts.root ? path.normalize('/' + opts.root.replace(/\/+$/, '')) : null
  opts.pushstate = opts.pushstate || false
  opts.files = opts.files || []
  opts.babelConfig = opts.babelConfig || null
  opts.webpackConfig = opts.webpackConfig || {}
  // Run on port 3000 if mode enabled but port not specified
  if (opts.dev && opts.dev === true) {
    opts.dev = 3000
  } else if (!opts.dev) {
    opts.dev = false
  }

  var globOptions = opts.ignore ? {realpath: true, ignore: opts.ignore } : {realpath: true};
  opts.styleComponents = opts.styleComponents ? glob.sync(opts.styleComponents, globOptions) : false;

  this.input = glob
    .sync(input, {realpath: true})
    .filter(function (file) {
      var readFile = fs.readFileSync(file);
      try {
        if (reactDocGenModule.parse(readFile)) {
          return true
        }
      } catch (e) {
        return false
      }
    });

  opts['reactDocgen'] = opts['reactDocgen'] || {}

  if (!opts['reactDocgen'].files) {
    opts['reactDocgen'].files = [input]
  }

  this.opts = opts

  // files to parse for react-docgen
  this.reactDocGenFiles = this.getReactPropDocFiles()

  // Cached files to include into the styleguide app
  this.cssFiles = this.extractFiles('.css')
  this.jsFiles = this.extractFiles('.js')

  this.appTemplate = fs.readFileSync(path.resolve(__dirname, './fixtures/index.html.mustache'), 'utf-8')

  this.stageDir = path.resolve(__dirname, '../rcs-tmp')
}
function RCS (input, opts) {
  opts = opts || {}

  this.log = require('./logger')('rcs-lib', {debug: opts.verbose || false})

  var config

  // If feeding in a direct config object
  if (opts.config !== null && typeof opts.config === 'object') {
    config = opts.config
  } else {
    config = this.readConfig(opts.config)
  }

  opts = assign(config, opts)

  opts.output = path.resolve(process.cwd(), (opts.output || 'styleguide').replace(/\/+$/, ''))
  opts.title = opts.title || 'Style Guide'
  opts.root = opts.root ? path.normalize('/' + opts.root.replace(/\/+$/, '')) : null
  opts.pushstate = opts.pushstate || false
  opts.files = opts.files || []
  opts.babelConfig = opts.babelConfig || null
  opts.webpackConfig = opts.webpackConfig || {}
  // Run on port 3000 if mode enabled but port not specified
  if (opts.dev && opts.dev === true) {
    opts.dev = 3000
  } else if (!opts.dev) {
    opts.dev = false
  }

  var globOptions = opts.ignore ? {realpath: true, ignore: opts.ignore } : {realpath: true};
  opts.styleComponents = opts.styleComponents ? glob.sync(opts.styleComponents, globOptions) : false;

  this.input = glob
    .sync(input, {realpath: true})
    .filter(function (file) {
      var readFile = fs.readFileSync(file);
      try {
        if (reactDocGenModule.parse(readFile)) {
          return true
        }
      } catch (e) {
        return false
      }
    });

  opts['reactDocgen'] = opts['reactDocgen'] || {}

  if (!opts['reactDocgen'].files) {
    opts['reactDocgen'].files = [input]
  }

  this.opts = opts

  // files to parse for react-docgen
  this.reactDocGenFiles = this.getReactPropDocFiles()

  // Cached files to include into the styleguide app
  this.cssFiles = this.extractFiles('.css')
  this.jsFiles = this.extractFiles('.js')

  this.appTemplate = fs.readFileSync(path.resolve(__dirname, './fixtures/index.html.mustache'), 'utf-8')

  this.stageDir = path.resolve(__dirname, '../rcs-tmp')
}
function RCS ( input , opts ) { opts = opts || { } this . log = require ( './logger' ) ( 'rcs-lib' , { debug : opts . verbose || false } ) var config // If feeding in a direct config object if ( opts . config !== null && typeof opts . config === 'object' ) { config = opts . config } else { config = this . readConfig ( opts . config ) } opts = assign ( config , opts ) opts . output = path . resolve ( process . cwd ( ) , ( opts . output || 'styleguide' ) . replace ( / \/+$ / , '' ) ) opts . title = opts . title || 'Style Guide' opts . root = opts . root ? path . normalize ( '/' + opts . root . replace ( / \/+$ / , '' ) ) : null opts . pushstate = opts . pushstate || false opts . files = opts . files || [ ] opts . babelConfig = opts . babelConfig || null opts . webpackConfig = opts . webpackConfig || { } // Run on port 3000 if mode enabled but port not specified if ( opts . dev && opts . dev === true ) { opts . dev = 3000 } else if ( ! opts . dev ) { opts . dev = false } var globOptions = opts . ignore ? { realpath : true , ignore : opts . ignore } : { realpath : true } ; opts . styleComponents = opts . styleComponents ? glob . sync ( opts . styleComponents , globOptions ) : false ; this . input = glob . sync ( input , { realpath : true } ) . filter ( function ( file ) { var readFile = fs . readFileSync ( file ) ; try { if ( reactDocGenModule . parse ( readFile ) ) { return true } } catch ( e ) { return false } } ) ; opts [ 'reactDocgen' ] = opts [ 'reactDocgen' ] || { } if ( ! opts [ 'reactDocgen' ] . files ) { opts [ 'reactDocgen' ] . files = [ input ] } this . opts = opts // files to parse for react-docgen this . reactDocGenFiles = this . getReactPropDocFiles ( ) // Cached files to include into the styleguide app this . cssFiles = this . extractFiles ( '.css' ) this . jsFiles = this . extractFiles ( '.js' ) this . appTemplate = fs . readFileSync ( path . resolve ( __dirname , './fixtures/index.html.mustache' ) , 'utf-8' ) this . stageDir = path . resolve ( __dirname , '../rcs-tmp' ) }
React Styleguide Generator

@class
@param {string} input
@param {Object} opts
@param {string} opts.output
@param {string} opts.title
@param {string|Object} opts.config
@param {string} opts.root
@param {boolean} opts.pushstate
@param {string[]} opts.files
@param {Object} opts.babelConfig
@param {Object} opts.webpackConfig
@param {Object} opts.reactDocgen
React Styleguide Generator