summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Prokop <jprokop@redhat.com>2022-10-26 11:45:00 +0200
committerJarek Prokop <jprokop@redhat.com>2022-10-26 11:45:00 +0200
commitda71247f3da96894ea75f44245a33a64ae9eb0da (patch)
tree8bdd9ebf119b7c55ab334548378053048f46057b
parenteb072f5e22a18aa8b93d7952957d6f5bdced8659 (diff)
downloadfedora_darkfish-rawhide.tar.gz
fedora_darkfish-rawhide.tar.xz
fedora_darkfish-rawhide.zip
Add Rubygems plugin for generation.HEADrawhide
-rw-r--r--fedora_darkfish.gemspec12
-rw-r--r--fedora_darkfish.spec3
-rw-r--r--lib/rubygems_plugin.rb93
3 files changed, 97 insertions, 11 deletions
diff --git a/fedora_darkfish.gemspec b/fedora_darkfish.gemspec
index 9cc8a69..3769061 100644
--- a/fedora_darkfish.gemspec
+++ b/fedora_darkfish.gemspec
@@ -1,9 +1,6 @@
-lib = File.expand_path('lib', __dir__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-
Gem::Specification.new do |spec|
spec.name = 'fedora_darkfish'
- spec.version = '1.0.0'
+ spec.version = '1.0.2'
spec.authors = ['Jaroslav Prokop']
spec.email = ['jar.prokop@volny.cz']
@@ -22,13 +19,8 @@ Gem::Specification.new do |spec|
'public gem pushes.'
end
- spec.files = %w[
- README.md
- LICENSE
- lib/rdoc/generator/fedora_darkfish.rb
- ]
+ spec.files = Dir["README.md", "LICENSE", "lib/**/*.rb"]
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- spec.require_paths = [File.join('lib', 'rdoc', 'generator')]
spec.add_dependency 'rdoc'
diff --git a/fedora_darkfish.spec b/fedora_darkfish.spec
index 7644e10..e43fb7c 100644
--- a/fedora_darkfish.spec
+++ b/fedora_darkfish.spec
@@ -2,7 +2,7 @@
%global gem_name fedora_darkfish
Name: rubygem-%{gem_name}
-Version: 1.0.0
+Version: 1.0.2
Release: 1%{?dist}
Summary: RDoc plugin for Fedora leveraging the Darkfish template
License: MIT
@@ -52,6 +52,7 @@ popd
%dir %{gem_instdir}
%license %{gem_instdir}/LICENSE
%{gem_libdir}
+%{gem_plugin}
%{gem_spec}
%exclude %{gem_cache}
diff --git a/lib/rubygems_plugin.rb b/lib/rubygems_plugin.rb
new file mode 100644
index 0000000..f003ae3
--- /dev/null
+++ b/lib/rubygems_plugin.rb
@@ -0,0 +1,93 @@
+[:pre_install, :pre_reset, :pre_uninstall, :post_build, :post_install, :post_reset, :post_uninstall].each do |meth|
+ block = Proc.new { puts 'This is ' + meth.to_s }
+ Gem.send(meth, &block)
+end
+
+# class RDoc::RubygemsHook::Fedora < Rdoc::RubygemsHook
+# def document options, destination
+#
+# end
+# end
+Gem.pre_install do
+ module RDoc
+ class RubygemsHook
+ alias generate_default generate
+
+ def self.load_rdoc
+ return if @fedora_darkfish_version
+
+ require_relative 'rdoc/generator/fedora_darkfish'
+
+ @fedora_darkfish_version = Gem::Version.new '1.0.0'
+ end
+
+ # def generate
+ # if Gem.rpmbuild?
+ # generate_fedora
+ # else
+ # generate_default
+ # end
+ # end
+
+ def generate #_fedora
+ # Unfortunately the generator option for RDoc is not parametrized so
+ # this has been Copied from RDoc::RubygemsHook#generate
+ # and darkfish was replaced with fedora at the end of this method.
+ return if @spec.default_gem?
+ return unless @generate_ri or @generate_rdoc
+
+ setup
+
+ options = nil
+
+ args = @spec.rdoc_options
+ args.concat @spec.source_paths
+ args.concat @spec.extra_rdoc_files
+
+ case config_args = Gem.configuration[:rdoc]
+ when String then
+ args = args.concat config_args.split(' ')
+ when Array then
+ args = args.concat config_args
+ end
+
+ delete_legacy_args args
+
+ Dir.chdir @spec.full_gem_path do
+ options = ::RDoc::Options.new
+ options.default_title = "#{@spec.full_name} Documentation"
+ options.parse args
+ end
+
+ options.quiet = !Gem.configuration.really_verbose
+
+ @rdoc = new_rdoc
+ @rdoc.options = options
+
+ store = ::RDoc::Store.new
+ store.encoding = options.encoding
+ store.dry_run = options.dry_run
+ store.main = options.main_page
+ store.title = options.title
+
+ @rdoc.store = store
+
+ say "Parsing documentation for #{@spec.full_name}"
+
+ Dir.chdir @spec.full_gem_path do
+ @rdoc.parse_files options.files
+ end
+
+ document 'ri', options, @ri_dir if
+ @generate_ri and (@force or not File.exist? @ri_dir)
+
+ document 'fedora', options, @rdoc_dir if
+ @generate_rdoc and (@force or not File.exist? @rdoc_dir)
+ end
+ end
+ end
+end
+
+# Gem.post_install do
+# puts require 'fedora_darkfish'
+# end