Incorporating gem documentation into ri


#1

Guys,

I’d like to incorporation the various gem rdocs into ri, so that I am
not forced to use gem_server to view the documentation. I’ve found old
posts on this subject but nothing conclusive. Surely there is a way to
do this?

Any help you can provide is greatly appreciated.

Thanks!
John


#2

John W. wrote:

Guys,

I’d like to incorporation the various gem rdocs into ri, so that I am
not forced to use gem_server to view the documentation. I’ve found old
posts on this subject but nothing conclusive. Surely there is a way to
do this?

Any help you can provide is greatly appreciated.

I believe you can run rdoc -r … over the gem’s source code, and it
will add the docs to your ri data set.

Warning: If the gem code defines methods on core classes then your base
ri data source could get munged. Ri is not really designed for arbitrary
additions.

(I hope I’m wrong about this, but my last experience was running rdoc -r
over the standard lib source, and ending up with broken core docs
because some code had added or redefined methods in Array, String, and
so on.)


James B.

“Blanket statements are over-rated”


#3

On Jan 27, 2006, at 14:43, James B. wrote:

Warning: If the gem code defines methods on core classes then your
base ri data source could get munged. Ri is not really designed for
arbitrary additions.

(I hope I’m wrong about this, but my last experience was running
rdoc -r over the standard lib source, and ending up with broken
core docs because some code had added or redefined methods in
Array, String, and so on.)

Possibly you didn’t use the --merge and --ri-system or --ri-site
options?

Dave


#4

Dave T. wrote:

because some code had added or redefined methods in Array, String,
and so on.)

Possibly you didn’t use the --merge and --ri-system or --ri-site options?

Could be.

James


#5

On Jan 28, 2006, at 6:32 AM, John W. wrote:

Thanks guys. When I try doing this (), it goes on for awhile and then
hits this:

rrails-1.0.0/lib/rails_generator/generators/components/controller/
templates/controller.rb:3:15:
Expected class name or ‘<<’. Got RubyToken::TkLT: “<”

Then it just sits there…never completing.

Any idea what might be causing this?

RDoc looks for RDoc in .rb files. Since that file is not a ruby
file, RDoc needs to be told not to attempt to scan it.

For the Rails gem, the Rakefile tells RDoc not to scan this file.
You should follow its wisdom.

The other way to prevent/include files in RDoc’s search is
with .document files containing the names of files and paths to
document.


Eric H. - removed_email_address@domain.invalid - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com


#6

Eric H. wrote:

rrails-1.0.0/lib/rails_generator/generators/components/controller/
templates/controller.rb:3:15:
Expected class name or ‘<<’. Got RubyToken::TkLT: “<”

Then it just sits there…never completing.

Any idea what might be causing this?

RDoc looks for RDoc in .rb files. Since that file is not a ruby
file, RDoc needs to be told not to attempt to scan it.

For the Rails gem, the Rakefile tells RDoc not to scan this file.
You should follow its wisdom.

The other way to prevent/include files in RDoc’s search is
with .document files containing the names of files and paths to
document.

Hmmm…you’re right…this doesn’t look like a true Ruby file, although
it’ll be difficult to filter it out because of it’s .rb extension.

How does the Rakefile know what to scan and what not? I guess that’ll be
my next area of research. Would it be easier to modify gem itself to do
this task? Perhaps this should be a candidate for inclusion as an option
to gem?

Thanks!
John


#7

Thanks guys. When I try doing this (), it goes on for awhile and then
hits this:

rrails-1.0.0/lib/rails_generator/generators/components/controller/templates/controller.rb:3:15:
Expected class name or ‘<<’. Got RubyToken::TkLT: “<”

Then it just sits there…never completing.

Any idea what might be causing this?

Thanks!
John


#8

Hmmm…you’re right…this doesn’t look like a true Ruby file, although
it’ll be difficult to filter it out because of it’s .rb extension.

How does the Rakefile know what to scan and what not? I guess that’ll be
my next area of research. Would it be easier to modify gem itself to do
this task? Perhaps this should be a candidate for inclusion as an option
to gem?
Success!

Apparently, someone had already thought of doing this and didn’t, as
evidenced by the following lines in rubygems/doc_manager.rb:

#TODO: Why is this throwing an error?
#ri = RDoc::RDoc.new
#ri.document([’-R’] + source_dirs)

Anyway, I was successful…I’ll look at making this more integrated and
submitting as a patch, but for the quick hack all it took was changing
the following line (58 in my version):

r.document([’–quiet’, ‘–op’, rdoc_dir] + @rdoc_args.flatten +
source_dirs)

to:

r.document([’–quiet’, ‘–op’, ‘–merge’, ‘-r’, ‘–ri-system’, rdoc_dir]

  • @rdoc_args.flatten + source_dirs)

It worked perfectly…all Rails classes, etc, are now in ri.

Thanks guys!

John