Class IHelp::Renderer
In: lib/ihelp.rb
Parent: Object
Ferret::Analysis::StandardAnalyzer IHelpAnalyzer RiDriver IHelpDriver IHelpIndex Renderer lib/ihelp.rb IHelp dot/m_0_1.png

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.

Methods

emacs   html   parse_ruby_doc_url   ri   rubydoc   source  

Public Instance methods

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

[Source]

     # File lib/ihelp.rb, line 174
174:     def emacs(info)
175:       system "gnudoit", %Q[(progn (ri "#{info.full_name}") "#{info.full_name}")]
176:     end

[Source]

     # File lib/ihelp.rb, line 178
178:     def html(info)
179:       puts "Opening help for: #{info.full_name}"
180:       doc = REXML::Document.new
181:       root = doc.add_element("html")
182:       head = root.add_element("head")
183:       title = head.add_element("title")
184:       title.add_text("#{info.full_name} - RI Documentation")
185:       body = root.add_element("body")
186:       body.add_element(info.to_html.root)
187:       tmp = Tempfile.new("#{info.full_name.gsub(/\W/,"_")}_doc.html")
188:       tmp.write( doc.to_s(2) )
189:       tmp.flush
190:       pid = fork{
191:         system(IHelp.web_browser, "file://#{tmp.path}")
192:         tmp.close!
193:       }
194:       Process.detach(pid)
195:       pid
196:     end

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

[Source]

     # File lib/ihelp.rb, line 139
139:     def ri(info)
140:       IHelp.ri_driver.display_info(info)
141:     end

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

[Source]

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

Show sources -renderer using RubyToRuby.

seattlerb.rubyforge.org/

sudo gem install ruby2ruby

[Source]

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

Private Instance methods

[Source]

     # File lib/ihelp.rb, line 199
199:     def parse_ruby_doc_url(item_name)
200:       item_name.split(/\.|#/,2).first.gsub(/::/,"/")
201:     end

[Validate]