diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb index 5bc0c5849a..d6a56adf97 100644 --- a/lib/rdoc/generator/markup.rb +++ b/lib/rdoc/generator/markup.rb @@ -83,6 +83,23 @@ class RDoc::CodeObject end +class RDoc::AnyMethod + + ## + # Creates an HTML link to the superclass method called by this method. + + def superclass_method_link + target = superclass_method + return unless target + + html_formatter = formatter + name = target.full_name + + html_formatter.link name, html_formatter.convert_string(name) + end + +end + class RDoc::MethodAttr ## diff --git a/lib/rdoc/generator/template/aliki/class.rhtml b/lib/rdoc/generator/template/aliki/class.rhtml index 6cb99ee214..cfef74d1a6 100644 --- a/lib/rdoc/generator/template/aliki/class.rhtml +++ b/lib/rdoc/generator/template/aliki/class.rhtml @@ -185,10 +185,7 @@ <%- if method.calls_super %>
Outer#foo'
+ assert_equal expected, method.superclass_method_link
+
+ assert_nil RDoc::AnyMethod.new('bar').superclass_method_link
+ end
+
+ def test_superclass_method_link_escapes_name
+ method = method_calling_super '<<'
+
+ link = method.superclass_method_link
+
+ expected = 'Outer#<<'
+ assert_equal expected, link
+ refute_match %r{Outer#<<}, link
+ end
+
attr_reader :path
def find_symbol(name)
@symbols[name]
end
+ def method_calling_super(name)
+ top_level = @store.add_file 'superclass_method_link.rb'
+ parent_method = RDoc::AnyMethod.new name
+
+ method = RDoc::AnyMethod.new name
+ method.calls_super = true
+
+ parent = top_level.add_class RDoc::NormalClass, 'Outer'
+ parent.add_method parent_method
+
+ child = top_level.add_class RDoc::NormalClass, 'Inner', parent.full_name
+ child.add_method method
+
+ method
+ end
+
end