Skip to content

ruby_parser.rb - add void_stmt to insert_comments loop#1290

Merged
lsegal merged 1 commit intolsegal:masterfrom
MSP-Greg:void-stmt
Nov 26, 2019
Merged

ruby_parser.rb - add void_stmt to insert_comments loop#1290
lsegal merged 1 commit intolsegal:masterfrom
MSP-Greg:void-stmt

Conversation

@MSP-Greg
Copy link
Contributor

Description

While running YARD with Ruby 2.7, the following comment is not added to class B:

module A
  # comment
  # ...
  # end comment
  class B

but, if a blank line is added between module A and the comment, it parses fine.

Tests passed in my fork, but 2.7/trunk is not tested against. I checked the issue locally.

I could add Actions testing on Windows (Ruby 2.4 thru trunk), which I assume would show the issue.

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

@coveralls
Copy link

coveralls commented Nov 19, 2019

Coverage Status

Coverage decreased (-1.8%) to 91.933% when pulling 10a2e5b on MSP-Greg:void-stmt into 4b5c875 on lsegal:master.

@koic
Copy link
Contributor

koic commented Nov 25, 2019

Superfantastic!

@koic
Copy link
Contributor

koic commented Nov 25, 2019

@lsegal This PR will resolve the following repositories CI failures related to RuboCop when using Ruby 2.7.0-dev.

Could you release a new version of YARD gem? I'm happy when it is released :-)

@MSP-Greg
Copy link
Contributor Author

@koic

Thanks for testing. Over the weekend some changes were made to irb (see ruby/ruby@efbca15), and it broke YARD, specifically the code here:

require "e2mmap"
require "irb/slex"
module YARD
module Parser::Ruby::Legacy
# Legacy lexical tokenizer module.
module RubyToken

A simple fix is to add gem 'irb', '1.1.0' somewhere, but I think a more permanent fix is needed...

@aycabta
Copy link
Contributor

aycabta commented Nov 26, 2019

The ruby-token.rb was also removed at ruby/ruby@45bb6f2 but the class, RubyToken was copied and pasted to lib/yard/parser/ruby/legacy/ruby_lex.rb of YARD.

RubyLex in lib/irb/ruby-lex.rb was big-bang changed at ruby/ruby@94b740b#diff-80fbffd8d3dfc72fb539e0c03a8f0581 and also copied and pasted to the same file (lib/yard/parser/ruby/legacy/ruby_lex.rb).

I think SLex should be also copied from lib/irb/slex.rb and be pasted to the same file (lib/yard/parser/ruby/legacy/ruby_lex.rb).

@lsegal
Copy link
Owner

lsegal commented Nov 26, 2019

Another option is to remove legacy given that YARD has officially dropped support for the 1.8 parser a while ago. If Ruby is going in the same direction, I don't see a reason to keep such old outdated code.

@lsegal lsegal merged commit 27874ee into lsegal:master Nov 26, 2019
@MSP-Greg MSP-Greg deleted the void-stmt branch November 26, 2019 20:56
@MSP-Greg
Copy link
Contributor Author

@lsegal

Another option is to remove legacy

I briefly looked at this. The following overload statement parses with the legacy parser, but a Ripper based parser may not allow it, since the parameters aren't valid Ruby code:

module YARD::Handlers::Ruby::DecoratorHandlerMethods
# @overload process_decorator(*nodes, opts = {}, &block)

Thoughts?

koic added a commit to koic/rubocop-rails that referenced this pull request Dec 6, 2019
This PR solves the following "The manual directory is out of sync" error.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-rails/2180

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
koic added a commit to koic/rubocop-performance that referenced this pull request Dec 6, 2019
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-performance/869

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
koic added a commit to koic/rubocop-minitest that referenced this pull request Dec 6, 2019
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-minitest/968

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
koic added a commit to koic/rubocop that referenced this pull request Dec 9, 2019
This PR solves a broken document as follows:

```console
% ruby -v
ruby 2.7.0dev (2019-12-08T15:13:07Z master 0e71fbc18e) [x86_64-darwin17]

% bundle exec rake generate_cops_documentation
Files:         473
Modules:        83 (   76 undocumented)
Classes:       437 (  411 undocumented)
Constants:     628 (  620 undocumented)
Attributes:     31 (    0 undocumented)
Methods:      1080 (  961 undocumented)
 8.46% documented
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_bundler.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_gemspec.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_layout.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_lint.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_metrics.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_migration.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_naming.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_security.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_style.md
```

The document will be empty as follows:

```diff
% git diff
diff --git a/manual/cops_bundler.md b/manual/cops_bundler.md
index b369413..3dc102845 100644
--- a/manual/cops_bundler.md
+++ b/manual/cops_bundler.md
@@ -6,32 +6,7 @@ Enabled by default | Safe | Supports autocorrection |
VersionAdded | VersionChan
 --- | --- | --- | --- | ---
 Enabled | Yes | No | 0.46 | -

-A Gem's requirements should be listed only once in a Gemfile.
-
-### Examples
-
-```ruby
-# bad
-gem 'rubocop'
-gem 'rubocop'
-
-# bad
-group :development do
-  gem 'rubocop'
-end
-
-group :test do
-  gem 'rubocop'
-end
-
-# good
-group :development, :test do
-  gem 'rubocop'
-end
-
-# good
-gem 'rubocop', groups: [:development, :test]
-```
+No documentation

(snip)
```

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Dec 9, 2019
This PR solves a broken document as follows:

```console
% ruby -v
ruby 2.7.0dev (2019-12-08T15:13:07Z master 0e71fbc18e) [x86_64-darwin17]

% bundle exec rake generate_cops_documentation
Files:         473
Modules:        83 (   76 undocumented)
Classes:       437 (  411 undocumented)
Constants:     628 (  620 undocumented)
Attributes:     31 (    0 undocumented)
Methods:      1080 (  961 undocumented)
 8.46% documented
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_bundler.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_gemspec.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_layout.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_lint.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_metrics.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_migration.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_naming.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_security.md
* generated /Users/koic/src/github.com/rubocop-hq/rubocop/manual/cops_style.md
```

The document will be empty as follows:

```diff
% git diff
diff --git a/manual/cops_bundler.md b/manual/cops_bundler.md
index b369413..3dc102845 100644
--- a/manual/cops_bundler.md
+++ b/manual/cops_bundler.md
@@ -6,32 +6,7 @@ Enabled by default | Safe | Supports autocorrection |
VersionAdded | VersionChan
 --- | --- | --- | --- | ---
 Enabled | Yes | No | 0.46 | -

-A Gem's requirements should be listed only once in a Gemfile.
-
-### Examples
-
-```ruby
-# bad
-gem 'rubocop'
-gem 'rubocop'
-
-# bad
-group :development do
-  gem 'rubocop'
-end
-
-group :test do
-  gem 'rubocop'
-end
-
-# good
-group :development, :test do
-  gem 'rubocop'
-end
-
-# good
-gem 'rubocop', groups: [:development, :test]
-```
+No documentation

(snip)
```

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
@z64
Copy link

z64 commented Dec 10, 2019

@lsegal @MSP-Greg Sorry to bump a PR - could we get a tracking issue for the irb/slex etc. issue above for visibility?

Ran into it myself and had quite a difficult time debugging to find this conversation among other irb/slex issues over the ages / trying to deduce if my environment was just broken. 😺

koic added a commit to koic/rubocop-faker that referenced this pull request Dec 13, 2019
This commit solves the following "The manual directory is out of sync"
error.

```console
% ruby -v
ruby 2.7.0dev (2019-12-11T07:52:06Z master 3098798044) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-rails/2180

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
koic added a commit to koic/yard that referenced this pull request Dec 26, 2019
Follow up of lsegal#1290 (comment).

This is a workaround path for Ruby 2.7.0.

`irb/slex` internal API has been removed in the following commits.
ruby/ruby@45bb6f2

This PR copies the above file to lib/yard/parser/ruby/legacy/irb/slex.rb.

Hopefully this workaround patch will be dropped along with legacy Ruby code
in the future.

And E2MM (e2mmap gem) is no longer bundled gems.
https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/

```console
% cd path/to/repo/yard
% ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
% bundle exec rake

(snip)

LoadError:
  cannot load such file -- e2mmap
  # ./lib/yard/parser/ruby/legacy/ruby_lex.rb:1:in `require'
  # ./lib/yard/parser/ruby/legacy/ruby_lex.rb:1:in `<top (required)>'
```

This dependency on `e2mmap` could be removed when `irb/slex` is removed
in the future.
@koic koic mentioned this pull request Dec 26, 2019
4 tasks
@koic
Copy link
Contributor

koic commented Dec 26, 2019

I opened a workaround patch #1296 for using Ruby 2.7.0.

koic added a commit to koic/yard that referenced this pull request Dec 26, 2019
Follow up of lsegal#1290 (comment).

This is a workaround path for Ruby 2.7.0.

`irb/slex` internal API has been removed in the following commits.
ruby/ruby@45bb6f2

This PR copies the above file to lib/yard/parser/ruby/legacy/irb/slex.rb.

Hopefully this workaround patch will be dropped along with legacy Ruby code
in the future.

And E2MM (e2mmap gem) is no longer bundled gems.
https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/

```console
% cd path/to/repo/yard
% ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
% bundle exec rake

(snip)

LoadError:
  cannot load such file -- e2mmap
  # ./lib/yard/parser/ruby/legacy/ruby_lex.rb:1:in `require'
  # ./lib/yard/parser/ruby/legacy/ruby_lex.rb:1:in `<top (required)>'
```

This PR adds `e2mmap` gem to the gemspec. And this dependency on `e2mmap`
could be removed when `irb/slex` is removed in the future.
lsegal added a commit that referenced this pull request Dec 31, 2019
castwide pushed a commit to castwide/solargraph that referenced this pull request Jan 1, 2020
* CI against Ruby 2.7

* Ruby 2.7.0 Released
https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/

* e2mmap gem is no longer bundled with Ruby 2.7

```
/home/travis/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- e2mmap (LoadError)
```

https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/

```
The following libraries are no longer bundled gems. Install corresponding gems to use these features.
* CMath (cmath gem)
* Scanf (scanf gem)
* Shell (shell gem)
* Synchronizer (sync gem)
* ThreadsWait (thwait gem)
* E2MM (e2mmap gem)
```

* `lib/irb/slex.rb` has been removed from Ruby 2.7

```
/home/travis/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- irb/slex (LoadError)
```

Refer ruby/ruby@efbca15
lsegal/yard#1290 (comment)

* Allow lower irb versions

* Add benchmark gem explicitly
patrickm53 pushed a commit to patrickm53/performance-develop-rubyonrails that referenced this pull request Sep 23, 2022
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-performance/869

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
richardstewart0213 added a commit to richardstewart0213/performance-build-Performance-optimization-analysis- that referenced this pull request Nov 4, 2022
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-performance/869

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
Cute0110 added a commit to Cute0110/Rubocop-Performance that referenced this pull request Sep 28, 2023
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-performance/869

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
SerhiiMisiura added a commit to SerhiiMisiura/Rubocop-Performance that referenced this pull request Oct 5, 2023
This PR solves the following "The manual directory is out of sync" error
when using Ruby 2.7.0-dev.

```console
% ruby -v
ruby 2.7.0dev (2019-12-03T05:51:14Z master e42d9d8df8) [x86_64-darwin17]
% CI=true bundle exec rake

(snip)

The manual directory is out of sync. Run `rake
generate_cops_documentation` and commit the results.
```

https://circleci.com/gh/rubocop-hq/rubocop-performance/869

This issue will be resolved with the release of YARD 0.9.21 or higher,
which includes the following changes:
lsegal/yard#1290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Comments