diff options
author | Stan Lo <[email protected]> | 2024-10-10 17:45:36 +0800 |
---|---|---|
committer | git <[email protected]> | 2024-10-10 09:45:41 +0000 |
commit | c5f0fe12859cd194f4df9ba2072f70228da2fcd5 (patch) | |
tree | 51b89cb69141ec7b1972e87b6cfc2a10826c24a2 /lib/rdoc/generator/template/darkfish/js/darkfish.js | |
parent | 2cf4aa0801468a2b55cfd25e93e762af47c1b141 (diff) |
[ruby/rdoc] Improve method source toggling
(https://github.com/ruby/rdoc/pull/1176)
* Move method source block to the top
Currently, if a method description is long (e.g. `Array.new`), users need
to click the method toggle button next to the method title, and then scroll
down to the source code expanded below the description.
This commit changes the behavior so that the source code is expanded
immediately below the method title.
* Update method toggle's interface
1. Display the method toggle button by default instead of displaying on hover
2. Only toggle the source code when clicking the method toggle button, not
when clicking the entire method title section. This will allow us to display
an anchor link next to the method title
3. Simplify the toggle source button's appearance
* Use details tag for method toggling
* Rename method-click-advice to method-source-toggle
* Improve method controls' display on mobile
By moving the method controls out of the method header, we can display
them to the right of the method name on desktop, and below the method name
on mobile.
* Add "Example" label to example code blocks
The label should help users distinguish example code blocks from other
code blocks, such as method source code.
It's only applied to Ruby code examples.
* Revert "Add "Example" label to example code blocks"
This reverts commit https://github.com/ruby/rdoc/commit/69fc9ce6a379.
* Give source code blocks a different background color
* Change targeted method's highlighting color to work better with the new method source
https://github.com/ruby/rdoc/commit/e608a84af3
Diffstat (limited to 'lib/rdoc/generator/template/darkfish/js/darkfish.js')
-rw-r--r-- | lib/rdoc/generator/template/darkfish/js/darkfish.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js index bea0a5f1cb..aeb8526344 100644 --- a/lib/rdoc/generator/template/darkfish/js/darkfish.js +++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js @@ -34,7 +34,7 @@ function showSource( e ) { }; function hookSourceViews() { - document.querySelectorAll('.method-heading').forEach(function (codeObject) { + document.querySelectorAll('.method-source-toggle').forEach(function (codeObject) { codeObject.addEventListener('click', showSource); }); }; |