Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Ruby 3.0 #1364

Merged
merged 3 commits into from Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -28,3 +28,14 @@ jobs:
bundle exec rake
env:
CI: true
build_ruby3:
name: "Ruby: 3.0 OS: Linux"
container: ruby:3.0-rc-alpine
steps:
- uses: actions/checkout@v2
- run: apk add -U build-base
- run: gem update --system --no-document --conservative
- run: bundle install --jobs=3 --retry=3
- run: ruby -v && bundle exec rake
env:
CI: true
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -9,6 +9,7 @@ group :development do
gem 'simplecov'
gem 'samus', '~> 3.0.9', :require => false
gem 'coveralls', :require => false
gem 'webrick'
end

group :asciidoc do
Expand Down
4 changes: 1 addition & 3 deletions lib/yard/templates/section.rb
Expand Up @@ -20,9 +20,7 @@ def dup

def [](*args)
if args.first.is_a?(Range) || args.size > 1
obj = super(*args)
obj.name = name
return obj
return self.class.new(name, *super(*args))
elsif args.first.is_a?(Integer)
return super(*args)
end
Expand Down
1 change: 1 addition & 0 deletions rbs
Submodule rbs added at 4e5ee8
11 changes: 11 additions & 0 deletions spec/parser/ruby/ruby_parser_spec.rb
Expand Up @@ -539,5 +539,16 @@ class B
is_expected.to eq "#{condition_type} condition?; 42; end"
end
end

it "handles single-line method declaration syntax" do
YARD.parse_string <<-eof
class A
# Adds two numbers
def add(x) = x + 1
end
eof

expect(Registry.at('A#add').docstring).to eq('Adds two numbers')
end if RUBY_VERSION >= '3.'
end
end if HAVE_RIPPER
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -209,4 +209,5 @@ def puts(str = '')
Kernel.srand config.seed
end

YARD::Logger
include YARD
15 changes: 5 additions & 10 deletions spec/templates/helpers/html_helper_spec.rb
Expand Up @@ -21,27 +21,22 @@ def options
end

describe "#charset" do
after { Encoding.default_external = 'utf-8' if defined?(Encoding) }

it "returns foo if LANG=foo" do
expect(ENV).to receive(:[]).with('LANG').and_return('shift_jis') if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return('shift_jis') if defined?(Encoding)
Encoding.default_external = 'shift_jis' if defined?(Encoding)
expect(charset).to eq 'shift_jis'
end

['US-ASCII', 'ASCII-7BIT', 'ASCII-8BIT'].each do |type|
['US-ASCII', 'binary', 'ASCII-8BIT'].each do |type|
it "converts #{type} to iso-8859-1" do
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
Encoding.default_external = type if defined?(Encoding)
expect(charset).to eq 'iso-8859-1'
end
end

it "supports utf8 as an encoding value for utf-8" do
type = 'utf8'
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
expect(charset).to eq 'utf-8'
end

it "takes file encoding if there is a file" do
@file = OpenStruct.new(:contents => String.new('foo').force_encoding('sjis'))
# not the correct charset name, but good enough
Expand Down
1 change: 1 addition & 0 deletions yard-rbs-core
Submodule yard-rbs-core added at 7d9654