diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-26 18:10:30 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-26 18:10:30 +0000 |
commit | 90952d32f80e3733e9895f296aea067a828d0143 (patch) | |
tree | 5a9f6a60c7ea00f3fb92924d41f4119e6e00834a /lib/rdoc/ri/ri_paths.rb | |
parent | b73e6801e30e4bd8f57d2f54cb479deaf95b74fb (diff) |
Add --system, --site, --home and --gems to limit ri search path.
Allow --doc-dir to be specified mulitple times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/ri_paths.rb')
-rw-r--r-- | lib/rdoc/ri/ri_paths.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb index c5526201ea..4a67e44ba5 100644 --- a/lib/rdoc/ri/ri_paths.rb +++ b/lib/rdoc/ri/ri_paths.rb @@ -44,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 |