Skip to content

Commit

Permalink
Follow up changes for Prism Ruby parser (#1145)
Browse files Browse the repository at this point in the history
* Print warning message when using Prism Ruby parser

* Run all tests with Prism Ruby parser on CI

* Run CI with Ruby 3.0 too

* Make prism dependency optional
  • Loading branch information
st0012 committed Aug 1, 2024
1 parent fde99f1 commit 9d36593
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ permissions: # added using https://github.com/step-security/secure-workflows
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

test:
needs: ruby-versions
Expand Down Expand Up @@ -43,6 +46,11 @@ jobs:
run: bundle exec rake
env:
RUBYOPT: --enable-frozen_string_literal
- name: Run test with Prism parser
run: bundle exec rake
env:
RUBYOPT: --enable-frozen_string_literal
RDOC_USE_PRISM_PARSER: true
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
run: bundle exec rake rdoc
lint:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ group :development do
gem 'test-unit-ruby-core'
gem 'rubocop', '>= 1.31.0'
gem 'gettext'
gem 'prism', '>= 0.30.0'
end
3 changes: 3 additions & 0 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions rdoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9d36593

Please sign in to comment.