# Incorporating gem documentation into ri

**URL:** <https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189>\
**Category:** Ruby\
**Created:** [January 27, 2006, 10:30pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189 "2006-01-27T22:30:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 27, 2006, 10:30pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/1 "2006-01-27T22:30:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 27, 2006, 11:45pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/2 "2006-01-27T23:45:31Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 28, 2006, 8:27am UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/3 "2006-01-28T08:27:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 28, 2006, 8:45am UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/4 "2006-01-28T08:45:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 30, 2006, 2:13am UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/5 "2006-01-30T02:13:18Z")

</div>

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](http://segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 30, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/6 "2006-01-30T14:40:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 28, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/7 "2006-01-28T15:31:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 30, 2006, 3:03pm UTC](https://www.ruby-forum.com/t/incorporating-gem-documentation-into-ri/53189/8 "2006-01-30T15:03:38Z")

</div>

> 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
