File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,24 @@ def other
3030 node . remove_attribute 'id'
3131 end
3232
33- # Convert "click to toggle source" into a link
33+ # (RDoc prior to Ruby 3.4) Convert "click to toggle source" into a link
3434 css ( '.method-click-advice' ) . each do |node |
3535 node . name = 'a'
3636 node . content = 'Show source'
3737 end
3838
39+ # (RDoc for Ruby 3.4+) Add a "Show source" link
40+ css ( '.method-source-toggle' ) . each do |node |
41+ link_node = Nokogiri ::XML ::Node . new ( 'a' , doc . document )
42+ link_node . content = 'Show source'
43+ link_node [ 'class' ] = 'method-click-advice'
44+
45+ node . parent . parent . at_css ( '.method-heading' ) . add_child ( link_node )
46+ end
47+
48+ # (RDoc for Ruby 3.4+) Remove the additional "Source" toggle from the page
49+ css ( '.method-controls' ) . remove
50+
3951 # Add class to differentiate Ruby code from C code
4052 css ( '.method-source-code' ) . each do |node |
4153 node . parent . prepend_child ( node )
You can’t perform that action at this time.
0 commit comments