From 15e96603324709a3a7860832a5bfd92f824197eb Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 30 Mar 2026 18:08:43 +0100 Subject: [PATCH 1/9] Bump minimum Ruby to 3.2, add rbs dependency, update CI RBS 4.0 requires Ruby >= 3.2. Bump RDoc's own minimum to match and add `rbs >= 4.0.0` as a gemspec dependency. Bump prism minimum to `>= 1.6.0` (required by rbs). Drop JRuby and TruffleRuby from CI matrix (rbs has a C extension that cannot build on them). --- .github/workflows/test.yml | 14 +++----------- Gemfile | 4 +--- rdoc.gemspec | 5 +++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c6309ea77..70ad37c2cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,9 +14,9 @@ jobs: ruby-versions: uses: ruby/actions/.github/workflows/ruby_versions.yml@master with: - # 2.7 breaks `test_parse_statements_nodoc_identifier_alias_method` - min_version: 3.0 + min_version: 3.2 versions: '["mswin"]' + engine: cruby test: needs: ruby-versions @@ -26,14 +26,6 @@ jobs: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} os: [ubuntu-latest, macos-latest, windows-latest] exclude: - - os: windows-latest - ruby: truffleruby - - os: windows-latest - ruby: truffleruby-head - - os: windows-latest - ruby: jruby - - os: windows-latest - ruby: jruby-head - os: macos-latest ruby: mswin - os: ubuntu-latest @@ -68,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - prism_version: ['1.0.0', '1.3.0', '1.7.0', 'head'] + prism_version: ['1.6.0', '1.7.0', 'head'] runs-on: ubuntu-latest env: RUBYOPT: --enable-frozen_string_literal diff --git a/Gemfile b/Gemfile index 317623101b..4b2be8f5d5 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,5 @@ elsif ENV['PRISM_VERSION'] end platforms :ruby do - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2') - gem 'mini_racer' # For testing the searcher.js file - end + gem 'mini_racer' # For testing the searcher.js file end diff --git a/rdoc.gemspec b/rdoc.gemspec index 1afe52f7b6..294255d7a1 100644 --- a/rdoc.gemspec +++ b/rdoc.gemspec @@ -63,11 +63,12 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat s.rdoc_options = ["--main", "README.md"] 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(">= 3.2.0") s.required_rubygems_version = Gem::Requirement.new(">= 2.2") s.add_dependency 'psych', '>= 4.0.0' s.add_dependency 'erb' s.add_dependency 'tsort' - s.add_dependency 'prism', '>= 1.0.0' + s.add_dependency 'prism', '>= 1.6.0' + s.add_dependency 'rbs', '>= 4.0.0' end From c7e4cd5541a282eded1f14e8d5b8c57997ce6c0c Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 30 Mar 2026 18:08:57 +0100 Subject: [PATCH 2/9] Extract and display RBS type signatures in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `type_signature` accessor to `MethodAttr`. During Prism parsing, extract `#:` annotation lines from comment blocks and store them on methods and attributes. Bump Marshal to v4 for RI serialization. Render type signatures in the aliki theme: below method headings for methods, inline after the `[RW]` badge for attributes. Arrows use `→` for consistency with `call_seq`. Validate annotations through `RBS::Parser` — invalid sigs emit a warning but are still displayed. Client-side JS highlighter colors type names (blue) and built-in keywords like `void`/`untyped`/`bool` (purple). --- lib/rdoc/code_object/any_method.rb | 4 +- lib/rdoc/code_object/attr.rb | 6 +- lib/rdoc/code_object/method_attr.rb | 6 + lib/rdoc/generator/template/aliki/_head.rhtml | 5 + lib/rdoc/generator/template/aliki/class.rhtml | 13 +- .../generator/template/aliki/css/rdoc.css | 33 ++++ lib/rdoc/parser/prism_ruby.rb | 45 ++++- test/rdoc/code_object/any_method_test.rb | 21 +++ test/rdoc/code_object/attr_test.rb | 17 ++ test/rdoc/parser/prism_ruby_test.rb | 154 ++++++++++++++++++ 10 files changed, 294 insertions(+), 10 deletions(-) diff --git a/lib/rdoc/code_object/any_method.rb b/lib/rdoc/code_object/any_method.rb index f56110ea11..26b42c07cb 100644 --- a/lib/rdoc/code_object/any_method.rb +++ b/lib/rdoc/code_object/any_method.rb @@ -14,7 +14,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr # RDoc 4.1 # Added is_alias_for - MARSHAL_VERSION = 3 # :nodoc: + MARSHAL_VERSION = 4 # :nodoc: ## # Don't rename \#initialize to \::new @@ -166,6 +166,7 @@ def marshal_dump @parent.class, @section.title, is_alias_for, + @type_signature, ] end @@ -204,6 +205,7 @@ def marshal_load(array) @parent_title = array[13] @section_title = array[14] @is_alias_for = array[15] + @type_signature = array[16] array[8].each do |new_name, document| add_alias RDoc::Alias.new(nil, @name, new_name, RDoc::Comment.from_document(document), singleton: @singleton) diff --git a/lib/rdoc/code_object/attr.rb b/lib/rdoc/code_object/attr.rb index bfc981f7e8..3895121854 100644 --- a/lib/rdoc/code_object/attr.rb +++ b/lib/rdoc/code_object/attr.rb @@ -11,7 +11,7 @@ class RDoc::Attr < RDoc::MethodAttr # Added parent name and class # Added section title - MARSHAL_VERSION = 3 # :nodoc: + MARSHAL_VERSION = 4 # :nodoc: ## # Is the attribute readable ('R'), writable ('W') or both ('RW')? @@ -108,7 +108,8 @@ def marshal_dump @file.relative_name, @parent.full_name, @parent.class, - @section.title + @section.title, + @type_signature, ] end @@ -140,6 +141,7 @@ def marshal_load(array) @parent_name = array[8] @parent_class = array[9] @section_title = array[10] + @type_signature = array[11] @file = RDoc::TopLevel.new array[7] if version > 1 diff --git a/lib/rdoc/code_object/method_attr.rb b/lib/rdoc/code_object/method_attr.rb index 3169640982..f968543bdd 100644 --- a/lib/rdoc/code_object/method_attr.rb +++ b/lib/rdoc/code_object/method_attr.rb @@ -58,6 +58,11 @@ class RDoc::MethodAttr < RDoc::CodeObject attr_accessor :call_seq + ## + # RBS type signature from inline #: annotations + + attr_accessor :type_signature + ## # The call_seq or the param_seq with method name, if there is no call_seq. @@ -86,6 +91,7 @@ def initialize(text, name, singleton: false) @block_params = nil @call_seq = nil @params = nil + @type_signature = nil end ## diff --git a/lib/rdoc/generator/template/aliki/_head.rhtml b/lib/rdoc/generator/template/aliki/_head.rhtml index c6c238d26c..4d05606e58 100644 --- a/lib/rdoc/generator/template/aliki/_head.rhtml +++ b/lib/rdoc/generator/template/aliki/_head.rhtml @@ -145,6 +145,11 @@ defer > + +