Documentation from inside irb

Hi,

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

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

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

···

On Thu, Jul 22, 2010 at 10:08:23PM +0900, Eugen Ciur wrote:

Hi,

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

>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

--
Daniel Bye
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and X
                                - proprietary attachments in e-mail / \

Eugen Ciur wrote:

Hi,

is there a way to call ri documentation from irb ?

If you just want to access ri within irb then this would do in your
.irbrc:

   def help(*args); system('ri', *args); end

If you want a smarter ri, see
http://eigenclass.org/hiki/irb+ri+completion and
Tagaholic - Page Irb Output And Improve Ri With Hirb
.

As for an improvement on irb's autocompletion, see bond -

Gabriel

···

--
Posted via http://www.ruby-forum.com/\.

Eugen Ciur wrote:

Hi,

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

>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
$ irb

require 'rubygems'
require 'ri_for'
IO.ri_for :open

sig: 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

···

--
Posted via http://www.ruby-forum.com/\.

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

···

On 07/22/2010 04:21 PM, Daniel Bye wrote:

On Thu, Jul 22, 2010 at 10:08:23PM +0900, Eugen Ciur wrote:
   

Hi,

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

>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
     

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

--
Eugen Ciur
Research& Development Team, PrimeTel PLC
Tel: +(357)25867145
skype ID: eugen_pt

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
irb(main):008:0> hel 'String'
<ri help here>
=> true

···

from :0

On 07/23/2010 10:48 AM, Gabriel Horner wrote:

Eugen Ciur wrote:
   

Hi,

is there a way to call ri documentation from irb ?
     

If you just want to access ri within irb then this would do in your
.irbrc:

    def help(*args); system('ri', *args); end

If you want a smarter ri, see
http://eigenclass.org/hiki/irb+ri+completion and
Tagaholic - Page Irb Output And Improve Ri With Hirb
.

As for an improvement on irb's autocompletion, see bond -
GitHub - cldwalker/bond: Mission: Easy custom autocompletion for arguments, methods and beyond. Accomplished for irb and any other readline-like console environments.

Gabriel

Eugen Ciur wrote:

wow, it has even tab completion!

that's easy to get, even without wirble; just:

    require 'irb/completion'

···

--
G.

--
Posted via http://www.ruby-forum.com/\.