In Files

Parent

Files

IHelp::Renderer

Contains the help renderer methods to be used by IHelp#help. The help-method creates a new instance of Renderer and calls the method defined by IHelp.renderer with the RI info object.

Public Instance Methods

emacs(info) click to toggle source

XEmacs renderer. Uses ri-emacs to show the ri output in Emacs.

rubyforge.org/projects/ri-emacs/ www.rubyist.net/~rubikitch/computer/irbsh/index.en.html

# File lib/ihelp.rb, line 173
def emacs(info)
  system "gnudoit", %[(progn (ri "#{info.full_name}") "#{info.full_name}")]
end
html(info) click to toggle source
# File lib/ihelp.rb, line 177
def html(info)
  puts "Opening help for: #{info.full_name}"
  doc = REXML::Document.new
  root = doc.add_element("html")
  head = root.add_element("head")
  title = head.add_element("title")
  title.add_text("#{info.full_name} - RI Documentation")
  body = root.add_element("body")
  body.add_element(info.to_html.root)
  tmp = Tempfile.new("#{info.full_name.gsub(/\W/,"_")}_doc.html")
  tmp.write( doc.to_s(2) )
  tmp.flush
  pid = fork{
    system(IHelp.web_browser, "file://#{tmp.path}")
    tmp.close!
  }
  Process.detach(pid)
  pid
end
ri(info) click to toggle source

Default renderer method, opens the help using the IHelpDriver gotten from IHelp.ri_driver.

# File lib/ihelp.rb, line 138
def ri(info)
  IHelp.ri_driver.display_info(info)
end
rubydoc(info) click to toggle source

Opens the class documentation page on www.ruby-doc.org using the program defined in IHelp::Renderer.web_browser.

# File lib/ihelp.rb, line 145
def rubydoc(info)
  require 'uri'
  class_name = parse_ruby_doc_url(info.full_name)
  puts "Opening help for: #{class_name.gsub(/\//,"::")}"
  system(IHelp.web_browser, "http://www.ruby-doc.org/core/classes/#{class_name}.html")
end
source(info) click to toggle source

Show sources -renderer using RubyToRuby.

seattlerb.rubyforge.org/

sudo gem install ruby2ruby

# File lib/ihelp.rb, line 158
def source(info)
  require 'ruby2ruby'
  class_name = info.full_name.split(/[#\.]/).first
  klass = class_name.split("::").inject(Object){|o,i| o.const_get(i)}
  args = [klass]
  args << info.name if info.is_a? RI::MethodDescription
  puts RubyToRuby.translate(*args)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.