Offline Gem Server RDocs

Twitter _ Jesse Newland_ sinatra-rubygems + Passeng ....jpg

Get Sinatra, Rubygems, and Passenger working for offline RDocs? Count me in. I saw this and new I had to have it. I’ve been on some long plane rides recently and I frequently find myself wanting to look up something from a gem’s documentation while I’m coding. You can use the gem server command but that’s just such a pain to do every time you want to look something up. I hadn’t really given it much thought that there might be an easier way until I saw Jesse’s tweet about it. Having this offline using passenger at http://gems.local is great but I wanted to have a little more searching baked in. Here’s how I did it:

  1. Install the hanna gem from mislav.

    You may need to have the HAML gem installed for this to work. The hanna gem is a great theme for rdoc output. It includes javascript to make some ajaxy type search so you can filter methods by typing in to a text field in one of the frames on the left. It took me a little while to find this theme. It’s the one currently in use on GitRDoc, which is a great resource (if you’re online).

  2. Tell rdoc to use the hanna theme

    In order to tell rdoc and gem to use this when you use the "gem" command, you need to add to your .gemrc. Beware that this will affect all future rdoc generation when you install a gem. Add the following to ~/.gemrc:

  3. Regenerate your rdocs

    You then need to regenerate all of your rdocs with this theme. You can do this by executing the following:

  4. Get sinatra-rubygems

    Clone my fork of Jesse Newland’s sinatra-rubygems from GitHub:

    git clone git://github.com/jseifer/sinatra-rubygems.git

  5. Add it to Passenger

    Hook it up to your passenger preference pane and set the name to "gems.local", restart Apache and you’ll be all set:

    passenger pref pane.jpg

After you complete the above steps, everything should be working. Enjoy! This will come in handy next time you don’t have internet access and need to look up some methods. I’d like to give a special thanks to Jesse Newland for releasing the sinatra-rubygems app.

Update: k776 points out in the comments that this doesn’t work on the latest version of rdoc, which is 2.4.1 as of this writing. It seems 2.3.0 is the version to go with.

Post to Twitter Post to Delicious Delicious Post to Digg Digg This Post Post to Facebook Facebook Post to Reddit Reddit This Post

No related posts.

30 Responses to “Offline Gem Server RDocs”

  1. ropiku 25. Feb, 2009 at 9:25 pm #

    Thanks for your article, it works great.
    You have a typo in the first gist, it's “sudo gem install mislav-hanna” without an h at the end.
    Also note that regenerating rdocs might take a long time, depending on how many gems you have installed.

  2. jseifer 25. Feb, 2009 at 10:03 pm #

    Thanks a lot and good catch, I updated the command.

  3. Christoph Olszowka 25. Feb, 2009 at 11:27 pm #

    Good stuff. I wrote something similar, but working with a static html frameset and a Ruby script that will create it from the local gems installation. No need for sinatra, passenger or any other running servers. Just plain old HTML files on your machine: http://blog.olszowka.de/2009/02/13/rdoc-index-f...

  4. cldwalker 26. Feb, 2009 at 12:19 am #

    Nice gemrc tip. For opening a gem's docs I just autocomplete any gem from my shell using my completion gem, http://github.com/cldwalker/dotfiles/tree/master. Setting up your own gem completion is as simple as having your gem's rdoc paths defined in a yaml: http://github.com/cldwalker/dotfiles/blob/maste....

  5. k776 27. Feb, 2009 at 4:46 am #

    Forgive my ignorance. I'm following the article and when it comes to rebuilding rdocs, I'm seeing

    invalid argument: –format=html

    I ran rdoc –help, and from the looks of it, html is not a valid format.

    -f, –fmt, –format=FORMAT Set the output formatter. One of:
    darkfish
    ri

    Any ideas?

  6. jasonseifer 27. Feb, 2009 at 4:49 am #

    Did you install the hanna gem from above? That's the first thing that I think I can think of that would cause that.

  7. k776 27. Feb, 2009 at 5:01 am #

    I did, yes. It installed fine too. I'm thinking maybe faulty rdoc install. Grabbing html markup file from rdoc CVS to see how that goes.

  8. jasonseifer 27. Feb, 2009 at 5:03 am #

    It might be a path issue also. Where is everything installed and is it in your path?

  9. k776 27. Feb, 2009 at 5:09 am #

    /opt/ruby-enterprise-1.8.6-20090201/ and it is in my path, sudo's path, and root users path. All gems are in /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8 . No gems in ~/.gem (I install system wide). Tried uninstall rdoc and hanna, then reinstalling. No luck. Still only giving me ri and darkfish.

  10. k776 27. Feb, 2009 at 5:21 am #

    No luck with CVS. Even using the ones that are installed doesn't work.

    $ sudo gem rdoc –all –no-ri –format=darkfish
    ERROR: While executing gem … (OptionParser::InvalidOption)
    invalid option: –format=darkfish
    $ sudo gem rdoc –all –no-ri –format=ri
    ERROR: While executing gem … (OptionParser::InvalidOption)
    invalid option: –format=ri

    If those work for you, then something is swewd with my setup @_@

  11. k776 27. Feb, 2009 at 5:40 am #

    It would appear the new Rdoc 2.4.1 doesn't have html format, doesn't support inline source, doesn't support hanna template, and fails on some gems because of opname/op-name. I've downgraded to 2.3.0 and it's working again. Thanks for the article.

  12. jasonseifer 27. Feb, 2009 at 5:54 pm #

    Thanks a lot for this info. I've updated the post.

  13. Karl 27. Feb, 2009 at 6:26 pm #

    I had the same issues as k776, as I was on rdoc 2.4.1 as well.

    Note1: –inline-source is deprecated as of 2.4.0

    Note2: I used 'rdoc: –line-numbers –format=darkfish' in my .gemrc with no problems. Sorry, I just like darkfish better than hanna.

    Great idea Jason.

  14. jasonseifer 27. Feb, 2009 at 6:31 pm #

    Hey, thanks a lot. I like the layout of the darkfish template a lot but I couldn't find a way to search by the method names. I'm also not sure how the gem name dropdown looks with that template (or if it even works).

  15. Karl 27. Feb, 2009 at 7:10 pm #

    @Jason,
    Well, I have to retreat on my previous comment, it crapped out after about 6 gems with the “–inline-source will be removed from RDoc on or after August 2009″ warning, even when not using hanna.

    So it looks like it's back to rdoc 2.3.0.

    You are right that DarkFish is missing the searchable methods and the dropdown is missing completely. Looks like it forkin' time.

    Actually, I like RailsBrain.com docs about the best. Complete navigation via keyboard. Now, how do we get RailsBrain/DarkFish/hanna into the pot for a little rdoc-template stew.

  16. manalang 08. Apr, 2009 at 4:13 pm #

    Check out Bdoc. It's off-line (really off-line) Rdocs => http://github.com/manalang/bdoc/tree/master

  17. Marcos Oliveira 23. Apr, 2009 at 11:30 pm #

    Jason,

    Thank you very much. I really needed the local documentation and find all the steps ready here :)

  18. roger 15. Jun, 2009 at 9:16 am #

    does it work with 2.4.3?

  19. rogerdpack 23. Jun, 2009 at 3:32 pm #

    It doesn't indeed [hanna doesn't]

    Also note here's a bdoc that has links to external url's, too: http://github.com/rogerdpack/bdoc/tree/master

  20. rogerdpack 23. Jun, 2009 at 8:32 pm #

    It doesn't indeed [hanna doesn't]

    Also note here's a bdoc that has links to external url's, too: http://github.com/rogerdpack/bdoc/tree/master

  21. Bruno Miranda 15. Feb, 2010 at 4:16 pm #

    Do you still accomplish this the same way you did back in Feb 09?

  22. Chris Wanstrath 01. Mar, 2010 at 8:34 am #

    WHAT!

  23. jasonseifer 01. Mar, 2010 at 2:30 pm #

    Yep, although I've since stayed on the version of rdoc that's supported by hanna since I like that hanna template much more.

  24. Brendan Kemp 23. Aug, 2010 at 11:23 am #

    I found that I had to specify –overwrite to regenerate all rdocs.

    gem rdoc –all –overwrite

Trackbacks/Pingbacks

  1. Ennuyer.net » Blog Archive » Ruby on Rails Link Backlog - 28. Feb, 2009

    [...] Offline Gem Server RDocs | Jason Seifer [...]

  2. almost effortless » Weekly Digest, 3-8-09 - 08. Mar, 2009

    [...] Offline Gem Server RDocs Get Sinatra, Rubygems, and Passenger working for offline RDocs? Count me in. I saw this and new I had to have it. I’ve been on some long plane rides recently and I frequently find myself wanting to look up something from a gem’s documentation while I’m coding. You can use the gem server command but that’s just such a pain to do every time you want to look something up. [...]

  3. Daddy Fixes Everything » Blog Archive » Sinatra-Tailer: a small app for viewing server log files - 18. Mar, 2009

    [...] was reading Jason Seifer’s: Offline Gem Server Rdocs, which is an apache/passenger served Sinatra app that allows you to view the Rdocs of installed [...]

  4. Pretty docs for rubygems « Jabberwocky - 01. Dec, 2009

    [...] Pretty docs for rubygems Posted in Uncategorized by elisehuard on December 1, 2009 Tip I got through my colleague Bart Duchesne: to have nicer templates for the rubygem documentation, you can use templates. Mislav’s Hanna templates are pretty decent (way better than the default ones anyway). Howto (updated from this site): [...]

  5. Ed Schmalzle » Blog Archive » My RDoc Setup - 09. Mar, 2010

    [...] I wouldn’t have an always on internet connection to get my documentation fix. I recalled a post by Jason Seifer I had seen that described how to generate your docs with a better template and host [...]

  6. Mac OS X Post Install Guide, May 2010 | Jason Seifer - 10. May, 2010

    [...] rack apps can easily be hosted with Passenger Pane. Then you can also set up your rdocs for local viewing without using gem server. The instructions in the article still work, you just need to keep an old [...]

Leave a Reply