Forum: Ruby Incorporating gem documentation into ri

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F8fd54072606eaf5603484e756672034?d=identicon&s=25 John Wells (Guest)
on 2006-01-27 22:30
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
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-01-27 23:45
(Received via mailing list)
John Wells 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 Britt

"Blanket statements are over-rated"
5d06917e13b29bcff1c1609492c06873?d=identicon&s=25 Dave Thomas (Guest)
on 2006-01-28 08:27
(Received via mailing list)
On Jan 27, 2006, at 14:43, James Britt 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
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-01-28 08:45
(Received via mailing list)
Dave Thomas 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
F8fd54072606eaf5603484e756672034?d=identicon&s=25 John Wells (Guest)
on 2006-01-28 15:31
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
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-01-30 02:13
(Received via mailing list)
On Jan 28, 2006, at 6:32 AM, John Wells 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 Hodel - drbrain@segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
F8fd54072606eaf5603484e756672034?d=identicon&s=25 John Wells (Guest)
on 2006-01-30 14:40
Eric Hodel 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
F8fd54072606eaf5603484e756672034?d=identicon&s=25 John Wells (Guest)
on 2006-01-30 15:03
> 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
This topic is locked and can not be replied to.