diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-26 20:44:14 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-26 20:44:14 +0000 |
commit | 4e23c46ff4c2b6fb8c16a50b7123acb753f7b7d6 (patch) | |
tree | 03e7986b60a2ef8aca427d12f0288e8b09339f55 /lib/rdoc/ri/ri_paths.rb | |
parent | 74831046c7240243c57efec65c11e2e71a9287f4 (diff) |
Merge from HEAD.
Add --system, --site, --home, --gems to ri.
Allow --doc-dir to be specified multiple times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/ri_paths.rb')
-rw-r--r-- | lib/rdoc/ri/ri_paths.rb | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb index 07d900238f..32363bf70a 100644 --- a/lib/rdoc/ri/ri_paths.rb +++ b/lib/rdoc/ri/ri_paths.rb @@ -29,13 +29,7 @@ module RI version = Config::CONFIG['ruby_version'] base = File.join(Config::CONFIG['datadir'], "ri", version) - - if ENV["DESTDIR"] - SYSDIR = File.join(ENV["DESTDIR"], base, "system") - else - SYSDIR = File.join(base, "system") - end - + SYSDIR = File.join(base, "system") SITEDIR = File.join(base, "site") homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] @@ -50,8 +44,37 @@ module RI begin require 'rubygems' - Dir["#{Gem.path}/doc/*/ri"].each { |path| RI::Paths::PATH << path } + GEMDIRS = Dir["#{Gem.path}/doc/*/ri"] + GEMDIRS.each { |path| RI::Paths::PATH << path } rescue LoadError + GEMDIRS = nil + end + + # Returns the selected documentation directories as an Array, or PATH if no + # overriding directories were given. + + def self.path(use_system, use_site, use_home, use_gems, *extra_dirs) + path = raw_path(use_system, use_site, use_home, use_gems, *extra_dirs) + return path.select { |path| File.directory? path } end + + # Returns the selected documentation directories including nonexistent + # directories. Used to print out what paths were searched if no ri was + # found. + + def self.raw_path(use_system, use_site, use_home, use_gems, *extra_dirs) + return PATH unless use_system or use_site or use_home or use_gems or + not extra_dirs.empty? + + path = [] + path << extra_dirs unless extra_dirs.empty? + path << RI::Paths::SYSDIR if use_system + path << RI::Paths::SITEDIR if use_site + path << RI::Paths::HOMEDIR if use_home + path << RI::Paths::GEMDIRS if use_gems + + return path.flatten.compact + end + end end |