module RDoc

def self.home

def self.home
  rdoc_dir = begin
              File.expand_path('~/.rdoc')
            rescue ArgumentError
            end
  if File.directory?(rdoc_dir)
    rdoc_dir
  else
    require 'fileutils'
    begin
      # XDG
      xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
      unless File.exist?(xdg_data_home)
        FileUtils.mkdir_p xdg_data_home
      end
      File.join xdg_data_home, "rdoc"
    rescue Errno::EACCES
    end
  end
end

def self.load_yaml

def self.load_yaml
  begin
    gem 'psych'
  rescue NameError => e # --disable-gems
    raise unless e.name == :gem
  rescue Gem::LoadError
  end
  begin
    require 'psych'
  rescue ::LoadError
  ensure
    require 'yaml'
  end
end