[ANN] IHelp 0.2.0

I

Ilmari Heikkinen

URL: http://fhtr.org/projects/ihelp/

Download:
=========

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


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.ruby-doc.org/
Pickaxe book: http://www.ruby-doc.org/find/pickaxe
Why's (Poignant) Guide to Ruby: http://poignantguide.net/ruby/


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>
 
G

Gennady Bystritksy

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.
 
I

Ilmari Heikkinen

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.
 
B

Brian McCallister

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
 
B

Brian McCallister

btw -- REALLY NICE!

=)

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

URL: http://fhtr.org/projects/ihelp/

Download:
=========

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


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.ruby-doc.org/
Pickaxe book: http://www.ruby-doc.org/find/pickaxe
Why's (Poignant) Guide to Ruby: http://poignantguide.net/ruby/


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>
 
I

Ilmari Heikkinen

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/lib/ihelp.rb
 
P

Piergiuliano Bossi

Ilmari said:
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
 
I

Ilmari Heikkinen

Ilmari said:
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.
 
P

Piergiuliano Bossi

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 said:
Ilmari said:
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.
 
C

Csaba Henk

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
 
I

Ilmari Heikkinen

--Apple-Mail-10--636226293
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

Hi, thanks for the feedback :)

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


--Apple-Mail-10--636226293
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="string_methods_help.rb"
Content-Disposition: attachment;
filename=string_methods_help.rb

require 'ihelp'
require 'stringio'
s = StringIO.new

# get the formatter
formatter = RI::Options.instance.formatter
# hack the formatter
[:puts, :print, :write].each{|method_name|
formatter.send:)define_method, method_name){|*args|
self.class.out.send(method_name, *args)
}
}
class << formatter; attr_accessor :eek:ut end

formatter.out = s
RI::Options.instance.use_stdout = true

# collect formatted help into s
String.methods.each{|m| String.help(m)}

RI::Options.instance.use_stdout = false
formatter.out = STDOUT

s.rewind
str = s.read
# display the big collected help doc
RI::Options.instance.displayer.instance_eval{ page{ puts str } }

--Apple-Mail-10--636226293--
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top