[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] IHelp 0.2.0

Ilmari Heikkinen

1/16/2005 8:46:00 PM

URL: http://fhtr.org/proje...

Download:
=========

Release: http://fhtr.org/proje...releases/ihelp-0.2.0.tar.gz
Darcs repo: http://dark.fhtr.org/re...


IHelp README
============

The IHelp (Interactive Help) package provides contextual help for
objects and methods by using ri.


Usage
-----

Example:

require 'ihelp'

12.help
"string".help :reverse # cute syntax - "string".help:reverse
Array.help :map
help "Array#map"

# and, after generating ri docs for this (rdoc --ri ihelp/):
IHelp.help


To load IHelp automatically with irb, add the following to your
irbrc:
require 'ihelp'

If you think it makes the irb startup too slow, load it in a thread:
Thread.new{ require 'ihelp' }

But note that calling help will fail before it's completely loaded.


See also
--------

ri --help
rdoc --help
ruby --help

The ruby-doc.org Ruby documentation project: http://www.rub...
Pickaxe book: http://www.rub...find/pickaxe
Why's (Poignant) Guide to Ruby: http://poignantguide...


Requirements
------------

* Ruby 1.8
* generated ri documentation


Install
-------

De-compress archive and enter its top directory.
Then type:

($ su)
# ruby setup.rb

These simple step installs this program under the default
location of Ruby libraries. You can also install files into
your favorite directory by supplying setup.rb some options.
Try "ruby setup.rb --help".


License
-------

Ruby's


Ilmari Heikkinen <kig misfiring net>



10 Answers

Gennady

1/18/2005 12:23:00 AM

0

I did not see any reaction to this announcement yet, so I will be the
first one. It works great for me, being the best integration between irb
and ri in my opinion. Much better than Python's docstrings ;-), again IMHO.

The nice thing about it is that you turn it on when you need it, no
overhead otherwise.

Thanks a lot, Ilmari !!!

Gennady.

Ilmari Heikkinen wrote:
> URL: http://fhtr.org/proje...
>
> Download:
> =========
>
> Release: http://fhtr.org/proje...releases/ihelp-0.2.0.tar.gz
> Darcs repo: http://dark.fhtr.org/re...
>
>
> IHelp README
> ============
>
> The IHelp (Interactive Help) package provides contextual help for
> objects and methods by using ri.
>
>
> Usage
> -----
>
> Example:
>
> require 'ihelp'
>
> 12.help
> "string".help :reverse # cute syntax - "string".help:reverse
> Array.help :map
> help "Array#map"
>
> # and, after generating ri docs for this (rdoc --ri ihelp/):
> IHelp.help
>
>
> To load IHelp automatically with irb, add the following to your .irbrc:
> require 'ihelp'
>
> If you think it makes the irb startup too slow, load it in a thread:
> Thread.new{ require 'ihelp' }
>
> But note that calling help will fail before it's completely loaded.
>
>
> See also
> --------
>
> ri --help
> rdoc --help
> ruby --help
>
> The ruby-doc.org Ruby documentation project: http://www.rub...
> Pickaxe book: http://www.rub...find/pickaxe
> Why's (Poignant) Guide to Ruby: http://poignantguide...
>
>
> Requirements
> ------------
>
> * Ruby 1.8
> * generated ri documentation
>
>
> Install
> -------
>
> De-compress archive and enter its top directory.
> Then type:
>
> ($ su)
> # ruby setup.rb
>
> These simple step installs this program under the default
> location of Ruby libraries. You can also install files into
> your favorite directory by supplying setup.rb some options.
> Try "ruby setup.rb --help".
>
>
> License
> -------
>
> Ruby's
>
>
> Ilmari Heikkinen <kig misfiring net>
>
>



Ilmari Heikkinen

1/18/2005 1:35:00 AM

0


On 18.1.2005, at 02:22, Gennady Bystritksy wrote:

> I did not see any reaction to this announcement yet, so I will be the
> first one. It works great for me, being the best integration between
> irb and ri in my opinion. Much better than Python's docstrings ;-),
> again IMHO.
>
> The nice thing about it is that you turn it on when you need it, no
> overhead otherwise.
>
> Thanks a lot, Ilmari !!!
>
> Gennady.

Thank you very much for trying it out! And if you find any problems,
let me know, please.

--
Ilmari Heikkinen



Brian McCallister

1/18/2005 2:30:00 AM

0

I get

irb(main):001:0> require 'ihelp'

unrecognized option `--readline'

For help on options, try 'ri --help'

brianm@kite:~/work/ihelp-0.2.0$

I suspect stemming from my .irbrc which looks like:

require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]

IRB.conf[:AUTO_INDENT] = true

def ri(*names)
system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
end


When i comment out the ARGV additions it works fine.

-Brian

On Jan 16, 2005, at 3:46 PM, Ilmari Heikkinen wrote:

> URL: http://fhtr.org/proje...
>
> Download:
> =========
>
> Release: http://fhtr.org/proje...releases/ihelp-0.2.0.tar.gz
> Darcs repo: http://dark.fhtr.org/re...
>
>
> IHelp README
> ============
>
> The IHelp (Interactive Help) package provides contextual help for
> objects and methods by using ri.
>
>
> Usage
> -----
>
> Example:
>
> require 'ihelp'
>
> 12.help
> "string".help :reverse # cute syntax - "string".help:reverse
> Array.help :map
> help "Array#map"
>
> # and, after generating ri docs for this (rdoc --ri ihelp/):
> IHelp.help
>
>
> To load IHelp automatically with irb, add the following to your
> .irbrc:
> require 'ihelp'
>
> If you think it makes the irb startup too slow, load it in a thread:
> Thread.new{ require 'ihelp' }
>
> But note that calling help will fail before it's completely loaded.
>
>
> See also
> --------
>
> ri --help
> rdoc --help
> ruby --help
>
> The ruby-doc.org Ruby documentation project: http://www.rub...
> Pickaxe book: http://www.rub...find/pickaxe
> Why's (Poignant) Guide to Ruby: http://poignantguide...
>
>
> Requirements
> ------------
>
> * Ruby 1.8
> * generated ri documentation
>
>
> Install
> -------
>
> De-compress archive and enter its top directory.
> Then type:
>
> ($ su)
> # ruby setup.rb
>
> These simple step installs this program under the default
> location of Ruby libraries. You can also install files into
> your favorite directory by supplying setup.rb some options.
> Try "ruby setup.rb --help".
>
>
> License
> -------
>
> Ruby's
>
>
> Ilmari Heikkinen <kig misfiring net>
>
>
>



Brian McCallister

1/18/2005 2:32:00 AM

0

btw -- REALLY NICE!

=)

On Jan 17, 2005, at 9:30 PM, Brian McCallister wrote:

> I get
>
> irb(main):001:0> require 'ihelp'
>
> unrecognized option `--readline'
>
> For help on options, try 'ri --help'
>
> brianm@kite:~/work/ihelp-0.2.0$
>
> I suspect stemming from my .irbrc which looks like:
>
> require 'irb/completion'
> ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
>
> IRB.conf[:AUTO_INDENT] = true
>
> def ri(*names)
> system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
> end
>
>
> When i comment out the ARGV additions it works fine.
>
> -Brian
>
> On Jan 16, 2005, at 3:46 PM, Ilmari Heikkinen wrote:
>
>> URL: http://fhtr.org/proje...
>>
>> Download:
>> =========
>>
>> Release: http://fhtr.org/proje...releases/ihelp-0.2.0.tar.gz
>> Darcs repo: http://dark.fhtr.org/re...
>>
>>
>> IHelp README
>> ============
>>
>> The IHelp (Interactive Help) package provides contextual help for
>> objects and methods by using ri.
>>
>>
>> Usage
>> -----
>>
>> Example:
>>
>> require 'ihelp'
>>
>> 12.help
>> "string".help :reverse # cute syntax - "string".help:reverse
>> Array.help :map
>> help "Array#map"
>>
>> # and, after generating ri docs for this (rdoc --ri ihelp/):
>> IHelp.help
>>
>>
>> To load IHelp automatically with irb, add the following to your
>> .irbrc:
>> require 'ihelp'
>>
>> If you think it makes the irb startup too slow, load it in a thread:
>> Thread.new{ require 'ihelp' }
>>
>> But note that calling help will fail before it's completely loaded.
>>
>>
>> See also
>> --------
>>
>> ri --help
>> rdoc --help
>> ruby --help
>>
>> The ruby-doc.org Ruby documentation project:
>> http://www.rub...
>> Pickaxe book: http://www.rub...find/pickaxe
>> Why's (Poignant) Guide to Ruby: http://poignantguide...
>>
>>
>> Requirements
>> ------------
>>
>> * Ruby 1.8
>> * generated ri documentation
>>
>>
>> Install
>> -------
>>
>> De-compress archive and enter its top directory.
>> Then type:
>>
>> ($ su)
>> # ruby setup.rb
>>
>> These simple step installs this program under the default
>> location of Ruby libraries. You can also install files into
>> your favorite directory by supplying setup.rb some options.
>> Try "ruby setup.rb --help".
>>
>>
>> License
>> -------
>>
>> Ruby's
>>
>>
>> Ilmari Heikkinen <kig misfiring net>
>>
>>
>>
>
>
>



Ilmari Heikkinen

1/18/2005 4:55:00 AM

0


On 18.1.2005, at 04:30, Brian McCallister wrote:

> I get
>
> irb(main):001:0> require 'ihelp'
>
> unrecognized option `--readline'
>
> For help on options, try 'ri --help'
>
> brianm@kite:~/work/ihelp-0.2.0$
>
> I suspect stemming from my .irbrc which looks like:
>
> require 'irb/completion'
> ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
>
> IRB.conf[:AUTO_INDENT] = true
>
> def ri(*names)
> system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
> end
>
>
> When i comment out the ARGV additions it works fine.

Thank you, that's a good catch.

The problem is in IHelp using RiDriver carelessly --
RiDriver#initialize uses ARGV for its options.

Subclassed it to redefine #initialize to take the
options as a parameter. (And added ARGV to test unit setup.)

Could you try the following and see if it works better now?

http://dark.fhtr.org/repos/ihelp/li...

--
Ilmari Heikkinen



Piergiuliano Bossi

1/18/2005 12:55:00 PM

0

Ilmari Heikkinen wrote:
> If you think it makes the irb startup too slow, load it in a thread:
> Thread.new{ require 'ihelp' }
>
> But note that calling help will fail before it's completely loaded.

Sorry, but loading it in a separate thread doesn't work under windows
(neither 0.1):

irb(main):001:0> "".help
NoMethodError: undefined method `help' for "":String
from (irb):1
from
c:/apps/ruby18/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:
5
irb(main):002:0> Time.new
=> Tue Jan 18 13:41:19 W. Europe Standard Time 2005
irb(main):003:0> Time.new
=> Tue Jan 18 13:50:51 W. Europe Standard Time 2005
irb(main):004:0> "".help
NoMethodError: undefined method `help' for "":String
from (irb):4
from
c:/apps/ruby18/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:
5
irb(main):005:0>

Note that I have only
Thread.new { require 'ihelp' }
in .irbrc therefore 9 minutes should be enough to load, shouldn't they? :)

Btw, which differences since 0.1 apart from setup?

Thx
Giuliano

--
If you want to send me an email address should be 'p', then a dot,
followed by 'bossi' at 'quinary', another dot and 'com' at last

Ilmari Heikkinen

1/19/2005 2:52:00 AM

0


On 18.1.2005, at 14:56, Piergiuliano Bossi wrote:

> Ilmari Heikkinen wrote:
>> If you think it makes the irb startup too slow, load it in a thread:
>> Thread.new{ require 'ihelp' }
>> But note that calling help will fail before it's completely loaded.
>
> Sorry, but loading it in a separate thread doesn't work under windows
> (neither 0.1):
>
> [snip]
> Note that I have only
> Thread.new { require 'ihelp' }
> in .irbrc therefore 9 minutes should be enough to load, shouldn't
> they? :)
>

Yes it definitely should.
I don't know why it doesn't work, sorry :(

I wonder why it doesn't work... Guess I'll boot to windows tomorrow and
find out.
Better not load it in a thread for the time being ;)

> Btw, which differences since 0.1 apart from setup?
>

Not much external changes, apart from working around that TypeError
exception ri started raising in 1.8.2.

Refactored code, changed the name, rewrote documentation, added tests,
fixed bugs.

Now I have 0.3.0 candidate in the darcs repo, which separates the code
more from the ri cmdline tool and has changable help renderers. I have
a simple alternative handler there that opens the ruby-doc.org class
doc in a web browser (on osx), it merely grabs the class name and puts
it in the url, calls the osx `open`-cmd, and is around 5 lines of code.

--
Ilmari Heikkinen (is going through version numbers way too fast)



Piergiuliano Bossi

1/19/2005 5:12:00 PM

0

Hello, just a brief note in order to detail it a little bit more.
I have 2 machines, both with Win2000 PRO, SP4.

The former has ruby 1.8.2-RC10 (I guess, not final). In any case:

C:\>ruby -v
ruby 1.8.2 (2004-11-06) [i386-mswin32]

Under this platform, error is found by loadpath_manager in rubygems:

irb(main):001:0> "".help
NoMethodError: undefined method `help' for "":String
from (irb):1
from
c:/apps/ruby18/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5

Please note that I have installed at least 1 gem (extensions).


The latter has a fresh ruby 1.8.2 installation:

C:\>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]

As you can see error here is found by a different source:

irb(main):001:0> "".help
NoMethodError: undefined method `help' for "":String
from (irb):1
from c:/apps/ruby18/lib/ruby/1.8/yaml/rubytypes.rb:2

I don't know if it matters, though.

Thanks anyway, I like it.
Giuliano

Ilmari Heikkinen wrote:
>
> On 18.1.2005, at 14:56, Piergiuliano Bossi wrote:
>
>> Ilmari Heikkinen wrote:
>>
>>> If you think it makes the irb startup too slow, load it in a thread:
>>> Thread.new{ require 'ihelp' }
>>> But note that calling help will fail before it's completely loaded.
>>
>>
>> Sorry, but loading it in a separate thread doesn't work under windows
>> (neither 0.1):
>>
>> [snip]
>> Note that I have only
>> Thread.new { require 'ihelp' }
>> in .irbrc therefore 9 minutes should be enough to load, shouldn't
>> they? :)
>>
>
> Yes it definitely should.
> I don't know why it doesn't work, sorry :(
>
> I wonder why it doesn't work... Guess I'll boot to windows tomorrow and
> find out.
> Better not load it in a thread for the time being ;)
>
>> Btw, which differences since 0.1 apart from setup?
>>
>
> Not much external changes, apart from working around that TypeError
> exception ri started raising in 1.8.2.
>
> Refactored code, changed the name, rewrote documentation, added tests,
> fixed bugs.
>
> Now I have 0.3.0 candidate in the darcs repo, which separates the code
> more from the ri cmdline tool and has changable help renderers. I have a
> simple alternative handler there that opens the ruby-doc.org class doc
> in a web browser (on osx), it merely grabs the class name and puts it in
> the url, calls the osx `open`-cmd, and is around 5 lines of code.
>
> --
> Ilmari Heikkinen (is going through version numbers way too fast)
>
>
>

--
If you want to send me an email address should be 'p', then a dot,
followed by 'bossi' at 'quinary', another dot and 'com' at last

Csaba Henk

1/23/2005 11:50:00 AM

0

On 2005-01-16, Ilmari Heikkinen <kig@misfiring.net> wrote:
> The IHelp (Interactive Help) package provides contextual help for
> objects and methods by using ri.

That's great, I've just been whining about ruby lacking docstrings, it's
just takes us as close to that as possible! Thanks!

Is there a way to get the formatted help (in either format), without
superflouos conversions?

I could do

rio=IHelp.ri_driver.instance_variable_get(:@options)
rio.use_stdout=true

and then maybe I could capture the output somehow, but that's a bit too
much hack. (I want things like concatenating various help informations,
like the help for all the String methods.)

Regards,
Csaba

Ilmari Heikkinen

1/23/2005 10:40:00 PM

0

Hi, thanks for the feedback :)

On 23.1.2005, at 14:00, Csaba Henk wrote:

> Is there a way to get the formatted help (in either format), without
> superflouos conversions?
>
> I could do
>
> rio=IHelp.ri_driver.instance_variable_get(:@options)
> rio.use_stdout=true
>
> and then maybe I could capture the output somehow, but that's a bit too
> much hack. (I want things like concatenating various help informations,
> like the help for all the String methods.)
>

Yes, I think it's possible.

Looked at what RI is doing, and it seems to me that this is the
simplest way to go (if there are any RDoc gurus reading this, please
tell if there's a better way.) And yes, it's a hack.

--
Ilmari Heikkinen