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.
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
# 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
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
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
Show sources -renderer using RubyToRuby.
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
Generated with the Darkfish Rdoc Generator 2.