summaryrefslogtreecommitdiffstats
path: root/fedora_darkfish.rb
blob: 6bb9825a03d7394c9a66b350f7b8610e2963f1dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'rdoc'
require 'rdoc/generator/darkfish'
require 'rdoc/generator/json_index'

module RDoc::Generator::Fedora
  class RDoc::Generator::Fedora::Darkfish < RDoc::Generator::Darkfish
    RDoc::RDoc.add_generator(self)

    alias initialize_orig initialize

    def initialize store, options
      options.template_dir = File.join __dir__, 'darkfish'

      initialize_orig store, options

      @json_index = RDoc::Generator::Fedora::JsonIndex.new self, options
    end

    def install_rdoc_static_file source, destination, options # :nodoc:
      return unless source.exist?

      begin
        FileUtils.mkdir_p File.dirname(destination), **options
        FileUtils.ln_sf source, destination, **options
      rescue
      end
    end
  end

  class RDoc::Generator::Fedora::JsonIndex < RDoc::Generator::JsonIndex
    alias generate_orig generate

    def generate
      generate_orig

      out_dir = @base_dir + @options.op_dir

      template_dir = File.join __dir__, 'json_index'

      Dir.chdir template_dir do
	Dir['**/*.js'].each do |source|
	  dest = File.join out_dir, source
	  source = File.realpath source
	  FileUtils.ln_sf source, dest, :verbose => $DEBUG_RDOC
	end
      end
    end

    # Don't generate gzipped content. Because we have always shipped also the
    # original, it just increases the size.
    def generate_gzipped
    end
  end
end