From f058f2d8451abb25c149ab5fca31ffa497d13121 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 1 Jul 2010 02:05:35 +0000 Subject: merges r28455 and r28460 from trunk into ruby_1_9_2. -- * lib/rdoc/ri/driver.rb (RDoc::RI::Driver#formatter): should use bs format when stdout is piped. [ruby-core:30734] -- * test/rdoc/test_rdoc_ri_driver.rb (TestRDocRIDriver#test_formatter): fix a test accordingly to r28455. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ lib/rdoc/ri/driver.rb | 6 +++--- test/rdoc/test_rdoc_ri_driver.rb | 9 ++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85f7dd4f47..9dc374fea7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jun 28 22:14:22 2010 Yusuke Endoh + + * test/rdoc/test_rdoc_ri_driver.rb (TestRDocRIDriver#test_formatter): + fix a test accordingly to r28455. + +Mon Jun 28 05:32:51 2010 Yusuke Endoh + + * lib/rdoc/ri/driver.rb (RDoc::RI::Driver#formatter): should use bs + format when stdout is piped. [ruby-core:30734] + Mon Jun 28 03:12:03 2010 Yusuke Endoh * bootstraptest/test_class.rb: add a test for [ruby-core:30843]. diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb index b5523355d5..90fbc7c7a2 100644 --- a/lib/rdoc/ri/driver.rb +++ b/lib/rdoc/ri/driver.rb @@ -546,7 +546,7 @@ Options may also be set in the 'RI' environment variable. def display document page do |io| - text = document.accept formatter + text = document.accept formatter(io) io.write text end @@ -795,10 +795,10 @@ Options may also be set in the 'RI' environment variable. # Creates a new RDoc::Markup::Formatter. If a formatter is given with -f, # use it. If we're outputting to a pager, use bs, otherwise ansi. - def formatter + def formatter(io) if @formatter_klass then @formatter_klass.new - elsif paging? then + elsif paging? or !io.tty? then RDoc::Markup::ToBs.new else RDoc::Markup::ToAnsi.new diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 51f2576cb4..8d64916088 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -498,15 +498,18 @@ Foo::Bar#bother def test_formatter driver = RDoc::RI::Driver.new - assert_instance_of @RM::ToAnsi, driver.formatter + io = Object.new + def io.tty?; true; end + + assert_instance_of @RM::ToAnsi, driver.formatter(io) driver.instance_variable_set :@paging, true - assert_instance_of @RM::ToBs, driver.formatter + assert_instance_of @RM::ToBs, driver.formatter(io) driver.instance_variable_set :@formatter_klass, @RM::ToHtml - assert_instance_of @RM::ToHtml, driver.formatter + assert_instance_of @RM::ToHtml, driver.formatter(io) end def test_method_type -- cgit v1.2.3