rdoc.rb 725 B

1234567891011121314151617181920212223242526272829303132
  1. require 'tilt/template'
  2. module Tilt
  3. # RDoc template. See:
  4. # http://rdoc.rubyforge.org/
  5. #
  6. # It's suggested that your program require 'rdoc/markup' and
  7. # 'rdoc/markup/to_html' at load time when using this template
  8. # engine.
  9. class RDocTemplate < Template
  10. self.default_mime_type = 'text/html'
  11. def self.engine_initialized?
  12. defined? ::RDoc::Markup
  13. end
  14. def initialize_engine
  15. require_template_library 'rdoc/markup'
  16. require_template_library 'rdoc/markup/to_html'
  17. end
  18. def prepare
  19. markup = RDoc::Markup::ToHtml.new
  20. @engine = markup.convert(data)
  21. @output = nil
  22. end
  23. def evaluate(scope, locals, &block)
  24. @output ||= @engine.to_s
  25. end
  26. end
  27. end