summaryrefslogtreecommitdiffstats
path: root/rubygems_plugin.rb
blob: 42f50ba8c44354589784df8541c463830c315a02 (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
# Initialize the RubyGems RDoc hook.
require "rubygems/rdoc"

# Make sure there is only one `done_installing`, so we can assume it it the
# RDod defined one.
raise <<~ERR unless Gem.done_installing_hooks.size == 1
  rdoc-generator-fedora-darkfish expects only one `Gem.done_installing_hooks`
  at this stage, but #{Gem.done_installing_hooks.size} are defined
ERR

# Subsequently drop the hook.
Gem.done_installing_hooks.pop

$LOAD_PATH.unshift __dir__
require 'fedora_darkfish'

module Fedora
  module RDoc
  end
end

class Fedora::RDoc::RubyGemsHook < RDoc::RubygemsHook
  def self.generation_hook installer, specs
    super
  end

  def document generator, options, destination
    fedora_generator = "fedora::#{generator}"
    generator = fedora_generator if RDoc::RDoc::GENERATORS.include? fedora_generator
    super
  end
end

Gem.done_installing(&Fedora::RDoc::RubyGemsHook.method(:generation_hook))