code: def cog(options):
      
      options.order('cog', 'sphinx', add_rest=True)
      # Figure out if we were given a filename or
      # directory, and scan the directory for files
      # if we need to.
      files_to_cog = getattr(options, 'args', [])
      if files_to_cog and os.path.isdir(files_to_cog[0]):
          dir_to_scan = path(files_to_cog[0])
          files_to_cog = list(dir_to_scan.walkfiles(
              options.get("pattern", "*.rst")
          ))
      try:
          _runcog(options, files_to_cog)
      except Exception as err:
          print('ERROR: %s' % err)
          raise
      return
docs: Run cog against all or a subset of the input source files.
  
      Examples::
  
        $ paver cog PyMOTW/atexit
        $ paver cog PyMOTW/atexit/index.rst
        $ paver cog
  
      See help on paver.doctools.cog for details on the standard
      options.