1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
drbrain 2006-06-26 20:44:14 +00:00
parent 74831046c7
commit 4e23c46ff4
11 changed files with 158 additions and 85 deletions

View file

@ -194,12 +194,15 @@ class DefaultDisplay
######################################################################
def page
setup_pager
return yield unless pager = setup_pager
begin
save_stdout = STDOUT.clone
STDOUT.reopen(pager)
yield
page_output
ensure
STDOUT.reopen(@save_stdout) if @save_stdout
STDOUT.reopen(save_stdout)
save_stdout.close
pager.close
end
end
@ -207,31 +210,11 @@ class DefaultDisplay
def setup_pager
unless @options.use_stdout
require 'tempfile'
@save_stdout = STDOUT.clone
STDOUT.reopen(Tempfile.new("ri_"))
end
end
######################################################################
def page_output
unless @options.use_stdout
path = STDOUT.path
STDOUT.reopen(@save_stdout)
@save_stdout = nil
paged = false
for pager in [ ENV['PAGER'], "less", "more <", 'pager' ].compact.uniq
if system("#{pager} #{path}")
paged = true
break
end
end
if !paged
@options.use_stdout = true
puts File.read(path)
for pager in [ ENV['PAGER'], "less", "more", 'pager' ].compact.uniq
return IO.popen(pager, "w") rescue nil
end
@options.use_stdout = true
nil
end
end
@ -255,12 +238,6 @@ class DefaultDisplay
end
######################################################################
def warn_no_database
puts "Before using ri, you need to generate documentation"
puts "using 'rdoc' with the --ri option"
end
######################################################################
def display_flow(flow)
if !flow || flow.empty?
@formatter.wrap("(no description...)")
@ -269,5 +246,10 @@ class DefaultDisplay
end
end
######################################################################
def warn_no_database
puts "Before using ri, you need to generate documentation"
puts "using 'rdoc' with the --ri option"
end
end # class RiDisplay