Posts Tagged ‘RDoc’

16 April

RubyGems: RDoc Information on Installed Gems

It can be useful to view the RDoc information for the various gems you may have installed on your local system. RubyGems provides a way to do this by starting up a local RDoc server.

Local Gem Server
To start the server, open a command window on the machine that has RubyGems installed and type:

gem server

Once the you get a message that the server is starting, you can minimize this command window (don’t close it or the server will stop).

Using your browser of choice, navigate to http://localhost:8808.

When you open this page, you will see a list of all the gems you have installed on the local system and each one will have an WWW link that will open the project’s homepage as well as an RDoc link that will open the RDoc information for that particular gem. At the top of the page are three columns: Files, Classes and Methods. I tend to find Classes and Methods the most useful when trying to discover usage and syntax for a gem.

If you click on methods displayed in the RDocs, an small pop-up will open to show you the code relating to the method. This can be even more useful if you are trying to figure out how to use a method.

Missing RDoc Information
There might be a situation where you have a gem installed that does not have RDoc information but you can force RubyGems to generate RDoc information for already installed gems.

gem rdoc --all

This will generate the RDoc information for all installed gems. You can also generate RDoc for select gems only by using:

gem rdoc GEMNAME