diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b96a61d5f..172ef353b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Gemfile b/Gemfile index f10f5256b..67f06391d 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/lib/yard/templates/section.rb b/lib/yard/templates/section.rb index e8674efe5..ca42adddc 100644 --- a/lib/yard/templates/section.rb +++ b/lib/yard/templates/section.rb @@ -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 diff --git a/rbs b/rbs new file mode 160000 index 000000000..4e5ee848b --- /dev/null +++ b/rbs @@ -0,0 +1 @@ +Subproject commit 4e5ee848b318c6c9cd4131a825f0b794017acb3a diff --git a/spec/parser/ruby/ruby_parser_spec.rb b/spec/parser/ruby/ruby_parser_spec.rb index f4eb09878..ffd3d41bb 100644 --- a/spec/parser/ruby/ruby_parser_spec.rb +++ b/spec/parser/ruby/ruby_parser_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c59b2d99e..9c521a1fd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -209,4 +209,5 @@ def puts(str = '') Kernel.srand config.seed end +YARD::Logger include YARD diff --git a/spec/templates/helpers/html_helper_spec.rb b/spec/templates/helpers/html_helper_spec.rb index f98f40c0a..5f3f268a5 100644 --- a/spec/templates/helpers/html_helper_spec.rb +++ b/spec/templates/helpers/html_helper_spec.rb @@ -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 diff --git a/yard-rbs-core b/yard-rbs-core new file mode 160000 index 000000000..7d9654fac --- /dev/null +++ b/yard-rbs-core @@ -0,0 +1 @@ +Subproject commit 7d9654facdd61c26eee517c0e410081727d28181