Skip to content

Fix --width option of ri #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/rdoc/ri/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def initialize initial_options = {}
@server = options[:server]
@use_stdout = options[:use_stdout]
@show_all = options[:show_all]
@width = options[:width]

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

def display document
page do |io|
text = document.accept formatter(io)
f = formatter(io)
f.width = @width if @width and f.respond_to?(:width)
text = document.accept f

io.write text
end
Expand Down
16 changes: 16 additions & 0 deletions test/test_rdoc_ri_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ def test_add_method_list
assert_equal expected, out
end

def test_output_width
@options[:width] = 10
driver = RDoc::RI::Driver.new @options

doc = @RM::Document.new
doc << @RM::IndentedParagraph.new(0, 'new, parse, foo, bar, baz')

out, = capture_io do
driver.display doc
end

expected = "new, parse, foo,\nbar, baz\n"

assert_equal expected, out
end

def test_add_method_list_interative
@options[:interactive] = true
driver = RDoc::RI::Driver.new @options
Expand Down