Skip to content

Commit 5f46568

Browse files
committed
Don't add "show source" button when source isn't present
1 parent be50790 commit 5f46568

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/docs/filters/rdoc/clean_html.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def other
4242
link_node.content = 'Show source'
4343
link_node['class'] = 'method-click-advice'
4444

45-
node.parent.parent.at_css('.method-heading').add_child(link_node)
45+
# Only add "Show source" if source is present
46+
method_root = node.ancestors('.method-detail').first
47+
method_root.at_css('.method-heading').add_child(link_node) if method_root.at_css('.method-source-code')
4648
end
4749

4850
# (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page

0 commit comments

Comments
 (0)