Unleashing ri

drbrain | Sun, 27 Aug 2006 23:45:00 GMT

Now that ruby 1.8.5 has been released (Changelog) and ri includes a bunch more documentation and integrates with gems you just might be suffering from ri overload.
$ ri --system -l | wc -l
    8882
$ ri -l | wc -l
   11918
$ echo 11918 - 8882 | bc
3036
I have 31 extra gems installed, including Rails, which gives me a ton more at-my-fingertips documentation! Some people would rather have less documentation, and there are a handful of new options that control where ri will search for documentation.
$ ri -h
[...]

  --doc-dir, -d <dirname>
                  A directory to search for documentation. If not
                  specified, we search the standard rdoc/ri directories.
                  May be repeated.

       --system   Include documentation from Ruby's standard library:
                    /usr/local/share/ri/1.8/system

         --site   Include documentation from libraries installed in site_lib:
                    /usr/local/share/ri/1.8/site

         --home   Include documentation stored in ~/.rdoc:
                    /Users/drbrain/.rdoc

         --gems   Include documentation from Rubygems:
                    /usr/local/lib/ruby/gems/1.8/doc/*/ri

[...]
Options may also be passed in the 'RI' environment variable
$
I've set my RI environment variable is -T -f ansi to turn off the pager and give me fancy colors, but you can do mix-and-match options to your liking. To only search the system libraries by default, export RI='--system'. To make an alias that searches only rails documentation:
alias rri="ri -d /usr/local/lib/ruby/gems/1.8/doc/actionmailer*/ri \
              -d /usr/local/lib/ruby/gems/1.8/doc/actionpack*/ri \
              -d /usr/local/lib/ruby/gems/1.8/doc/actionwebservice*/ri \
              -d /usr/local/lib/ruby/gems/1.8/doc/activerecord*/ri \
              -d /usr/local/lib/ruby/gems/1.8/doc/activesupport*/ri \
              -T -f ansi"
(If you have multiple rails versions you'll need to explicitly list the versions of each gem.)
$ rri ActiveRecord::Base.find
----------------------------------------------- ActiveRecord::Base::find
     ActiveRecord::Base::find(*args)
------------------------------------------------------------------------
     Find operates with three different retrieval approaches:

[...]
Also, note that if you install multiple versions of a gem you'll either need to run gem cleanup and remove the old versions or manually remove their ri if you want the older versions to hang around. If you don't, you might get duplicate documentation.

Posted in ,  | no comments

RDoc Mega Update

drbrain | Sat, 05 Aug 2006 05:08:56 GMT

With many thanks to Hugh Sasse for doing much of the gruntwork, there will be a huge increase in RDoc available in Ruby 1.8.5. If you have the time, get the latest from CVS (HEAD or ruby_1_8) and make install install-doc, check it out, and report back anything busted, poorly worded, or in need of general cleanup. I have until Sunday night to fix anything you find.

Posted in ,  | no comments

ZenTest RDoc

drbrain | Thu, 27 Apr 2006 02:57:29 GMT

The RDoc for your favorite testing toolset is now online at zentest.rubyforge.org/.

Strangely, my uploading tasks updates the RDoc every time I run it. Maybe I have the wrong task on the right hand side.

desc 'Upload RDoc to RubyForge'
task :upload => :rdoc do
  user = "#{ENV['USER']}@rubyforge.org"
  project = '/var/www/gforge-projects/zentest'
  local_dir = 'doc'
  pub = Rake::SshDirPublisher.new user, project, local_dir
  pub.upload
end

Posted in , ,  | no comments

Rubygems + ri

drbrain | Thu, 23 Feb 2006 11:42:00 GMT

I’ve almost finished doing what has previously been claimed as impossible. I’ve cleanly integrated ri and Rubygems so that you can use ri to search your installed gems’ documentation.

The first part was simple, tell Rubygems to generate ri data for its gems. Rather than have Rubygems install a gem’s ri data mixed-in with the standard library’s data it installs it into a per-gem directory.

The unfinished part is getting a patch into Ruby that makes ri go looking in the gem ri data directories. That patch is in [ruby-core:7423]. Hopefully I can push it into 1.8 so it will be usable with Rubygems 0.9.

Posted in , ,

I was right!

drbrain | Fri, 17 Feb 2006 10:28:00 GMT

Super-easy!

Except that Rubygems has methods that don’t get called when you think they should.

And that there’s a strange bug in RDoc when you run it twice.

Posted in , , ,

ri for Rubygems will be easy!

drbrain | Fri, 17 Feb 2006 08:44:00 GMT

Something simple as:

begin
  require 'rubygems'
  Dir["#{Gem.path}/gems/*/ri"].each do |path|
    RI::Paths::PATH << path
  end
rescue LoadError
end

Posted in , ,