# Ruby gems doc indexer

**URL:** <https://rubytalk.org/t/ruby-gems-doc-indexer/47580>\
**Category:** ruby-talk\
**Created:** [7 July 2008 21:44 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580 "2008-07-07T21:44:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [7 July 2008 21:44 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/1 "2008-07-07T21:44:03Z")

</div>

Don't know if this would be useful for anyone, but I wrote a utility to  
create an html index of the rdoc's of installed rubygems on your system.

I.e.  
ruby gem\_rdoc\_indexer.rb

creates file all\_gems\_rdocs.html  
with contents

> **···**
>
> ---------------
> 
> All installed gems: (core)
> 
> abstract-1.0.0: homepage (no rdoc)
> 
> actionmailer-1.3.3: homepage rdoc README  
> ....  
> with links to the rdoc's and README's.
> 
> example output file:  
> [http://ruby-roger-useful-functions.googlecode.com/svn/trunk/gem\_rdocs\_indexer/all\_gems\_rdocs\_index.html](http://ruby-roger-useful-functions.googlecode.com/svn/trunk/gem_rdocs_indexer/all_gems_rdocs_index.html)
> 
> how to get:
> 
> code:  
> [http://ruby-roger-useful-functions.googlecode.com/svn/trunk/gem\_rdocs\_indexer/gem\_rdoc\_indexer.rb](http://ruby-roger-useful-functions.googlecode.com/svn/trunk/gem_rdocs_indexer/gem_rdoc_indexer.rb)
> 
> Any feedback welcome.
> 
> Question: is there a designated place where rdoc's for the core lib's  
> are installed, locally?
> 
> Also, is it possible to get the specs for say version 1.0 of a gem, and  
> also the specs for version 2.0? Currently this isn't handled perfectly.
> 
> Thanks!
> 
> -R  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [7 July 2008 22:08 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/2 "2008-07-07T22:08:19Z")

</div>

Roger Pack wrote:

> Don't know if this would be useful for anyone, but I wrote a utility to  
> create an html index of the rdoc's of installed rubygems on your system.

Nice to have direct links to the home page, as well as local docs. That's a missing feature in my own indexer, but I like the table in mine. (Yes, I know about gem server.) Feel free to adapt from the following (which I run every so often after updating gems). The title field is not very useful, because most rdoc users don't know about that option.

require "amrita/template"  
include Amrita

Dir.chdir "/usr/local/lib/ruby/gems/1.8/doc"

tmpl = TemplateText.new \<\<END  
\<title\>Gem Docs\</title\>  
\<table border="1"\>  
&nbsp;&nbsp;&nbsp;\<tr\>\<th\>Name\</th\>\<th\>Title\</th\>\<th\>Gem Docs\</tr\>  
&nbsp;&nbsp;&nbsp;\<tr id=table1\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td id="name"\>\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td id="title"\>\</td\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<a id="gemdocs"\>\</a\>\</td\>  
&nbsp;&nbsp;&nbsp;\</tr\>  
\</table\>  
END

links = Dir['\*/rdoc/index.html']

linkdata = links.sort\_by{|s|s.downcase}.map do |link|  
&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:name =\> link[/(.\*?)\//,1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:title =\> File.open(link).grep(/\<title\>/)[0][/\<title\>(.\*?)\<\/title\>/,1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:gemdocs =\> a(:href=\>link) { link }  
&nbsp;&nbsp;&nbsp;}  
end

data = {  
&nbsp;&nbsp;&nbsp;&nbsp;:table1 =\> linkdata  
}

tmpl.prettyprint = true  
tmpl.expand(File.open("index.html", "w"), data)

puts "rebuilding fast-ri index..."  
system "fastri-server -Bb"  
puts "done"

> **···**
>
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [7 July 2008 22:18 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/3 "2008-07-07T22:18:14Z")

</div>

How is this different from running `gem server` and navigating to that URL in your browser?

> **···**
>
> On Jul 7, 2008, at 14:44 PM, Roger Pack wrote:
> 
> > Don't know if this would be useful for anyone, but I wrote a utility to  
> > create an html index of the rdoc's of installed rubygems on your system.

---

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [7 July 2008 22:27 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/4 "2008-07-07T22:27:57Z")

</div>

Eric Hodel wrote:

> > Don't know if this would be useful for anyone, but I wrote a utility  
> > to  
> > create an html index of the rdoc's of installed rubygems on your  
> > system.
> 
> How is this different from running `gem server` and navigating to that  
> URL in your browser?

In all honesty, I didn't know gem server existed, and, also honestly, it  
didn't make sense for me that gem server would be necessary for browsing  
an index of rdoc's.

My 'wish' would be something like this run automatically after  
installing new rdoc's:

gem install package  
...  
package installed  
updated index gem\_rdoc\_index.html

It just makes more sense than having to run a server to browse rdoc's.  
Thoughts?  
I'd be happy to code it up as a patch 🙂

-R

> **···**
>
> > On Jul 7, 2008, at 14:44 PM, Roger Pack wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [7 July 2008 22:31 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/5 "2008-07-07T22:31:49Z")

</div>

Eric Hodel wrote:

> **···**
>
> > On Jul 7, 2008, at 14:44 PM, Roger Pack wrote:
> > 
> > > Don't know if this would be useful for anyone, but I wrote a utility to  
> > > create an html index of the rdoc's of installed rubygems on your system.
> > 
> > How is this different from running `gem server` and navigating to that URL in your browser?
> 
> 20Mb of RSS to serve one static page.
> 
> Yeah, ok, some people sneeze in 20Mb chunks.
> 
> I do like the look of the gem server page (has it changed recently?). Why can't this be generated to some file after every gem update?
> 
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

---

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [7 July 2008 22:33 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/6 "2008-07-07T22:33:43Z")

</div>

> > How is this different from running `gem server` and navigating to that  
> > URL in your browser?
> 
> In all honesty, I didn't know gem server existed, and, also honestly, it  
> didn't make sense for me that gem server would be necessary for browsing  
> an index of rdoc's.

Also it has a link to the README, which is nice. Typically maintainers  
show their README in the rdoc's index with their own rdoc's, but don't  
set it up that way for the gem, for some reason.

-R

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [8 July 2008 18:19 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/7 "2008-07-08T18:19:23Z")

</div>

`gem server` is already a well-known way to access documentation. It provides a --daemon option so you can start it and forget about it. (It updates itself as new gems are installed.)

This is an entirely new way of accessing the same information that isn't going to be well-known. Furthermore, the path to this file is either going to be in an obscure location to support multiple users, or only accessible by one user.

I don't want to maintain two different ways of accessing the same information.

> **···**
>
> On Jul 7, 2008, at 15:27 PM, Roger Pack wrote:
> 
> > Eric Hodel wrote:
> > 
> > > On Jul 7, 2008, at 14:44 PM, Roger Pack wrote:
> > > 
> > > > Don't know if this would be useful for anyone, but I wrote a utility  
> > > > to create an html index of the rdoc's of installed rubygems on your  
> > > > system.
> > > 
> > > How is this different from running `gem server` and navigating to that  
> > > URL in your browser?
> > 
> > In all honesty, I didn't know gem server existed, and, also honestly, it  
> > didn't make sense for me that gem server would be necessary for browsing  
> > an index of rdoc's.
> > 
> > My 'wish' would be something like this run automatically after  
> > installing new rdoc's:
> > 
> > gem install package  
> > ...  
> > package installed  
> > updated index gem\_rdoc\_index.html
> > 
> > It just makes more sense than having to run a server to browse rdoc's.
> > 
> > Thoughts?  
> > I'd be happy to code it up as a patch 🙂

---

<div class="post-metadata">

**Author:** ![Vince\_Angeloni](https://avatars.discourse-cdn.com/v4/letter/v/49beb7/32.png) [@Vince\_Angeloni](https://rubytalk.org/u/Vince_Angeloni)\
**Post date:** [9 July 2008 01:03 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/8 "2008-07-09T01:03:36Z")

</div>

Eric Hodel wrote:

> This is an entirely new way of accessing the same information that  
> isn't going to be well-known. Furthermore, the path to this file is  
> either going to be in an obscure location to support multiple users,  
> or only accessible by one user.
> 
> I don't want to maintain two different ways of accessing the same  
> information.

For the single user at home, this is an ideal solution. I have no desire  
to use gem server just to view RDOCs. Robert, your code works like  
a charm and I think it is extremely useful. Thanks so much for sharing.

vince

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [9 July 2008 03:12 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/9 "2008-07-09T03:12:09Z")

</div>

> `gem server` is already a well-known way to access documentation. It  
> provides a --daemon option so you can start it and forget about it.  
> (It updates itself as new gems are installed.)

Yeah that works too. Either way is fine. My personal preference is the  
more light weight one. If it were up to me I'd deprecate the server and  
go more in that direction.  
But that's just me.

Some clarifying thoughts:  
Twould be nice to have a link there to the code itself, as well as the  
rdoc's [for perusal], and the README's. And to the normal rdoc's for  
ruby should they happen to be installed.  
Thanks!  
-R

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Jeremy\_McAnally1](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jeremy\_McAnally1](https://rubytalk.org/u/Jeremy_McAnally1)\
**Post date:** [9 July 2008 01:30 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/10 "2008-07-09T01:30:03Z")

</div>

You do realize that gem server that serves up the docs is just a  
simple WEBrick server right? I use it all the time. It's super  
simple to crank up and kill off.

But to each his own. 🙂

--Jeremy

> **···**
>
> On Tue, Jul 8, 2008 at 8:03 PM, Vince Angeloni \<nospam7272@mac.com\> wrote:
> 
> > Eric Hodel wrote:
> > 
> > > This is an entirely new way of accessing the same information that  
> > > isn't going to be well-known. Furthermore, the path to this file is  
> > > either going to be in an obscure location to support multiple users,  
> > > or only accessible by one user.
> > > 
> > > I don't want to maintain two different ways of accessing the same  
> > > information.
> > 
> > For the single user at home, this is an ideal solution. I have no desire  
> > to use gem server just to view RDOCs. Robert, your code works like  
> > a charm and I think it is extremely useful. Thanks so much for sharing.
> > 
> > vince  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
> 
> --  
> [http://jeremymcanally.com/](http://jeremymcanally.com/)  
> [http://entp.com](http://entp.com)
> 
> Read my books:  
> Ruby in Practice ([http://manning.com/mcanally/\](http://manning.com/mcanally/%5C))  
> My free Ruby e-book ([http://humblelittlerubybook.com/\](http://humblelittlerubybook.com/%5C))
> 
> Or, my blogs:
> 
> > **[Site not found · DreamHost](http://mrneighborly.com)**
> >
> > The owner of this domain has not yet uploaded their website.
> 
> [http://rubyinpractice.com](http://rubyinpractice.com)

---

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [26 September 2008 20:32 UTC](https://rubytalk.org/t/ruby-gems-doc-indexer/47580/11 "2008-09-26T20:32:57Z")

</div>

> Some clarifying thoughts:  
> Twould be nice to have a link there to the code itself, as well as the  
> rdoc's [for perusal], and the README's. And to the normal rdoc's for  
> ruby should they happen to be installed.

Twould be nice to have some access to any existing 'changelog', too,  
from gem server, and also to the unpacked gem files themselves [which  
would satisfy that]. Not sure if that's possible.  
-=R

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
