Offline Ruby Documentation 1

Posted by Paul
on Thursday, October 09

I can run gem server and get the documentation for all my gems served at http://localhost:8808. Very handy indeed and something I always have to hand when coding. I access the Ruby documentation more than anything else and, although the online docs are fine, it's not too useful when I'm offline! It'd be nice if I could get them served locally huh? Below are instructions for doing just that for my version of Ruby. Read on...

  • At the command line type ruby -v to get the version and patch level of the Ruby version you're running.

  • Go to http://svn.ruby-lang.org/repos/ruby/tags and find the path to the revision of the Ruby source that you're running. For me that'd be http://svn.ruby-lang.org/repos/ruby/tags/v1_8_6_111.

  • Go get Subversion if you don't already have it.

  • Get a local copy of the Ruby source for that version. To do so I ran svn export http://svn.ruby-lang.org/repos/ruby/tags/v1_8_6_111/ at the command line. Note I'm exporting (export) rather than checking out (co) as I'm not going to need to commit changes back again.

  • Jump into the root folder of the newly created directory structure (for me this was v1_8_6_111) and run rdoc -o c:\ruby\lib\ruby\gems\1.8\doc\ruby-1.8.6.111. The -o flag tells rdoc where to put the generated documentation (amend as necessary).

  • Jump into 'c:\ruby\lib\ruby\gems\1.8\specifications' and create a new file named 'ruby-1.8.6.111.gemspec' with the following content:

    # -*- encoding: utf-8 -*-
    
    Gem::Specification.new do |s|
      s.name = 'ruby'
      s.version = '1.8.6.111'
      s.homepage = 'http://www.ruby-lang.org'
      s.summary = 'The Ruby documentation'
    end

    When the gem server initialises it searches this folder for gem specifications. Having this file here causes the code to display a link to our Ruby documentation

This means that by going to http://localhost:8808 when the gem server is running I'm able to view the Ruby documentation along with all my gems.

Nice.

Comments

Leave a response

  1. SiduNovember 29, 2008 @ 10:43 AM
    Nice tip - I hadn't thought of checking out Ruby itself and running rdoc on it. Thanks!
Comment