Skip to content

Commit a505294

Browse files
committed
Show method or class doc correctly
1 parent e97bbc4 commit a505294

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

lib/reline.rb

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,31 @@ def get_screen_size
222222
cursor_pos_to_render, result, pointer = context.pop(3)
223223
return nil if result.nil? or pointer.nil?
224224
name = result[pointer]
225+
225226
driver = RDoc::RI::Driver.new
226-
doc = RDoc::Markup::Document.new
227-
begin
228-
driver.add_method(doc, name)
229-
rescue RDoc::RI::Driver::NotFoundError => e
230-
return nil
227+
name = driver.expand_name name
228+
doc = nil
229+
used_for_class = false
230+
if not name =~ /#|\./
231+
found, klasses, includes, extends = driver.classes_and_includes_and_extends_for(name)
232+
if not found.empty?
233+
doc = driver.class_document name, found, klasses, includes, extends
234+
used_for_class = true
235+
end
231236
end
237+
unless used_for_class
238+
doc = RDoc::Markup::Document.new
239+
begin
240+
driver.add_method(doc, name)
241+
rescue RDoc::RI::Driver::NotFoundError
242+
doc = nil
243+
end
244+
end
245+
return nil if doc.nil?
232246
formatter = RDoc::Markup::ToBs.new
233247
formatter.width = 40
234248
str = doc.accept(formatter)
249+
235250
[Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil]
236251
}
237252

0 commit comments

Comments
 (0)