Skip to content

Commit d26eef5

Browse files
committed
Display RBS type signatures in ri output
1 parent 2fecc01 commit d26eef5

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

lib/rdoc/ri/driver.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ def render_method(out, store, method, name) # :nodoc:
14151415
out << RDoc::Markup::Rule.new(1)
14161416

14171417
render_method_arguments out, method.arglists
1418+
render_method_type_signature out, method.type_signature
14181419
render_method_superclass out, method
14191420
if method.is_alias_for
14201421
al = method.is_alias_for
@@ -1452,6 +1453,14 @@ def render_method_comment(out, method, alias_for = nil)# :nodoc:
14521453
end
14531454
end
14541455

1456+
def render_method_type_signature(out, type_signature) # :nodoc:
1457+
return unless type_signature
1458+
1459+
sigs = type_signature.split("\n").map { |s| s + "\n" }
1460+
out << RDoc::Markup::Verbatim.new(*sigs)
1461+
out << RDoc::Markup::BlankLine.new
1462+
end
1463+
14551464
def render_method_superclass(out, method) # :nodoc:
14561465
return unless
14571466
method.respond_to?(:superclass_method) and method.superclass_method

test/rdoc/ri/driver_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,20 @@ def test_display_method
737737
assert_match %r%blah.6%, out
738738
end
739739

740+
def test_display_method_with_type_signature
741+
util_store
742+
743+
@blah.type_signature = '(Integer) -> String'
744+
@store1.save
745+
746+
out, = capture_output do
747+
@driver.display_method 'Foo::Bar#blah'
748+
end
749+
750+
assert_match %r%Foo::Bar#blah%, out
751+
assert_match %r%\(Integer\) -> String%, out
752+
end
753+
740754
def test_display_method_attribute
741755
util_store
742756

0 commit comments

Comments
 (0)