Skip to content

Commit 52cd4e6

Browse files
authored
Merge pull request #581 from aycabta/fix-width-option-of-ri
Fix --width option of ri
2 parents 49289ce + 9f945eb commit 52cd4e6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/rdoc/ri/driver.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def initialize initial_options = {}
425425
@server = options[:server]
426426
@use_stdout = options[:use_stdout]
427427
@show_all = options[:show_all]
428+
@width = options[:width]
428429

429430
# pager process for jruby
430431
@jruby_pager_process = nil
@@ -795,7 +796,9 @@ def complete_method name, klass, selector, completions # :nodoc:
795796

796797
def display document
797798
page do |io|
798-
text = document.accept formatter(io)
799+
f = formatter(io)
800+
f.width = @width if @width and f.respond_to?(:width)
801+
text = document.accept f
799802

800803
io.write text
801804
end

test/test_rdoc_ri_driver.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,22 @@ def test_add_method_list
348348
assert_equal expected, out
349349
end
350350

351+
def test_output_width
352+
@options[:width] = 10
353+
driver = RDoc::RI::Driver.new @options
354+
355+
doc = @RM::Document.new
356+
doc << @RM::IndentedParagraph.new(0, 'new, parse, foo, bar, baz')
357+
358+
out, = capture_io do
359+
driver.display doc
360+
end
361+
362+
expected = "new, parse, foo,\nbar, baz\n"
363+
364+
assert_equal expected, out
365+
end
366+
351367
def test_add_method_list_interative
352368
@options[:interactive] = true
353369
driver = RDoc::RI::Driver.new @options

0 commit comments

Comments
 (0)