browsing gem docs

  • Thread starter Joel VanderWerf
  • Start date
J

Joel VanderWerf

This little script generates a simple web page containing a table of
(name, title, link-to-rdocs) for each installed gem. Could something
like this be incorporated into gem so that each time a gem is installed
you get a nice links page?


#!/usr/bin/env ruby

require "amrita/template"
include Amrita

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

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

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

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

data = {
:table1 => linkdata
}

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

Joel VanderWerf

Stoyan said:
from your shell. By default it listen on port 8808 (try
http://machine.with.gems:8808/ in
your browser)

Very nice, but why does it depend on a web server? It's just a static
page, AFAICT. Does it do something more?

I'd really just like to have a bookmark in my browser so I can quickly
go to all my installed gem docs. Running a server to do that seems a
little excessive....

But at least now I realize I should have used gemspec files as input
rather than regexes.
 
C

Chad Fowler

=20
Very nice, but why does it depend on a web server? It's just a static
page, AFAICT. Does it do something more?
=20
I'd really just like to have a bookmark in my browser so I can quickly
go to all my installed gem docs. Running a server to do that seems a
little excessive....
=20
But at least now I realize I should have used gemspec files as input
rather than regexes.
=20

Hi! Nice script! You're right that a static doc page would be a good feat=
ure.

gem_server also allows you to serve gems (not just docs), so you can
use a gem_server as a remote gem source. That's why the web server is
there.

I'll add the static docs links page to the TODO list.

--=20
Chad Fowler
http://chadfowler.com
http://rubycentral.org=20
http://rubygarden.org=20
http://rubygems.rubyforge.org (over 700,000 gems served!)
 
J

Joel VanderWerf

Chad said:
gem_server also allows you to serve gems (not just docs), so you can
use a gem_server as a remote gem source. That's why the web server is
there.

AH, great! The remote gem source functionality is something I remember
asking for a while back. Thanks!
I'll add the static docs links page to the TODO list.

Ok, low priority for me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top