diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
commit | df7dac9174a31e71b58be6184e23bfe6b742a494 (patch) | |
tree | 885edf624f0e8f37014b0d937340ac1c372a0066 /lib/rdoc/generator/darkfish.rb | |
parent | fed428007c015ac3b7f4586f2491517fafffa030 (diff) |
* lib/rdoc: Update to RDoc 4.1.0.preview.1
RDoc 4.1.0 contains a number of enhancements including a new default
style and accessibility support. You can see the changelog here:
https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc
* test/rdoc: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/generator/darkfish.rb')
-rw-r--r-- | lib/rdoc/generator/darkfish.rb | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 26f545b14b..bd37b60668 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -58,6 +58,21 @@ class RDoc::Generator::Darkfish include ERB::Util ## + # Stylesheets, fonts, etc. that are included in RDoc. + + BUILTIN_STYLE_ITEMS = # :nodoc: + %w[ + fonts.css + fonts/Lato-Light.ttf + fonts/Lato-LightItalic.ttf + fonts/Lato-Regular.ttf + fonts/Lato-RegularItalic.ttf + fonts/SourceCodePro-Bold.ttf + fonts/SourceCodePro-Regular.ttf + rdoc.css + ] + + ## # Path to this file's parent directory. Used to find templates and other # resources. @@ -128,6 +143,11 @@ class RDoc::Generator::Darkfish attr_reader :store ## + # The directory where the template files live + + attr_reader :template_dir # :nodoc: + + ## # The output directory attr_reader :outputdir @@ -195,7 +215,13 @@ class RDoc::Generator::Darkfish debug_msg "Copying static files" options = { :verbose => $DEBUG_RDOC, :noop => @dry_run } - FileUtils.cp @template_dir + 'rdoc.css', '.', options + BUILTIN_STYLE_ITEMS.each do |item| + install_rdoc_static_file @template_dir + item, "./#{item}", options + end + + @options.template_stylesheets.each do |stylesheet| + FileUtils.cp stylesheet, '.', options + end Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path| next if File.directory? path @@ -203,11 +229,7 @@ class RDoc::Generator::Darkfish dst = Pathname.new(path).relative_path_from @template_dir - # I suck at glob - dst_dir = dst.dirname - FileUtils.mkdir_p dst_dir, options unless File.exist? dst_dir - - FileUtils.cp @template_dir + path, dst, options + install_rdoc_static_file @template_dir + path, dst, options end end @@ -447,7 +469,7 @@ class RDoc::Generator::Darkfish ## # Generates the 404 page for the RDoc servlet - def generate_servlet_not_found path + def generate_servlet_not_found message setup template_file = @template_dir + 'servlet_not_found.rhtml' @@ -530,6 +552,23 @@ class RDoc::Generator::Darkfish raise error end + def install_rdoc_static_file source, destination, options # :nodoc: + return unless source.exist? + + begin + FileUtils.mkdir_p File.dirname(destination), options + + begin + FileUtils.ln source, destination, options + rescue Errno::EEXIST + FileUtils.rm destination + retry + end + rescue + FileUtils.cp source, destination, options + end + end + ## # Prepares for generation of output from the current directory |