tmm1 / ripper-tags

fast, accurate ctags generator for ruby source code using Ripper
MIT License
550 stars 43 forks source link

Recommended way to generate tags for gems #91

Closed mottalrd closed 5 years ago

mottalrd commented 5 years ago

Hello, and thank you for this awesome project

I am wondering what's the best way to generate tags for my gems. When I use ctags this is how I do it: ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)

I replicated with ripper-tags this way: ripper-tags -R --exclude=.git --exclude=log . $(bundle list --paths)

But it is very slow (seconds in ctags, minutes in ripper-tags). I imagine this is because ripper-tags is written in ruby so there must be some overhead, but wondering if there is any better way?

Thank you!

mislav commented 5 years ago

ripper-tags is going to be much slower than ctags due to the former being written in pure Ruby while the latter is C.

You can possibly speed it up by doing something like bundle list --paths | sed 's/$/\/lib/' to only include the lib path inside of every gem, excluding other .rb files within gems such as tests.

You could also avoid generating tags for gems too often. You could generate them once each time after you update your dependenices and save them to a separate file such as tags-gems. Then, when regenerating the tags file from just the files your project, you can merge in the tags-gems file. Unfortunately, ripper-tags doesn't ship right now with any facilities to merge two tags files into one, so you would have to do that manually.

mottalrd commented 5 years ago

Thank you @mislav , super useful!

mislav commented 5 years ago

Closing because you might be able to implement some of these workarounds on your own that that doesn't seem anything immediately actionable that we can do from the ripper-tags side right now. PRs that improve performance of this tool are very welcome!