From 70fc27b7facb8c73580428450989b66425c08177 Mon Sep 17 00:00:00 2001 From: drbrain Date: Fri, 8 Feb 2013 04:12:56 +0000 Subject: * lib/rdoc/generator/darkfish.rb: Set encoding on output template to user-specified encoding. * test/rdoc/test_rdoc_generator_darkfish.rb: Test for above. * lib/rdoc.rb: Bump version git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/rdoc.rb | 2 +- lib/rdoc/generator/darkfish.rb | 24 ++++++++++++------------ test/rdoc/test_rdoc_generator_darkfish.rb | 10 ++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab4f13be96..2026ea8590 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Feb 8 13:12:04 2013 Eric Hodel + + * lib/rdoc/generator/darkfish.rb: Set encoding on output template to + user-specified encoding. + * test/rdoc/test_rdoc_generator_darkfish.rb: Test for above. + + * lib/rdoc.rb: Bump version + Fri Feb 8 11:53:33 2013 Eric Hodel * lib/rubygems/security/policy.rb: Raise proper exceptions when diff --git a/lib/rdoc.rb b/lib/rdoc.rb index 1b53421927..6508661d63 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -64,7 +64,7 @@ module RDoc ## # RDoc version you are using - VERSION = '4.0.0.rc.2' + VERSION = '4.0.0.rc.2.1' ## # Method visibilities diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index ba62646e77..26f545b14b 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -698,18 +698,18 @@ class RDoc::Generator::Darkfish return template if template - template = if page then - assemble_template file - else - file.read - end - - erbout = if page then - 'io' - else - file_var = File.basename(file).sub(/\..*/, '') - "_erbout_#{file_var}" - end + if page then + template = assemble_template file + erbout = 'io' + else + template = file.read + template = template.encode @options.encoding if + Object.const_defined? :Encoding + + file_var = File.basename(file).sub(/\..*/, '') + + erbout = "_erbout_#{file_var}" + end template = klass.new template, nil, '<>', erbout @template_cache[file] = template diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index 08c14f8d57..613a1151e7 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -173,5 +173,15 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase assert_same template, @g.send(:template_for, classpage) end + def test_template_for_partial + partial = Pathname.new @options.template_dir + '_sidebar_classes.rhtml' + + template = @g.send(:template_for, partial, false, RDoc::ERBPartial) + + assert_kind_of RDoc::ERBPartial, template + + assert_same template, @g.send(:template_for, partial) + end + end -- cgit v1.2.3