Unified · Split
| @@ -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 | end | 48 | end |
| 47 | 49 | ||
| 48 | # (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page | 50 | # (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page |