LXR for Ruby interpreter?
I'm trying to track down a bug caused by the intersection of MRI 1.8.7 and libxml-1.1.3, and I need to do some digging around in the codebase of the Ruby interpreter itself. The SVN browser is of limited utility; what I'd really like is to use LXR, which hyperlinks a C codebase for easy navigation, e.g. http://lxr.linux.no/p开发者_高级运维erl+perl-5.10.1/utf8.c
I can certainly set up LXR on my machine, but does anyone know if there's a public LXR for Ruby out there? Google is not very helpful: http://www.google.com/search?ie=UTF-8&q=lxr+ruby
I still haven't found a public LXR for MRI, so I set up one on my machine. Here's how to do it on Ubuntu 10.10:
: josh@josh; cat /etc/issue
Ubuntu 10.10 \n \l
: josh@josh; sudo aptitude install apache2 lxr
: josh@josh; sudo vim /etc/apache2/sites-available/default
: josh@josh; tail -6 /etc/apache2/sites-available/default
Alias /lxr /usr/share/lxr
Options All
AllowOverride All
: josh@josh; sudo vim /usr/share/lxr/http/.htaccess
: josh@josh; sudo cat /usr/share/lxr/http/.htaccess
SetHandler cgi-script
: josh@josh; sudo mkdir -p /usr/share/lxr/source/1.8.7-p334
: josh@josh; cd /usr/share/lxr/source/1.8.7-p334
: josh@josh; sudo tar xvjf /tmp/ruby-1.8.7.tar.bz2
: josh@josh; sudo mv ruby-1.8.7 ruby
: josh@josh; sudo vim /usr/share/lxr/source/versions
: josh@josh; sudo cat /usr/share/lxr/source/versions
1.8.7-p334
: josh@josh; sudo ln -s /usr/share/lxr/source/1.8.7-p334 /usr/share/lxr/source/defversion
: josh@josh; sudo genxref ruby
Starting pass 1: Collect identifier definitions.
(Pass 1) vms/vmsruby_private.c (993), file 1 of 262…
[...]
(Pass 3) identifier 8200 of maximum 17136…
(Pass 3) identifier 8300 of maximum 17136…
Completed pass 3 (0s):Information on 8316 identifiers dumped to disk.
: josh@josh; sudo chmod -R o+r .
: josh@josh; sudo vim /usr/share/lxr/http/lxr.conf
: josh@josh; sudo cat /usr/share/lxr/http/lxr.conf
# Configuration file.
# [...]
# The source is here.
sourceroot: /usr/share/lxr/source/$v/ruby/
srcrootname: Ruby
# [...]
Its not LXR, but I did a lot of that recently and found Understand extremely helpful. It'll let you click on any symbol and go to a definition/declaration and do simple call graphing and other static analysis. I just wish it supported Ruby source too.
On another note, libxml is still hopelessly broken, if you can migrate to Nokogiri it'll save you a lot of grief. Their APIs are very similar.
Introducing another code cross reference site, for general use besides linux kernel https://code-grep.com
精彩评论