lib/malt/engines/rdoc.rb in malt-0.3.0 vs lib/malt/engines/rdoc.rb in malt-0.4.0

- old
+ new

@@ -12,34 +12,40 @@ class RDoc < Abstract default :rdoc # Convert rdoc text to html. - def render(params) - text = params[:text] - into = params[:to] + def render(params={}) + into, text = parameters(params, :to, :text) + case into when :html, nil - html_engine.convert(text).to_s + prepare_engine(params).convert(text).to_s else super(params) end end - private + # + def create_engine(params={}) + into = parameters(params, :to) - # Load rdoc makup library if not already loaded. - def initialize_engine - return if defined?(::RDoc::Markup) - require 'rubygems' # hack - require_library 'rdoc/markup' - require_library 'rdoc/markup/to_html' + cached(into) do + ::RDoc::Markup::ToHtml.new end + end - # - def html_engine - @html_engine ||= ::RDoc::Markup::ToHtml.new - end + private + + # Load rdoc makup library if not already loaded. + def require_engine + return if defined?(::RDoc::Markup) + require 'rubygems' # hack + gem 'rdoc', '> 3' + require_library 'rdoc' + #require_library 'rdoc/markup' + #require_library 'rdoc/markup/to_html' + end end end