Comments (5)
For me the path is the following :
/home/quentinlem/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/friendly_id-5.5.0/guide.rb
I haven't separate versions of this gem on my system.
Also, commenting the file solve the issue.
The question now is : how to solve this ?
Can we update guide.rb to behave differently inside rails or bundle project ?
from friendly_id.
After a little troubleshooting, I think I've found the source of the issue.
For some context guide.rb
attempts to create Guide.md
by concatenating the main comment from each of a set of files. It assumes that each of these files has a =begin...=end
section.
However, after 81442a6#diff-25bc55f30c705a8a66eb2e7e68071f870583553019da95beaba7ad0518a09793L8, none of these files have a =begin...=end
section, as standard suggests using normal comments instead.
The exception comes when attempting to index the first match when there is no match:
match = File.read(path).match(/\n=begin(.*)\n=end/m)[1].to_s
^
Note that it is not just yard doc
that is broken by this. The rake guide
task that calls this file is also broken for the same reason.
I'm not entirely sure what the best way to move forward is, but with some guidance on a direction I'd be happy to resolve this.
Here are some suggestions:
-
Remove
rake guide
andguide.rb
(and remove references from.yardopts
)I imagine it is worth keeping the guide for the generated yard docs, but I thought I'd include this as it is an option.
-
Update the regex to build
Guide.md
more sophisticatedThis will take a little bit of research, as I'm not entirely sure if this will work as it did before, but I'm thinking that finding the first comment block in each file might work, or at least be a good starting point.
-
Use a custom delimiter
Instead of
=begin
and=end
, this could be# @guide begin
and# @guide end
.Using the custom tag
@guide begin
would prevent yard from showing the begin and end markers. -
Go back to using
=begin...=end
comment blocksI see 2 ways to do this:
-
Configure rubocop to allow block comments
Unfortunately, standard doesn't allow customizing the configuration (that's kind of the idea). However, it is possible to use the standard ruleset with rubocop and then customize the rubocop configuration (see https://github.com/standardrb/standard#running-standards-rules-via-rubocop).
-
Use
# rubocop:disable Style/BlockComments
This could be done before each
=begin...=end
block. Then# rubocop:enable Style/BlockComments
would be added after the=end
. -
from friendly_id.
I took a stab at resolving this with the custom delimiter idea: #1006
from friendly_id.
I had a similar error message when running yard gems
:
guide.rb:7:in `comments_from': undefined method `[]' for nil:NilClass (NoMethodError)
from guide.rb:14:in `block (2 levels) in <top (required)>'
from guide.rb:13:in `each'
from guide.rb:13:in `block in <top (required)>'
from guide.rb:11:in `open'
from guide.rb:11:in `<top (required)>'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:70:in `load'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:70:in `load_script'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:28:in `block in common_options'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1694:in `block in parse_in_order'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1636:in `catch'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1636:in `parse_in_order'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1630:in `order!'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1739:in `permute!'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/3.2.0/optparse.rb:1764:in `parse!'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:56:in `parse_options'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/yardoc.rb:536:in `optparse'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/yardopts_command.rb:97:in `parse_yardopts'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/yardopts_command.rb:41:in `parse_arguments'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/yardoc.rb:292:in `parse_arguments'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/yardoc.rb:248:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:14:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:41:in `block (2 levels) in build_gems'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:39:in `chdir'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:39:in `block in build_gems'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:29:in `each'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:29:in `build_gems'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/gems.rb:21:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command.rb:14:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command_parser.rb:72:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/lib/yard/cli/command_parser.rb:54:in `run'
from /Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/yard-0.9.32/bin/yard:13:in `<top (required)>'
from /Users/st/.rbenv/versions/3.2.1/bin/yard:25:in `load'
from /Users/st/.rbenv/versions/3.2.1/bin/yard:25:in `<main>'
Looks like the file guide.rb
file causes the problem.
I ran find ~/ -name 'guide.rb'
to find its location.
find ~/ -name 'guide.rb'
/Users/st//.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/friendly_id-5.5.0/guide.rb
/Users/st//.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/friendly_id-5.5.0/guide.rb
/Users/st//.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/friendly_id-5.4.2/guide.rb
It shows I have three separate friendly_id gems on my system, for different ruby versions, so I deleted two older ones I didn't need anymore with:
rm -rf /Users/st//.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/friendly_id-5.5.0
rm -rf /Users/st//.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/friendly_id-5.4.2
Then yard gems
succeeded.
Hope it helps.
from friendly_id.
Actually, that worked for yard gems
on my system gems, but when I tried it in a rails app directory (for an app using friendly_id 5.5) it failed again with the same error.
I opened the location of the gem and commented out the whole of the guide.rb
file, and yard gems
seems to succeed now.
For me the location was
/Users/st/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/friendly_id-5.5.0/guide.rb
but it might differ depending on the ruby version in use.
from friendly_id.
Related Issues (20)
- friendly_id tripping NotNullViolation in Postgres
- `allow_nil: true` on the find method does not work as expected. HOT 7
- normalize_friendly_id not working in a concern HOT 2
- Re-enable numeric sequences? HOT 1
- FriendlyId and CanCanCan and redirects
- Generate slug with a `name` and `id` of the record
- :history fails when trying to reuse slugs HOT 1
- Slug regenerated
- Find_by return an nill
- UUID set as slug on failed validations on base column HOT 1
- Error in the doc
- support for Arabic, Persian and other RTL languages
- 5.5.1 release request HOT 3
- Rails 7.1 composite key support
- History does not use parse_friendly_id
- Setting slug_limit in initialiser crashes rspec tests HOT 3
- How can I handle this scoped slug use case without a new option from Friendly ID to disable UUID generation? HOT 2
- Advise users on skipping lazy loaded associations HOT 1
- Collisions when using finder with Rails STI subtypes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from friendly_id.