From 2b393e97617ae1192733688fd74a64412799787c Mon Sep 17 00:00:00 2001 From: mterada1228 <49284339+mterada1228@users.noreply.github.com> Date: Fri, 6 Sep 2024 01:53:26 +0900 Subject: [PATCH 01/18] `rake install` command is failed (#1170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * `rake install` command is failed \### Problems Several file paths were changed by following PR. - https://github.com/ruby/rdoc/commit/4211292ffe80dd4737db2450d72df404a9d55051 - https://github.com/ruby/rdoc/commit/d7bca12c13b8b3f1632d698d497e67d4ea8a88bc Because rdoc.gemspec doesn't take in this changes, the `rake install` command is permanently failed. \### Test \#### before ```console ❯ bundle exec rake install Running RuboCop... Inspecting 4 files .... 4 files inspected, no offenses detected Tip: Based on detected gems, the following RuboCop extension libraries might be helpful: * rubocop-rake (https://rubygems.org/gems/rubocop-rake) You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options): AllCops: SuggestExtensions: false rake aborted! Running `gem build -V /Users/mterada/dev/redDataTools/remove_dependency/rdoc/rdoc.gemspec` failed with the following output: WARNING: See https://guides.rubygems.org/specification-reference/ for help ERROR: While executing gem ... (Gem::InvalidSpecificationException) ["RI.rdoc", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/class_module.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/context/section.rb", "lib/rdoc/extend.rb", "lib/rdoc/ghost_method.rb", "lib/rdoc/include.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb", "lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/require.rb", "lib/rdoc/single_class.rb", "lib/rdoc/top_level.rb"] are not files /Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `load' /Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `
' Tasks: TOP => install => build (See full trace by running task with --trace) ``` \#### after ```console ❯ bundle exec rake install Running RuboCop... Inspecting 4 files .... 4 files inspected, no offenses detected Tip: Based on detected gems, the following RuboCop extension libraries might be helpful: * rubocop-rake (https://rubygems.org/gems/rubocop-rake) You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options): AllCops: SuggestExtensions: false rdoc 6.7.0 built to pkg/rdoc-6.7.0.gem. rdoc (6.7.0) installed. ``` * Add a `bundle exec rake install` step to github workflow * make intentionally CI failed * Revert "make intentionally CI failed" This reverts commit 9fc5dd9423a024594ad26d86a8a6af829e7017f8. --- .github/workflows/test.yml | 2 ++ rdoc.gemspec | 40 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0d8e86c9e..ecfbbd9b47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,6 +53,8 @@ jobs: RDOC_USE_PRISM_PARSER: true - if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }} run: bundle exec rake rdoc + - if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }} + run: bundle exec rake install lint: runs-on: ubuntu-latest steps: diff --git a/rdoc.gemspec b/rdoc.gemspec index 93a281c8ae..26f9ba1a87 100644 --- a/rdoc.gemspec +++ b/rdoc.gemspec @@ -46,27 +46,27 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "LEGAL.rdoc", "LICENSE.rdoc", "README.rdoc", - "RI.rdoc", + "RI.md", "TODO.rdoc", "exe/rdoc", "exe/ri", "lib/rdoc.rb", - "lib/rdoc/alias.rb", - "lib/rdoc/anon_class.rb", - "lib/rdoc/any_method.rb", - "lib/rdoc/attr.rb", - "lib/rdoc/class_module.rb", + "lib/rdoc/code_object/alias.rb", + "lib/rdoc/code_object/anon_class.rb", + "lib/rdoc/code_object/any_method.rb", + "lib/rdoc/code_object/attr.rb", + "lib/rdoc/code_object/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/comment.rb", - "lib/rdoc/constant.rb", - "lib/rdoc/context.rb", - "lib/rdoc/context/section.rb", + "lib/rdoc/code_object/constant.rb", + "lib/rdoc/code_object/context.rb", + "lib/rdoc/code_object/context/section.rb", "lib/rdoc/cross_reference.rb", "lib/rdoc/encoding.rb", "lib/rdoc/erb_partial.rb", "lib/rdoc/erbio.rb", - "lib/rdoc/extend.rb", + "lib/rdoc/code_object/extend.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/json_index.rb", @@ -136,11 +136,11 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "lib/rdoc/generator/template/json_index/.document", "lib/rdoc/generator/template/json_index/js/navigation.js", "lib/rdoc/generator/template/json_index/js/searcher.js", - "lib/rdoc/ghost_method.rb", + "lib/rdoc/code_object/ghost_method.rb", "lib/rdoc/i18n.rb", "lib/rdoc/i18n/locale.rb", "lib/rdoc/i18n/text.rb", - "lib/rdoc/include.rb", + "lib/rdoc/code_object/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markdown.kpeg", "lib/rdoc/markdown/entities.rb", @@ -180,11 +180,11 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_tt_only.rb", "lib/rdoc/markup/verbatim.rb", - "lib/rdoc/meta_method.rb", - "lib/rdoc/method_attr.rb", - "lib/rdoc/mixin.rb", - "lib/rdoc/normal_class.rb", - "lib/rdoc/normal_module.rb", + "lib/rdoc/code_object/meta_method.rb", + "lib/rdoc/code_object/method_attr.rb", + "lib/rdoc/code_object/mixin.rb", + "lib/rdoc/code_object/normal_class.rb", + "lib/rdoc/code_object/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", @@ -201,7 +201,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "lib/rdoc/rd/inline.rb", "lib/rdoc/rd/inline_parser.ry", "lib/rdoc/rdoc.rb", - "lib/rdoc/require.rb", + "lib/rdoc/code_object/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", @@ -210,7 +210,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "lib/rdoc/ri/task.rb", "lib/rdoc/rubygems_hook.rb", "lib/rdoc/servlet.rb", - "lib/rdoc/single_class.rb", + "lib/rdoc/code_object/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/stats/normal.rb", "lib/rdoc/stats/quiet.rb", @@ -220,7 +220,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat "lib/rdoc/text.rb", "lib/rdoc/token_stream.rb", "lib/rdoc/tom_doc.rb", - "lib/rdoc/top_level.rb", + "lib/rdoc/code_object/top_level.rb", "lib/rdoc/version.rb", "man/ri.1", ] From 6a9cad4c5488bc56cd06addc97e0102082e65aeb Mon Sep 17 00:00:00 2001 From: Mads Ohm Larsen Date: Fri, 6 Sep 2024 23:26:13 +0200 Subject: [PATCH 02/18] Add more space after magnifying glass (#1173) --- lib/rdoc/generator/template/darkfish/css/rdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 0032ac172a..7171fd7895 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -307,7 +307,7 @@ main h6 { #search-field { width: 100%; - padding: 0.5em 1em 0.5em 2em; + padding: 0.5em 1em 0.5em 2.5em; border: 1px solid var(--border-color); border-radius: 20px; font-size: 14px; From 964a1982c8387881a61fc7855a3b999ffdc191b6 Mon Sep 17 00:00:00 2001 From: Mads Ohm Larsen Date: Sun, 8 Sep 2024 14:17:33 +0200 Subject: [PATCH 03/18] Use pointer cursor for navigation toggle (#1175) --- lib/rdoc/generator/template/darkfish/css/rdoc.css | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 7171fd7895..169a6331e9 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -223,6 +223,7 @@ nav a:hover { position: fixed; top: 10px; left: 20px; + cursor: pointer; } #navigation-toggle[aria-expanded="true"] { From b7d580afabf530b453911276e08e7aca0568c76d Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 27 Sep 2024 09:58:29 -0400 Subject: [PATCH 04/18] Add home page link to output message (#1165) The link is clickable in the terminal and opens the home page in the browser --- lib/rdoc/rdoc.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 47108ceee3..88ae55b409 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -520,6 +520,7 @@ def generate Dir.chdir @options.op_dir do unless @options.quiet then $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." + $stderr.puts "\nYou can visit the home page at: \e]8;;file://#{Dir.pwd}/index.html\e\\file://#{Dir.pwd}/index.html\e]8;;\e\\" end @generator.generate 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 05/18] 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 06/18] 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 07/18] 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 08/18] 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, From ac5ddbdfbd5d6bcdd5ea80602242dd914f4e5c27 Mon Sep 17 00:00:00 2001 From: Antoine Marguerie Date: Mon, 7 Oct 2024 15:15:12 +0200 Subject: [PATCH 09/18] Improve RDoc pages heading levels order (#1185) * improve rdoc pages heading elements order * Undo change entry content * Escape RDoc title --- ExampleMarkdown.md | 2 + ExampleRDoc.rdoc | 2 + History.rdoc | 126 +++++++++++++++++++++++---------------------- LICENSE.rdoc | 2 + TODO.rdoc | 15 +++--- 5 files changed, 78 insertions(+), 69 deletions(-) diff --git a/ExampleMarkdown.md b/ExampleMarkdown.md index 2a883c5c84..fd4359f355 100644 --- a/ExampleMarkdown.md +++ b/ExampleMarkdown.md @@ -1,3 +1,5 @@ +# Example Markdown + This document contains example output to show RDoc styling. This file was created from a Markdown file. diff --git a/ExampleRDoc.rdoc b/ExampleRDoc.rdoc index 79c2432ae2..b5dd68c19c 100644 --- a/ExampleRDoc.rdoc +++ b/ExampleRDoc.rdoc @@ -1,3 +1,5 @@ += Example \RDoc + This document contains example output to show RDoc styling. This file was created from a RDoc Markup file. diff --git a/History.rdoc b/History.rdoc index d20211f031..deb8c77787 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,4 +1,6 @@ -=== 5.1.0 / 2017-02-24 += History + +== 5.1.0 / 2017-02-24 * Bug fixes * Fix an issue that rdoc fails when running on Windows with RUBYOPT=-U. @@ -8,7 +10,7 @@ * Parse ruby 2.1 def. PR #436 by Akira Matsuda. * Suppress warnings in eval. PR #440 by Nobuyoshi Nakada. -=== 5.0.0 / 2016-11-05 +== 5.0.0 / 2016-11-05 * Major enhancements * Cleanup deprecated code targeted Ruby 1.8 @@ -25,19 +27,19 @@ * Improve class name expansion/resolution in ri. PR #400 by NARUSE, Yui * Improve performance of document generation. PR #397 by Yusuke Endoh. -=== 4.3.0 / 2016-11-04 +== 4.3.0 / 2016-11-04 * Minor enhancements * Removed json dependency for Ruby 2.4.0 * End to support Ruby 1.8.x -=== 4.2.2 / 2016-02-09 +== 4.2.2 / 2016-02-09 * Bug fixes * Include lib/rdoc/generator/pot/* in built gem -=== 4.2.1 / 2015-12-22 +== 4.2.1 / 2015-12-22 * Bug fixes * Fixed infinite loop with CR #339 by @nobu @@ -47,7 +49,7 @@ * Fix for valid syntax `class C end` parsing #368 by @nobu -=== 4.2.0 / 2014-12-06 +== 4.2.0 / 2014-12-06 * Major enhancements * RDoc can now produce translation files for use with gettext. See @@ -116,12 +118,12 @@ #312 by Scott Thompson. * Fixed RegExp matching stack overflow on Ruby 1.8.7. Issue #327 by sshao. -=== 4.1.2 / 2014-09-05 +== 4.1.2 / 2014-09-05 * Bug fixes * Updated vendored jQuery to 1.6.4. Bug ruby/ruby#711 by @neuralme -=== 4.1.1 / 2014-01-09 +== 4.1.1 / 2014-01-09 * Bug fixes * Fixed reporting of undocumented method parameters when including when @@ -132,7 +134,7 @@ * Removed duplicated condition in superclass fixup. Pull request #282 by Benoit Daloze. -=== 4.1.0 / 2013-12-26 +== 4.1.0 / 2013-12-26 * Notable changes * Improved accessibility of HTML output. Accessibility review was provided @@ -222,7 +224,7 @@ * Regexp options are no longer stripped in HTML output. Bug #259 by Zachary Scott, Pull request #265 by Rein Henrichs -=== 4.0.1 / 2013-03-27 +== 4.0.1 / 2013-03-27 * Bug fixes * RDoc::Options parser should rescue from OptionParser::ParseError. @@ -252,7 +254,7 @@ * The C parser now de-duplicates call-seq if the same C function is used for multiple method names. Bug #203 by Pete Higgins -=== 4.0.0 / 2013-02-24 +== 4.0.0 / 2013-02-24 RDoc 4.0 includes several new features and several breaking changes. The changes should not affect users of `rdoc` or `ri`. @@ -380,7 +382,7 @@ Changes since RDoc 3.12.1: * RDoc now ignores methods defined on constants instead of creating a fake module. Bug #163 by Zachary Scott. * Fixed ChangeLog parsing for FFI gem. Bug #165 by Zachary Scott. - * RDoc now links \#=== methods. Bug #164 by Zachary Scott. + * RDoc now links \#== methods. Bug #164 by Zachary Scott. * Allow [] following argument names for TomDoc. Bug #167 by Ellis Berner. * Fixed the RDoc servlet for home and site directories. Bug #170 by Thomas Leitner. @@ -455,7 +457,7 @@ Changes since RDoc 4.0.0.rc.2: * Templates now use the correct encoding when generating pages. Issue #183 by Vít Ondruch -=== 4.0.0.rc.2 / 2013-02-05 +== 4.0.0.rc.2 / 2013-02-05 * Minor enhancements * Added current heading and page-top links to HTML headings. @@ -476,7 +478,7 @@ Changes since RDoc 4.0.0.rc.2: * RDoc now ignores methods defined on constants instead of creating a fake module. Bug #163 by Zachary Scott. * Fixed ChangeLog parsing for FFI gem. Bug #165 by Zachary Scott. - * RDoc now links \#=== methods. Bug #164 by Zachary Scott. + * RDoc now links \#== methods. Bug #164 by Zachary Scott. * Allow [] following argument names for TomDoc. Bug #167 by Ellis Berner. * Fixed the RDoc servlet for home and site directories. Bug #170 by Thomas Leitner. @@ -487,7 +489,7 @@ Changes since RDoc 4.0.0.rc.2: * Fixed deletion of attribute ri data when a class was loaded then saved. Issue #171 by Thomas Leitner. -=== 4.0.0.preview2.1 / 2012-12-14 +== 4.0.0.preview2.1 / 2012-12-14 * Minor enhancements * Added --page-dir option to give pretty names for a FAQ, guides, or other @@ -510,7 +512,7 @@ Changes since RDoc 4.0.0.rc.2: * Incremental ri builds of C files now work. C variable names from previous runs are now saved between runs. -=== 4.0.0.preview2 / 2012-12-01 +== 4.0.0.preview2 / 2012-12-01 * Breaking changes * The default output encoding for RDoc is now UTF-8. Previously RDoc used @@ -658,7 +660,7 @@ Changes since RDoc 4.0.0.rc.2: * Fixed class << ::Foo writing documentation to /Foo.html * Fixed class ::A referencing itself from inside its own namespace. -=== 3.12.2 / 2013-02-24 +== 3.12.2 / 2013-02-24 * Bug fixes * Fixed bug in syntax-highlighting that would corrupt regular expressions. @@ -672,7 +674,7 @@ Changes since RDoc 4.0.0.rc.2: end. When a HEREDOC is not followed by a line end RDoc is not currently smart enough to restore the source correctly. Bug #162 by Zachary Scott. -=== 3.12.1 / 2013-02-05 +== 3.12.1 / 2013-02-05 * Bug fixes * Fixed an XSS exploit in darkfish.js. This could lead to cookie disclosure @@ -680,7 +682,7 @@ Changes since RDoc 4.0.0.rc.2: details including a patch you can apply to generated RDoc documentation. * Ensured that rd parser files are generated before checking the manifest. -=== 3.12 / 2011-12-15 +== 3.12 / 2011-12-15 * Minor enhancements * Added DEVELOPERS document which contains an overview of how RDoc works and @@ -711,13 +713,13 @@ Changes since RDoc 4.0.0.rc.2: * In rdoc, backspace and ansi formatters, whitespace between label or note and the colon is now stripped. -=== 3.11 / 2011-10-17 +== 3.11 / 2011-10-17 * Bug fixes * Avoid parsing TAGS files included in gems. Issue #81 by Santiago Pastorino. -=== 3.10 / 2011-10-08 +== 3.10 / 2011-10-08 * Major enhancements * RDoc HTML output has been improved: @@ -822,19 +824,19 @@ Changes since RDoc 4.0.0.rc.2: parsed. Unless your project includes nonexistent modules this avoids worst-case behavior (O(n!)) of RDoc::Include#module. -=== 3.9.5 / 2013-02-05 +== 3.9.5 / 2013-02-05 * Bug fixes * Fixed an XSS exploit in darkfish.js. This could lead to cookie disclosure to third parties. See CVE-2013-0256.rdoc for full details including a patch you can apply to generated RDoc documentation. -=== 3.9.4 / 2011-08-26 +== 3.9.4 / 2011-08-26 * Bug fixes * Applied typo and grammar fixes from Luke Gruber. Ruby bug #5203 -=== 3.9.3 / 2011-08-23 +== 3.9.3 / 2011-08-23 * Bug fixes * Add US-ASCII magic comments to work with ruby -Ku. Issue #63 by @@ -844,14 +846,14 @@ Changes since RDoc 4.0.0.rc.2: * Markup defined by RDoc::Markup#add_special inside a is no longer converted. -=== 3.9.2 / 2011-08-11 +== 3.9.2 / 2011-08-11 * Bug fix * Loosened TIDYLINK regexp to allow any content in the link section like: {foo}[rdoc-ref:SomeClass] * In HTML output headings are capped at
again -=== 3.9.1 / 2011-07-31 +== 3.9.1 / 2011-07-31 * Bug fixes * Fix RDoc::Markup parser for a header followed by a non-text token. Issue @@ -859,7 +861,7 @@ Changes since RDoc 4.0.0.rc.2: * Fix RDoc::Markup::ToHtmlCrossref#gen_url for non-rdoc-ref links. * Fix bug report URL when rdoc crashes. -=== 3.9 / 2011-07-30 +== 3.9 / 2011-07-30 * Minor enhancements * RDoc::Parser::C now supports :doc: and :nodoc: for class comments @@ -879,7 +881,7 @@ Changes since RDoc 4.0.0.rc.2: * Remove tokenizer restriction on header lengths for verbatim sections. Issue #49 by trans -=== 3.8 / 2011-06-29 +== 3.8 / 2011-06-29 * Minor enhancements * RDoc::Parser::C can now discover methods on ENV and ARGF. @@ -888,7 +890,7 @@ Changes since RDoc 4.0.0.rc.2: * Updating Object in an ri data store with new data now removes methods, includes, constants and aliases. -=== 3.7 / 2011-06-27 +== 3.7 / 2011-06-27 * Minor enhancements * New directive :category: which allows methods to be grouped into sections @@ -933,7 +935,7 @@ Changes since RDoc 4.0.0.rc.2: * ri data generation for method aliases no longer duplicates the class in #full_name -=== 3.6.1 / 2011-05-15 +== 3.6.1 / 2011-05-15 * Bug fixes * Fix infinite loop created when re-encountering BasicObject. @@ -941,7 +943,7 @@ Changes since RDoc 4.0.0.rc.2: * rb_path2class() can now be used to discover the parent class in rb_define_class_under. -=== 3.6 / 2011-05-13 +== 3.6 / 2011-05-13 * Major Enhancements * Interactive ri is now the default when no names are given. @@ -966,7 +968,7 @@ Changes since RDoc 4.0.0.rc.2: * The doc directive now forces documentation even when the method is marked private or protected. -=== 3.5.3 / 2010-02-06 +== 3.5.3 / 2010-02-06 * Bug fixes * When including a file perform a lossy force-transcoding to the output @@ -978,7 +980,7 @@ Changes since RDoc 4.0.0.rc.2: Bug #4376. * When Darkfish fails the file being generated is now reported. -=== 3.5.2 / 2010-02-04 +== 3.5.2 / 2010-02-04 * Deprecations * RDoc::Context::Section#sequence is now deprecated. Use @@ -995,14 +997,14 @@ Changes since RDoc 4.0.0.rc.2: * Fixed post-install message for Ruby 1.9.2 users. * Set required ruby version to >= 1.8.7. -=== 3.5.1 / 2010-01-30 +== 3.5.1 / 2010-01-30 * Bug fixes * Fixed some typos. Pull request #13 by R.T. Lechow. * Ensure an RDoc::Stats is created in #parse_files. Fixes documentation for railties which has no files. Reported by Aaron Patterson -=== 3.5 / 2010-01-29 +== 3.5 / 2010-01-29 * Minor enhancements * RDoc::Parser::C looks for rb_scan_args and fills in RDoc::AnyMethod#params @@ -1025,7 +1027,7 @@ Changes since RDoc 4.0.0.rc.2: * Relaxed RDoc::Parser::Ruby#remove_private_comments to consume more dashes as older versions once did. Bug #7 by Claus Folke Brobak. -=== 3.4 / 2010-01-06 +== 3.4 / 2010-01-06 * Minor enhancements * RDoc::RDoc#document may now be called with an RDoc::Options instance. @@ -1033,7 +1035,7 @@ Changes since RDoc 4.0.0.rc.2: * Added skips to Encoding tests running on 1.8. * Fixed warnings -=== 3.3 / 2010-01-03 +== 3.3 / 2010-01-03 * Minor enhancements * The coverage report can now report undocumented method parameters @@ -1060,7 +1062,7 @@ Changes since RDoc 4.0.0.rc.2: parser. RubyForge bug #28370 by Erik Hollensbe. * ri no longer displays all methods in the inheritance chain. -=== 3.2 / 2010-12-29 +== 3.2 / 2010-12-29 * Minor enhancements * RDoc generator authors may now suppress updating the output dir (creating @@ -1070,7 +1072,7 @@ Changes since RDoc 4.0.0.rc.2: * RDoc's gitignore now ignores .DS_Store files. Pull Request #3 by Shane Becker. -=== 3.1 / 2010-12-28 +== 3.1 / 2010-12-28 RDoc has moved to github. Releases after 3.1 reference github unless otherwise noted. @@ -1108,12 +1110,12 @@ otherwise noted. * RDoc::Parser::Ruby now parses negative numbers correctly. RubyForge patch #28544 by Eito Katagiri. -=== 3.0.1 / 2010-12-19 +== 3.0.1 / 2010-12-19 * Bug fix * RDoc no longer has a Perl parser. -=== 3.0 / 2010-12-19 +== 3.0 / 2010-12-19 Special thanks to Thierry Lambert for massive improvements to RDoc. @@ -1208,7 +1210,7 @@ Special thanks to Thierry Lambert for massive improvements to RDoc. * Methods added to true, false and nil are now documented. * Remove warning for methods defined on globals. -=== 2.5.11 / 2010-08-20 +== 2.5.11 / 2010-08-20 * Minor Enhancements * Alias comments are now discovered by the C parser. Reported by Jeremy @@ -1216,7 +1218,7 @@ Special thanks to Thierry Lambert for massive improvements to RDoc. * Removed --all option which is unused in RDoc. Use the nodoc or stopdoc/startdoc directives to suppress documentation instead. -=== 2.5.10 / 2010-08-17 +== 2.5.10 / 2010-08-17 * Minor Enhancements * Support rb_singleton_class(). Reported by Jeremy Evans. @@ -1234,14 +1236,14 @@ Special thanks to Thierry Lambert for massive improvements to RDoc. Evans. * RDoc now understands singleton aliases. Reported by Jeremy Evans. -=== 2.5.9 / 2010-07-06 +== 2.5.9 / 2010-07-06 * Bug Fixes * Look up pager correctly. * Fixed handling of bullets in verbatim sections. Partial patch by Juha-Jarmo Heinonen. -=== 2.5.8 / 2010-04-27 +== 2.5.8 / 2010-04-27 *NOTE*: @@ -1266,7 +1268,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * ri no longer complains about nonexistent pagers. * Fixed failing test -=== 2.5.7 / 2010-04-22 +== 2.5.7 / 2010-04-22 * Minor Enhancements * Unrecognized RDoc directives can now be registered by a plugin for @@ -1277,7 +1279,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * rdoc -p no longer means --pipe if files are also given. * RDoc now knows about BasicObject by default. Ruby Bug #1318 by Ambrus Zsbán -=== 2.5.6 / 2010-04-22 +== 2.5.6 / 2010-04-22 * Minor Enhancements * Unrecognized RDoc directives are added as metadata to the object they get @@ -1293,7 +1295,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. options. * Fixed link size on Darkfish file pages -=== 2.5.5 / 2010-04-19 +== 2.5.5 / 2010-04-19 * 1 Minor Enhancement * Use #binread in RDoc::Markup::PreProcess. Patch from ruby trunk. @@ -1305,7 +1307,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * Fixed handling of ignored invalid options to continue after the invalid option. -=== 2.5.4 / 2010-04-18 +== 2.5.4 / 2010-04-18 * 2 Minor Enhancements * Methods will now be cross-referenced when preceded with ::. Ruby Bug @@ -1316,7 +1318,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * RDoc::Parser::Ruby now handles while begin a; b end # .... Ruby Bug #3160 by Yusuke Endoh. -=== 2.5.3 / 2010-04-10 +== 2.5.3 / 2010-04-10 * 1 Minor Enhancement * RDoc::Parser::Simple and the include directive remove coding: comment from @@ -1326,7 +1328,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. #3121 by Yusuke Endoh. * Compare times as Integers as created.rid doesn't store fractional times. -=== 2.5.2 / 2010-04-09 +== 2.5.2 / 2010-04-09 * 1 Minor Enhancement * Imported various changes by Nobu from ruby trunk. @@ -1334,7 +1336,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * RDoc parses files without extensions as text files again. * RDoc::Parser::Ruby parses %{ strings correctly again. -=== 2.5.1 / 2010-04-06 +== 2.5.1 / 2010-04-06 * 1 Minor Enhancement * RDoc::Parser::C now supports the include directive for classes and @@ -1348,7 +1350,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * RDoc::Task's rerdoc task no longer deletes the doc directory twice. * rdoc --force-update now works correctly. Patch by Nobu Nokada -=== 2.5 / 2010-03-31 +== 2.5 / 2010-03-31 * 9 Major Enhancements * Darkfish now has a "Home" button @@ -1404,13 +1406,13 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. Filed Selenium bug #27789. * Alias comments are no longer hidden. Reported by Adam Avilla. -=== 2.4.3 / 2009-04-01 +== 2.4.3 / 2009-04-01 * 2 Bug Fixes * Corrected patch for file links * Corrected display of file popup -=== 2.4.2 / 2009-03-25 +== 2.4.2 / 2009-03-25 * 2 Minor Enhancements * Added --pipe for turning RDoc on stdin into HTML @@ -1435,7 +1437,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * Added back --promiscuous which didn't do anything you cared about. Why did you enable it? Nobody looked at that page! Oh, it warns, too. -=== 2.4.1 / 2009-02-26 +== 2.4.1 / 2009-02-26 * 1 Minor Enhancements * Added :attr:, :attr_reader:, :attr_writer:, :attr_accessor: directives. @@ -1446,7 +1448,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * Restore --inline-source that warns * Fixed links to files in Darkfish output -=== 2.4.0 / 2009-02-24 +== 2.4.0 / 2009-02-24 * 9 Minor Enhancements * `ri -f html` is now XHTML-happy @@ -1473,7 +1475,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * RDoc doesn't crash with def (blah).foo() end * RDoc doesn't crash with #define functions -=== 2.3.0 / 2009-01-28 +== 2.3.0 / 2009-01-28 * 3 Major Enhancements * Michael Granger's Darkfish generator is now the default for HTML output @@ -1508,7 +1510,7 @@ If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc. * C file RDoc is no longer included in token stream * Scan all gem paths to match gem name for ri output -=== 2.2.1 / 2008-09-24 +== 2.2.1 / 2008-09-24 This version provides some minor fixes and enhancements to 2.2.0 intended to polish RDoc for Ruby 1.9.1. @@ -1540,7 +1542,7 @@ to polish RDoc for Ruby 1.9.1. * Fixed missing display of constant values in ri. * Fixed display of constants in ri's html output. -=== 2.2.0 / 2008-09-19 +== 2.2.0 / 2008-09-19 This version includes some significant enhancements to ri. See RI.txt for documentation about ri. @@ -1621,7 +1623,7 @@ documentation about ri. * Fixed the horizontal rule markup (---) so that it correctly adds a horizontal rule rather than suppressing all text that follows. -=== 2.1.0 / 2008-07-20 +== 2.1.0 / 2008-07-20 * 3 Major Enhancements: * RDoc now knows about meta-programmed methods, see RDoc::Parser::Ruby @@ -1651,7 +1653,7 @@ documentation about ri. described in the documentation * RDoc now correctly sets superclasses if they were originally unknown -=== 2.0.0 / 2008-04-10 +== 2.0.0 / 2008-04-10 * 3 Major Enhancements: * Renamespaced everything RDoc under the RDoc module. diff --git a/LICENSE.rdoc b/LICENSE.rdoc index 683585ac8b..c61bb93398 100644 --- a/LICENSE.rdoc +++ b/LICENSE.rdoc @@ -1,3 +1,5 @@ += License + RDoc is copyrighted free software. You can redistribute it and/or modify it under either the terms of the GPL diff --git a/TODO.rdoc b/TODO.rdoc index 9b4215ca47..da919118d9 100644 --- a/TODO.rdoc +++ b/TODO.rdoc @@ -1,9 +1,10 @@ += TODO This file contains some things that might happen in RDoc, or might not. Forward Looking Statements applies. -=== RDoc::VERSION.succ +== RDoc::VERSION.succ -Blockers: +=== Blockers: * Update LICENSE to match ruby's switch * The alias keyword should not be bidirectional @@ -13,7 +14,7 @@ Blockers: * Fix consumption of , after link like: RDoc[rdoc-ref:RDoc], <- comma here * Remove support for links like Matrix[*rows] -Nice to have: +=== Nice to have: * Parse only changed files (like in ruby) * Page of Glory (or Shame) in HTML output showing documentation coverage @@ -26,9 +27,9 @@ Nice to have: * Global variable support * Provide the code_object to directive handlers -=== More Future +== More Future -API changes to RDoc +=== API changes to RDoc * RDoc::TopLevel#add_method should automatically create the appropriate method class rather than requiring one be passed in. @@ -36,7 +37,7 @@ API changes to RDoc * Add versions to RDoc::Markup syntax tree marshal format * Comments can no longer be Strings -=== Crazy Ideas +== Crazy Ideas * Auto-normalize heading levels to look OK. It's weird to see an

in the middle of a method section. @@ -46,7 +47,7 @@ API changes to RDoc * Rename Context to Container * Rename NormalClass to Class -=== Accessibility +== Accessibility Page title in right hand side From e608a84af398aab9aa9c7ff88e35a92c899db8f3 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 10 Oct 2024 17:45:36 +0800 Subject: [PATCH 10/18] Improve method source toggling (#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 69fc9ce6a379e3c28020b8e9b849b7c39948b848. * Give source code blocks a different background color * Change targeted method's highlighting color to work better with the new method source --- .../generator/template/darkfish/class.rhtml | 55 ++++++++++--------- .../generator/template/darkfish/css/rdoc.css | 38 +++++++------ .../template/darkfish/js/darkfish.js | 2 +- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml index 6c64ba6c98..26652cada9 100644 --- a/lib/rdoc/generator/template/darkfish/class.rhtml +++ b/lib/rdoc/generator/template/darkfish/class.rhtml @@ -101,35 +101,42 @@
">
<%- if (call_seq = method.call_seq) then -%> - <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%> -
- - <%= h(call_seq.strip. - gsub( /^\w+\./m, '')). - gsub(/(.*)[-=]>/, '\1→') %> - - <%- if i == 0 and method.token_stream then -%> - click to toggle source + <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%> +
+ + <%= h(call_seq.strip. + gsub( /^\w+\./m, '')). + gsub(/(.*)[-=]>/, '\1→') %> + +
<%- end -%> -
- <%- end -%> <%- elsif method.has_call_seq? then -%> -
- <%= h method.name %> -
+
+ <%= h method.name %> +
<%- else -%> -
- <%= h method.name %><%= h method.param_seq %> - <%- if method.token_stream then -%> - click to toggle source - <%- end -%> -
+
+ <%= h method.name %> + <%= h method.param_seq %> +
<%- end -%>
+ <%- if method.token_stream -%> +
+
+ Source +
+
+ <%- end -%> + <%- unless method.skip_description? then -%>
+ <%- if method.token_stream then -%> +
+
<%= method.markup_code %>
+
+ <%- end -%> <%- if method.comment then -%> <%= method.description.strip %> <%- else -%> @@ -144,12 +151,6 @@ %>
<%- end -%> - - <%- if method.token_stream then -%> -
-
<%= method.markup_code %>
-
- <%- end -%>
<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 772a06b85b..8b7662c645 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -22,6 +22,7 @@ --link-hover-color: #25a28a; /* A slightly brighter teal-green */ --border-color: #e0e0e0; --sidebar-text-color: #2c3e50; /* Dark blue-gray for contrast */ + --source-code-background-color: #e8f0eb; /* Font family variables */ --font-primary: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; @@ -595,6 +596,10 @@ main .method-source-code { transition-timing-function: ease-in-out; } +main .method-source-code pre { + background: var(--source-code-background-color); +} + main .method-source-code.active-menu { visibility: visible; max-height: 100vh; @@ -607,12 +612,15 @@ main .method-description .method-calls-super { main .method-detail { margin-bottom: 2.5em; - cursor: pointer; } main .method-detail:target { margin-left: -10px; - border-left: 10px solid #f1edba; + border-left: 10px solid var(--source-code-background-color); +} + +main .method-header { + display: inline-block; } main .method-heading { @@ -622,23 +630,12 @@ main .method-heading { font-weight: bold; color: var(--text-color); } -main .method-heading :link, -main .method-heading :visited { - color: inherit; -} -main .method-click-advice { - position: absolute; - top: 2px; - right: 5px; - font-size: 12px; - color: #9b9877; - visibility: hidden; - padding-right: 20px; + +main .method-controls { line-height: 20px; - background: url(../images/zoom.png) no-repeat right top; -} -main .method-header:hover .method-click-advice { - visibility: visible; + float: right; + color: var(--secondary-color); + cursor: pointer; } main .method-alias .method-heading { @@ -743,6 +740,11 @@ main .attribute-access-type { overflow-x: auto; white-space: nowrap; } + + main .method-controls { + margin-top: 10px; + float: none; + } } /* @end */ 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); }); }; From 7757fd9fe437498ca27a717423c99b604e202fd9 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 11 Oct 2024 00:09:40 +0800 Subject: [PATCH 11/18] Make methods and attributes linkable (#1189) * Use the same color for both class/module and method highlight * Make methods and attributes linkable --- .../generator/template/darkfish/class.rhtml | 24 ++++++++++++------- .../generator/template/darkfish/css/rdoc.css | 15 ++++++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml index 26652cada9..afac0c44cd 100644 --- a/lib/rdoc/generator/template/darkfish/class.rhtml +++ b/lib/rdoc/generator/template/darkfish/class.rhtml @@ -72,8 +72,10 @@ <%- attributes.each do |attrib| -%>
- <%= h attrib.name %>[<%= attrib.rw %>] + + <%= h attrib.name %> + [<%= attrib.rw %>] +
@@ -103,21 +105,27 @@ <%- if (call_seq = method.call_seq) then -%> <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%> <%- end -%> <%- elsif method.has_call_seq? then -%>
- <%= h method.name %> + + <%= h method.name %> +
<%- else -%>
- <%= h method.name %> - <%= h method.param_seq %> + + <%= h method.name %> + <%= h method.param_seq %> +
<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 8b7662c645..12212a341e 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -84,7 +84,7 @@ h4:target, h5:target, h6:target { margin-left: -10px; - border-left: 10px solid #f1edba; + border-left: 10px solid var(--source-code-background-color); } /* 4. Links */ @@ -631,6 +631,18 @@ main .method-heading { color: var(--text-color); } +main .method-heading::after { + content: '¶'; + position: absolute; + visibility: hidden; + color: var(--secondary-color); + font-size: 0.5em; +} + +main .method-heading:hover::after { + visibility: visible; +} + main .method-controls { line-height: 20px; float: right; @@ -663,7 +675,6 @@ main #attribute-method-details .method-detail:hover { } main .attribute-access-type { text-transform: uppercase; - padding: 0 1em; } /* @end */ From 716bc16a7dbcac937d38c328d2d89a2f7cff2fa9 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 15 Oct 2024 18:59:29 -0400 Subject: [PATCH 12/18] Generate meta tags based on page's content (#1091) --- lib/rdoc/generator/darkfish.rb | 15 +++++++ .../generator/template/darkfish/_head.rhtml | 22 +++++++++ test/rdoc/test_rdoc_generator_darkfish.rb | 45 +++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 96bb4fb66f..5709fabf81 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -780,4 +780,19 @@ def template_for file, page = true, klass = ERB template end + # Returns an excerpt of the content for usage in meta description tags + def excerpt(content) + text = content.is_a?(RDoc::Comment) ? content.text : content + + # Match from a capital letter to the first period, discarding any links, so + # that we don't end up matching badges in the README + first_paragraph_match = text.match(/[A-Z][^\.:\/]+\./) + return text[0...150].gsub(/\n/, " ").squeeze(" ") unless first_paragraph_match + + extracted_text = first_paragraph_match[0] + second_paragraph = first_paragraph_match.post_match.match(/[A-Z][^\.:\/]+\./) + extracted_text << " " << second_paragraph[0] if second_paragraph + + extracted_text[0...150].gsub(/\n/, " ").squeeze(" ") + end end diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml index 69649ad3b5..9e6fb4f94c 100644 --- a/lib/rdoc/generator/template/darkfish/_head.rhtml +++ b/lib/rdoc/generator/template/darkfish/_head.rhtml @@ -3,6 +3,28 @@ <%= h @title %> +<%- if defined?(klass) -%> + "> + + <%- if klass.comment.empty? -%> + "> + <%- else -%> + "> + <%- end -%> +<%- elsif defined?(file) -%> + + "> +<%- elsif @title -%> + + + <%- if @options.main_page and + main_page = @files.find { |f| f.full_name == @options.main_page } then %> + "> + <%- else -%> + + <%- end -%> +<%- end -%> +