lib/yard/rubygems/doc_manager.rb in yard-0.9.5 vs lib/yard/rubygems/doc_manager.rb in yard-0.9.6
- old
+ new
@@ -1,9 +1,11 @@
+# frozen_string_literal: true
begin
require 'rubygems/user_interaction'
require 'rubygems/doc_manager'
rescue LoadError
+ nil # noop
end
class Gem::DocManager
def self.load_yardoc
require File.expand_path(File.join(File.dirname(__FILE__), *%w(.. .. yard)))
@@ -12,37 +14,37 @@
def run_yardoc(*args)
args << '--quiet'
args << '--backtrace' if Gem.configuration.backtrace
unless File.file?(File.join(@spec.full_gem_path, '.yardopts'))
args << @spec.require_paths
- if @spec.extra_rdoc_files.size > 0
+ unless @spec.extra_rdoc_files.empty?
args << '-'
args += @spec.extra_rdoc_files
end
end
- args = args.flatten.map {|arg| arg.to_s }
+ args = args.flatten.map(&:to_s)
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)
+ raise Gem::FilePermissionError, dirname
rescue => ex
alert_error "While generating documentation for #{@spec.full_name}"
ui.errs.puts "... MESSAGE: #{ex}"
ui.errs.puts "... YARDOC 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
- begin undef setup_rdoc; rescue NameError; end
+ begin undef setup_rdoc; rescue NameError; nil end
def setup_rdoc
- if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
- raise Gem::FilePermissionError.new(@doc_dir)
+ if File.exist?(@doc_dir) && !File.writable?(@doc_dir)
+ raise Gem::FilePermissionError, @doc_dir
end
FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
self.class.load_rdoc if @spec.has_rdoc?
@@ -69,11 +71,11 @@
end
begin
alias install_ri_yard_orig install_ri
alias install_ri install_ri_yard
- rescue NameError; end
+ rescue NameError; nil end
def install_rdoc_yard
if @spec.has_rdoc?
install_rdoc_yard_orig
elsif @spec.has_yardoc?
@@ -82,7 +84,7 @@
end
begin
alias install_rdoc_yard_orig install_rdoc
alias install_rdoc install_rdoc_yard
- rescue NameError; end
+ rescue NameError; nil end
end