# File lib/rubygems_plugin.rb, line 29
  def run_yardoc(*args)
    args << @spec.rdoc_options
    args << '--quiet'
    if @spec.extra_rdoc_files.size > 0
      args << '--files'
      args << @spec.extra_rdoc_files.join(",")
    end
    args << @spec.require_paths.map {|p| p + "/**/*.rb" }
    args = args.flatten.map do |arg| arg.to_s end

    old_pwd = Dir.pwd
    Dir.chdir(@spec.full_gem_path)
    YARD::CLI::Yardoc.run(*args)
  rescue Errno::EACCES => e
    dirname = File.dirname e.message.split("-")[1].strip
    raise Gem::FilePermissionError.new(dirname)
  rescue RuntimeError => ex
    alert_error "While generating documentation for #{@spec.full_name}"
    ui.errs.puts "... MESSAGE:   #{ex}"
    ui.errs.puts "... YARDDOC args: #{args.join(' ')}"
    ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
    Gem.configuration.backtrace
    ui.errs.puts "(continuing with the rest of the installation)"
  ensure
    Dir.chdir(old_pwd)
  end