History

Don't add "show source" button when source isn't present

Dan Arnfield committed 8 months ago

Commit 5f465681 parent be507901 file · +3 −1Browse files

Unified · Split

lib/docs/filters/rdoc/clean_html.rb+3−1
@@ -42,7 +42,9 @@ module Docs · 41 unmodified lines
42 link_node.content = 'Show source'42 link_node.content = 'Show source'
43 link_node['class'] = 'method-click-advice'43 link_node['class'] = 'method-click-advice'
44 44
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')
46 end48 end
47 49
48 # (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page50 # (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page