diff options
author | Stan Lo <[email protected]> | 2024-08-03 11:29:40 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-08-05 08:27:45 +0800 |
commit | cbc40bb130fb52f1990ce1fd41e834a5f3fdbcdd (patch) | |
tree | 56845ee9fb311d5f7fb952c0392eecac93759e5f /lib | |
parent | 7d5cb4573d39e5c62058314dcfc73895b4e6dffd (diff) |
Sync rdoc
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11308
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rdoc/generator/template/darkfish/_head.rhtml | 1 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml | 3 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/class.rhtml | 4 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/css/rdoc.css | 75 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/index.rhtml | 4 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/js/darkfish.js | 17 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/page.rhtml | 5 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml | 5 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/servlet_root.rhtml | 4 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/table_of_contents.rhtml | 9 | ||||
-rw-r--r-- | lib/rdoc/parser/ruby.rb | 3 | ||||
-rw-r--r-- | lib/rdoc/rd/block_parser.rb | 8 | ||||
-rw-r--r-- | lib/rdoc/rd/inline_parser.rb | 8 | ||||
-rw-r--r-- | lib/rdoc/rdoc.gemspec | 3 |
14 files changed, 114 insertions, 35 deletions
diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml index d5aed3e9ef..69649ad3b5 100644 --- a/lib/rdoc/generator/template/darkfish/_head.rhtml +++ b/lib/rdoc/generator/template/darkfish/_head.rhtml @@ -1,4 +1,5 @@ <meta charset="<%= @options.charset %>"> +<meta name="viewport" content="width=device-width, initial-scale=1" /> <title><%= h @title %></title> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml new file mode 100644 index 0000000000..b51448a8f7 --- /dev/null +++ b/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml @@ -0,0 +1,3 @@ +<button id="navigation-toggle" class="navigation-toggle" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation"> + <span aria-hidden>☰</span> +</button> diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml index d6510336df..915b2f9c9f 100644 --- a/lib/rdoc/generator/template/darkfish/class.rhtml +++ b/lib/rdoc/generator/template/darkfish/class.rhtml @@ -1,5 +1,7 @@ <body id="top" role="document" class="<%= klass.type %>"> -<nav role="navigation"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> <div id="project-navigation"> <%= render '_sidebar_navigation.rhtml' %> <%= render '_sidebar_search.rhtml' %> diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 2cc55e03b1..00045abb58 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -19,12 +19,12 @@ body { font-weight: 300; /* Layout */ - display: grid; - grid-template-columns: auto 1fr; + display: flex; + flex-wrap: wrap; } body > :last-child { - grid-column: 1 / 3; + width: 100%; } h1 span, @@ -203,24 +203,38 @@ nav { font-family: Helvetica, sans-serif; font-size: 14px; border-right: 1px solid #ccc; - position: sticky; + position: fixed; top: 0; overflow: auto; + z-index: 10; /* Layout */ - width: 260px; /* fallback */ - width: max(50px, 20vw); - min-width: 50px; - max-width: 80vw; - height: calc(100vh - 100px); /* reduce the footer height */ - resize: horizontal; + width: 300px; + min-height: 100vh; + background: white; +} + +@media (min-width: 1024px) { + nav { + min-height: unset; + height: calc(100vh - 100px); /* reduce the footer height */ + } } main { display: block; - margin: 1em; + margin: 3em 1em 1em; min-width: 340px; font-size: 16px; + width: 100%; + max-width: 64em; +} + +@media (min-width: 1024px) { + main { + margin-left: auto; + margin-right: auto; + } } main h1, @@ -232,8 +246,10 @@ main h6 { font-family: Helvetica, sans-serif; } -.table-of-contents main { - margin-left: 2em; +@media (min-width: 1024px) { + .table-of-contents main { + margin-left: 20em; + } } #validator-badges { @@ -280,6 +296,38 @@ nav p { list-style: none; } +.navigation-toggle { + position: fixed; + left: 4px; + z-index: 100; + + background: transparent; + border: none; + cursor: pointer; + padding: 4px; + font-size: 24px; +} +.navigation-toggle[aria-expanded="true"] { + left: 260px; +} + +/* Adds a suble gradient to help the toggle stand out from the background */ +.navigation-toggle::before { + content: ""; + background: linear-gradient(180deg, rgba(250,250,250,1) 40%, rgba(250,250,250,0.8) 70%, rgba(250,250,250,0) 100%); + display: block; + z-index: -1; + pointer-events: none; + position: fixed; + top: 0; + height: 50px; + width: 100vw; +} + +.navigation-toggle[aria-expanded="true"]::before { + height: 0; +} + #project-navigation .nav-section { margin: 0; border-top: 0; @@ -684,4 +732,3 @@ pre { } /* @end */ - diff --git a/lib/rdoc/generator/template/darkfish/index.rhtml b/lib/rdoc/generator/template/darkfish/index.rhtml index 423e225b68..b3eede6c00 100644 --- a/lib/rdoc/generator/template/darkfish/index.rhtml +++ b/lib/rdoc/generator/template/darkfish/index.rhtml @@ -1,5 +1,7 @@ <body id="top" role="document" class="file"> -<nav role="navigation"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> <div id="project-navigation"> <%= render '_sidebar_navigation.rhtml' %> diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js index 19a85c54e1..bea0a5f1cb 100644 --- a/lib/rdoc/generator/template/darkfish/js/darkfish.js +++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js @@ -90,8 +90,25 @@ function hookFocus() { }); } +function hookSidebar() { + var navigation = document.querySelector('#navigation'); + var navigationToggle = document.querySelector('#navigation-toggle'); + + navigationToggle.addEventListener('click', function() { + navigation.hidden = !navigation.hidden; + navigationToggle.ariaExpanded = navigationToggle.ariaExpanded !== 'true'; + }); + + var isSmallViewport = window.matchMedia("(max-width: 1024px)").matches; + if (isSmallViewport) { + navigation.hidden = true; + navigationToggle.ariaExpanded = false; + } +} + document.addEventListener('DOMContentLoaded', function() { hookSourceViews(); hookSearch(); hookFocus(); + hookSidebar(); }); diff --git a/lib/rdoc/generator/template/darkfish/page.rhtml b/lib/rdoc/generator/template/darkfish/page.rhtml index 4a6b006bb3..90b9e4ee3b 100644 --- a/lib/rdoc/generator/template/darkfish/page.rhtml +++ b/lib/rdoc/generator/template/darkfish/page.rhtml @@ -1,5 +1,7 @@ <body id="top" role="document" class="file"> -<nav role="navigation"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> <div id="project-navigation"> <%= render '_sidebar_navigation.rhtml' %> <%= render '_sidebar_search.rhtml' %> @@ -15,4 +17,3 @@ <main role="main" aria-label="Page <%=h file.full_name%>"> <%= file.description %> </main> - diff --git a/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml b/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml index f0841572c3..b30e64eec5 100644 --- a/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +++ b/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml @@ -1,5 +1,7 @@ <body role="document"> -<nav role="navigation"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> <%= render '_sidebar_navigation.rhtml' %> <%= render '_sidebar_search.rhtml' %> @@ -15,4 +17,3 @@ <p><%= message %> </main> - diff --git a/lib/rdoc/generator/template/darkfish/servlet_root.rhtml b/lib/rdoc/generator/template/darkfish/servlet_root.rhtml index cab3092b17..859ce2930b 100644 --- a/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +++ b/lib/rdoc/generator/template/darkfish/servlet_root.rhtml @@ -1,5 +1,7 @@ <body role="document"> -<nav role="navigation"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> <div id="project-navigation"> <div id="home-section" class="nav-section"> <h2> diff --git a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml b/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml index 54a376c9e5..5869873775 100644 --- a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +++ b/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml @@ -1,4 +1,13 @@ <body id="top" class="table-of-contents"> +<%= render '_sidebar_toggle.rhtml' %> + +<nav id="navigation" role="navigation"> + <div id="project-navigation"> + <%= render '_sidebar_navigation.rhtml' %> + + <%= render '_sidebar_search.rhtml' %> + </div> +</nav> <main role="main"> <h1 class="class"><%= h @title %></h1> diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 1e3b401a5d..909b02d2af 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -11,6 +11,9 @@ if ENV['RDOC_USE_PRISM_PARSER'] require 'rdoc/parser/prism_ruby' RDoc::Parser.const_set(:Ruby, RDoc::Parser::PrismRuby) + puts "=========================================================================" + puts "RDoc is using the experimental Prism parser to generate the documentation" + puts "=========================================================================" return end diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb index 527147d91d..df4e072c20 100644 --- a/lib/rdoc/rd/block_parser.rb +++ b/lib/rdoc/rd/block_parser.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # DO NOT MODIFY!!!! -# This file is automatically generated by Racc 1.7.3 +# This file is automatically generated by Racc 1.8.0 # from Racc grammar file "block_parser.ry". # @@ -23,7 +23,7 @@ unless $".find {|p| p.end_with?('/racc/info.rb')} $".push "#{__dir__}/racc/info.rb" module Racc - VERSION = '1.7.3' + VERSION = '1.8.0' Version = VERSION Copyright = 'Copyright (c) 1999-2006 Minero Aoki' end @@ -31,10 +31,6 @@ end end -unless defined?(NotImplementedError) - NotImplementedError = NotImplementError # :nodoc: -end - module Racc class ParseError < StandardError; end end diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb index adacf64d5b..c7a679e259 100644 --- a/lib/rdoc/rd/inline_parser.rb +++ b/lib/rdoc/rd/inline_parser.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # DO NOT MODIFY!!!! -# This file is automatically generated by Racc 1.7.3 +# This file is automatically generated by Racc 1.8.0 # from Racc grammar file "inline_parser.ry". # @@ -23,7 +23,7 @@ unless $".find {|p| p.end_with?('/racc/info.rb')} $".push "#{__dir__}/racc/info.rb" module Racc - VERSION = '1.7.3' + VERSION = '1.8.0' Version = VERSION Copyright = 'Copyright (c) 1999-2006 Minero Aoki' end @@ -31,10 +31,6 @@ end end -unless defined?(NotImplementedError) - NotImplementedError = NotImplementError # :nodoc: -end - module Racc class ParseError < StandardError; end end diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec index e3ceea9e0a..93a281c8ae 100644 --- a/lib/rdoc/rdoc.gemspec +++ b/lib/rdoc/rdoc.gemspec @@ -230,9 +230,8 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat s.rdoc_options = ["--main", "README.rdoc"] s.extra_rdoc_files += s.files.grep(%r[\A[^\/]+\.(?:rdoc|md)\z]) - s.required_ruby_version = Gem::Requirement.new(">= 2.7.0") + s.required_ruby_version = Gem::Requirement.new(">= 2.6.0") s.required_rubygems_version = Gem::Requirement.new(">= 2.2") - s.add_dependency 'prism', '>= 0.30.0' s.add_dependency 'psych', '>= 4.0.0' end |