Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# 3.0 is interpreted as 3
ruby: ["3.0", 3.1, 3.2, 3.3, 3.4]
ruby: ["3.0", 3.1, 3.2, 3.3, 3.4, "4.0"]
include:
- os: ubuntu-latest
container: ruby:2.2
Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
source 'https://rubygems.org'

group :development do
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
gem 'benchmark'
gem 'irb'
gem 'logger'
gem 'ostruct'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why ostruct here and not in the gemspec?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could see ostruct is only used in one of the benchmarking scripts and I don't think they're distributed in the gem, are they?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh indeed we did move away from OpenStruct in the ~ last release.

end
gem 'rspec', '>= 3.11.0'
gem 'rake'
gem 'rdoc', '= 6.1.2.1'
Expand Down
2 changes: 1 addition & 1 deletion lib/yard/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def has_yardoc
@has_rdoc == 'yard'
end

undef has_rdoc?
undef has_rdoc? if method_defined?(:has_rdoc?)
def has_rdoc?
(@has_rdoc ||= true) && @has_rdoc != 'yard'
end
Expand Down
6 changes: 3 additions & 3 deletions spec/handlers/ruby/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class StringHandler < Handlers::Ruby::Base
handles "x"
end
allow(Handlers::Base).to receive(:subclasses).and_return [StringHandler]
ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
ast = YARD::Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
valid StringHandler, ast[0][0][0]
invalid StringHandler, ast[0][1]
end
Expand All @@ -56,7 +56,7 @@ class RegexHandler < Handlers::Ruby::Base
handles(/^if x ==/)
end
allow(Handlers::Base).to receive(:subclasses).and_return [RegexHandler]
ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
ast = YARD::Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
valid RegexHandler, ast
invalid RegexHandler, ast[0][1]
end
Expand All @@ -75,7 +75,7 @@ class MethCallHandler < Handlers::Ruby::Base
handles method_call(:meth)
end
allow(Handlers::Base).to receive(:subclasses).and_return [MethCallHandler]
ast = Parser::Ruby::RubyParser.parse(<<-"eof").ast
ast = YARD::Parser::Ruby::RubyParser.parse(<<-"eof").ast
meth # 0
meth() # 1
meth(1,2,3) # 2
Expand Down
4 changes: 4 additions & 0 deletions yard.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ Gem::Specification.new do |s|
s.executables = ['yard', 'yardoc', 'yri']
s.license = 'MIT' if s.respond_to?(:license=)
s.metadata['yard.run'] = 'yri'
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
s.add_dependency 'irb'
s.add_dependency 'logger'
end
Comment on lines +23 to +26
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional here doesn't really do the "right" thing, namely for rubygems this will require Ruby 4.x to build the deps, which means gem publishes need to happen from Ruby 4 otherwise deps will get lost. That seems like it would be very error prone and lead to regressions.

That said, I understand what we're trying to do and I think the biggest blocker for this change is that the only way to do this is to force the added deps to all Rubies, and that might be a bit of a problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add another gemspec for a different gem name, e.g. yard_on_ruby4, and set required_ruby_version to 4.0.0...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or vendor the code from the dependencies?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, but I can't imagine how that would work from a user POV. At that point, directing users to install yard4 etc would be a documentation effort not very different from just adding docs to gem install irb logger yard or place those deps in a Gemfile (which is a far more common pattern here).

IMO I think the more likely approach might actually be to vendor a lot of these libraries to avoid any extra complexity. Unfortunately the Ruby maintainers didn't provide a lot of backward compatibility options when moving down this path of these breaking changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I think the more likely approach might actually be to vendor a lot of these libraries to avoid any extra complexity. Unfortunately the Ruby maintainers didn't provide a lot of backward compatibility options when moving down this path of these breaking changes.

That or adding the decencies for everyone. That will just force Ruby 3.x users to use other version of the concerned libs. Probably using a more up to date version than the one natively embedded in their ruby 3.x system.

end