From 003126cc23538c41ec0d5803353441649cc59599 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:32:39 +0200 Subject: [PATCH 1/4] Only let browser search through source code until it's expanded (#1181) Something that's been bothering me is that while the source code is not visible by default, the browser still jump to it when searching. Adding the `visible` property prevents this. Test it out yourself: * `bundle exec rdoc` * open `_site/index.html` * Search for `NameError` Before, you will get a match from `load_yaml` source code, after you only get the match when that methods source code is expanded. --- lib/rdoc/generator/template/darkfish/css/rdoc.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 169a6331e9..7a42e62522 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -585,6 +585,9 @@ main header h3 { /* @group Method Details */ main .method-source-code { + /* While this is already invisible through the rule below, this will inform the browser to + not consider source code during text searching until it is actually expanded. */ + visibility: hidden; max-height: 0; overflow: auto; transition-duration: 200ms; @@ -594,6 +597,7 @@ main .method-source-code { } main .method-source-code.active-menu { + visibility: visible; max-height: 100vh; } From ed00d1cc10ff3267958e70630506f7acb5d43dbb Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 3 Oct 2024 13:06:51 +0100 Subject: [PATCH 2/4] Apply the same changes made in ruby/ruby#10924 (#1187) --- test/rdoc/test_rdoc_ri_driver.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 39e6e67759..3263e6173e 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -54,10 +54,10 @@ def test_self_dump RDoc::RI::Driver.dump @store1.cache_path end - assert_match %r%:class_methods%, out - assert_match %r%:modules%, out - assert_match %r%:instance_methods%, out - assert_match %r%:ancestors%, out + assert_match %r%:class_methods|class_methods:%, out + assert_match %r%:modules|modules:%, out + assert_match %r%:instance_methods|instance_methods:%, out + assert_match %r%:ancestors|ancestors:%, out end def test_add_also_in_empty From 7b68545094383bbb3bd1d55bde458d02bada4a0c Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Thu, 3 Oct 2024 21:27:39 +0900 Subject: [PATCH 3/4] Fix ToRdoc#accept_table (#1184) --- lib/rdoc/markup/to_rdoc.rb | 8 ++++---- test/rdoc/support/text_formatter_test_case.rb | 17 +++++++++++++++++ test/rdoc/test_rdoc_markup_to_ansi.rb | 11 +++++++++++ test/rdoc/test_rdoc_markup_to_bs.rb | 11 +++++++++++ test/rdoc/test_rdoc_markup_to_markdown.rb | 11 +++++++++++ test/rdoc/test_rdoc_markup_to_rdoc.rb | 11 +++++++++++ 6 files changed, 65 insertions(+), 4 deletions(-) diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb index 88234f5096..90763ccfdb 100644 --- a/lib/rdoc/markup/to_rdoc.rb +++ b/lib/rdoc/markup/to_rdoc.rb @@ -249,8 +249,8 @@ def accept_verbatim verbatim # Adds +table+ to the output def accept_table header, body, aligns - widths = header.zip(body) do |h, b| - [h.size, b.size].max + widths = header.zip(*body).map do |cols| + cols.map(&:size).max end aligns = aligns.map do |a| case a @@ -262,12 +262,12 @@ def accept_table header, body, aligns :rjust end end - @res << header.zip(widths, aligns) do |h, w, a| + @res << header.zip(widths, aligns).map do |h, w, a| h.__send__(a, w) end.join("|").rstrip << "\n" @res << widths.map {|w| "-" * w }.join("|") << "\n" body.each do |row| - @res << row.zip(widths, aligns) do |t, w, a| + @res << row.zip(widths, aligns).map do |t, w, a| t.__send__(a, w) end.join("|").rstrip << "\n" end diff --git a/test/rdoc/support/text_formatter_test_case.rb b/test/rdoc/support/text_formatter_test_case.rb index e359028a29..9b3d7ed626 100644 --- a/test/rdoc/support/text_formatter_test_case.rb +++ b/test/rdoc/support/text_formatter_test_case.rb @@ -99,6 +99,23 @@ def test_accept_paragraph_wrap accept_paragraph_wrap end + ## + # Test case that calls @to.accept_table + + def test_accept_table_align + header = ['AA', 'BB', 'CCCCC'] + body = [ + ['', 'bbb', 'c'], + ['aaaa', 'b', ''], + ['a', '', 'cc'] + ] + aligns = [nil, :left, :right] + @to.start_accepting + @to.accept_table header, body, aligns + + accept_table_align + end + ## # Test case that calls @to.attributes with an escaped # cross-reference. If this test doesn't pass something may be very diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb index 81372c64d2..893040cb44 100644 --- a/test/rdoc/test_rdoc_markup_to_ansi.rb +++ b/test/rdoc/test_rdoc_markup_to_ansi.rb @@ -348,6 +348,17 @@ def list_verbatim assert_equal expected, @to.end_accepting end + def accept_table_align + expected = "\e[0m" + <<-EXPECTED + AA |BB |CCCCC +----|---|----- + |bbb| c +aaaa|b | + a | | cc + EXPECTED + assert_equal expected, @to.end_accepting + end + # functional test def test_convert_list_note note_list = <<-NOTE_LIST diff --git a/test/rdoc/test_rdoc_markup_to_bs.rb b/test/rdoc/test_rdoc_markup_to_bs.rb index 7ebde481e6..93baa6b59f 100644 --- a/test/rdoc/test_rdoc_markup_to_bs.rb +++ b/test/rdoc/test_rdoc_markup_to_bs.rb @@ -349,4 +349,15 @@ def list_verbatim assert_equal expected, @to.end_accepting end + def accept_table_align + expected = <<-EXPECTED + AA |BB |CCCCC +----|---|----- + |bbb| c +aaaa|b | + a | | cc + EXPECTED + assert_equal expected, @to.end_accepting + end + end diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb index 92ed37bc50..1b24eb8ef0 100644 --- a/test/rdoc/test_rdoc_markup_to_markdown.rb +++ b/test/rdoc/test_rdoc_markup_to_markdown.rb @@ -346,6 +346,17 @@ def list_verbatim assert_equal expected, @to.end_accepting end + def accept_table_align + expected = <<-EXPECTED + AA |BB |CCCCC +----|---|----- + |bbb| c +aaaa|b | + a | | cc + EXPECTED + assert_equal expected, @to.end_accepting + end + def test_convert_RDOCLINK result = @to.convert 'rdoc-garbage:C' diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb index 50f4b6dc8b..c6f1aeae10 100644 --- a/test/rdoc/test_rdoc_markup_to_rdoc.rb +++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb @@ -346,6 +346,17 @@ def list_verbatim assert_equal expected, @to.end_accepting end + def accept_table_align + expected = <<-EXPECTED + AA |BB |CCCCC +----|---|----- + |bbb| c +aaaa|b | + a | | cc + EXPECTED + assert_equal expected, @to.end_accepting + end + # functional test def test_convert_list_note note_list = <<-NOTE_LIST From b53f0cb2edd470ed9d3eb6800ead58c38d43719f Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 7 Oct 2024 07:25:55 -0400 Subject: [PATCH 4/4] Use normal `font-weight` for links (#1188) --- lib/rdoc/generator/template/darkfish/css/rdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 7a42e62522..772a06b85b 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -92,7 +92,6 @@ h6:target { color: var(--link-color); text-decoration: none; transition: color 0.3s ease; - font-weight: 600; /* Make links bolder */ } :link:hover,