documentation from inside irb

E

Eugen Ciur

Hi,

is there a way to call ri documentation from irb ?
Something like:

shell>irb
irb(main):001:0> help inspect
NameError: undefined method `execute' for module `IRB::ExtendCommand::Help'
from (eval):4:in `instance_method'
from (eval):4:in `help'
from (irb):1
from /usr/lib/ruby/1.8/rubygems.rb:1016
 
E

Eugen Ciur

wow, it has even tab completion!
thank you Dan!

The wirble gem allows you to use ri from within irb sessions. It adds
various other fancy bits as well, which may or may not be interesting.

Dan
 
E

Eugen Ciur

Thank you!

Gabriel, the only remark is that if I leave method's name 'help' then
upon loading irb a warning is issued:

irb: warn: can't alias help from irb_help.

If 'help' will be renamed to something else, for example, 'hel', then
it is possible to call ri help from command line only if its arguments
will be quoted:

irb(main):007:0> hel String
TypeError: can't convert Class into String
from /home/eugen/.irbrc:3:in `system'
from /home/eugen/.irbrc:3:in `hel'
from (irb):7
from :0
irb(main):008:0> hel 'String'
<ri help here>
=> true
 
R

Roger Pack

Eugen said:
Hi,

is there a way to call ri documentation from irb ?
Something like:

shell>irb
irb(main):001:0> help inspect
NameError: undefined method `execute' for module
`IRB::ExtendCommand::Help'
from (eval):4:in `instance_method'
from (eval):4:in `help'
from (irb):1
from /usr/lib/ruby/1.8/rubygems.rb:1016

This is a bug in core and "should" work, really...

that being the case, here's my attempt at it:

$ gem install ri_for
$ irbsig: Kernel#open arity -1
appears to be a c method
Searching ri for
sig: Kernel#open arity -1
...


ri_for gives you more than just ri--it gives you the source code where
available, which turns out to be quite useful.
Cheers!
-r
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top