diff options
-rw-r--r-- | darkfish.spec | 42 | ||||
-rw-r--r-- | fedora_darkfish.gemspec | 26 | ||||
-rw-r--r-- | fedora_darkfish.rb | 63 | ||||
-rw-r--r-- | rubygems_plugin.rb | 107 |
4 files changed, 74 insertions, 164 deletions
diff --git a/darkfish.spec b/darkfish.spec index b5713a5..2a38ca0 100644 --- a/darkfish.spec +++ b/darkfish.spec @@ -1,5 +1,7 @@ %global gem_name fedora_darkfish +%global gem_plugin %{gem_dir}/plugins/%{name}_plugin.rb + Name: darkfish-rdoc Version: 6.4.0 Release: 1%{?dist} @@ -9,14 +11,13 @@ Summary: Darkfish RDoc Generator License: GPL-2.0 AND Ruby AND BSD-3-Clause AND CC-BY-2.5 URL: https://ruby.github.io/rdoc Source0: https://rubygems.org/gems/rdoc-%{version}.gem -Source1: fedora_darkfish.gemspec -Source2: fedora_darkfish.rb -Source3: rubygems_plugin.rb +Source1: fedora_darkfish.rb +Source2: rubygems_plugin.rb # Because the fonts are not embedded, do not refer to them in the font.css # file. Patch0: rdoc-6.4.0-Drop-the-font-URLs-from-css.patch Requires: %{name}-assets -BuildRequires: %{_bindir}/gem +Requires: ruby(rubygems) BuildRequires: rubygems-devel BuildArch: noarch @@ -39,30 +40,14 @@ This package provides Darkfish template shared assets for documentaion generated for rubygem- packages on Fedora. %prep -#%%setup -q -n rdoc-%{version} -%setup -q -c +%setup -q -n rdoc-%{version} -pushd rdoc-%{version} %patch0 -p1 -popd - -mkdir -p lib -pushd lib -cp -a %{SOURCE2} . -cp -a %{SOURCE3} . -popd %build -gem build %{SOURCE1} -%gem_install - %install -mkdir -p %{buildroot}%{gem_dir} -cp -a .%{gem_dir}/* \ - %{buildroot}%{gem_dir}/ - -pushd rdoc-%{version}/lib/rdoc/generator/template/ +pushd lib/rdoc/generator/template/ find . -mindepth 2 -type d \ -exec install -d %{buildroot}%{_datadir}/darkfish-rdoc/{} \; find . -type f \ @@ -74,17 +59,20 @@ rm %{buildroot}%{_datadir}/darkfish-rdoc/{darkfish,json_index}/.document # Drop fonts. System fonts are going to be pulled in instead. rm -rf %{buildroot}%{_datadir}/darkfish-rdoc/darkfish/fonts +install -p -m 644 %{SOURCE1} %{buildroot}%{_datadir}/darkfish-rdoc/ +install -p -m 644 %{SOURCE2} %{buildroot}%{_datadir}/darkfish-rdoc/ + +mkdir -p $(dirname %{buildroot}%{gem_plugin}) +echo "require '%{_datadir}/darkfish-rdoc/rubygems_plugin.rb'" > %{buildroot}%{gem_plugin} + %check # Not test ATM. Not clear if there is actually something to test. %files -%dir %{gem_instdir} -%{gem_libdir} %{gem_plugin} -%{gem_spec} -%exclude %{gem_docdir} -%exclude %{gem_cache} %{_datadir}/darkfish-rdoc/darkfish/*.rhtml +%{_datadir}/darkfish-rdoc/fedora_darkfish.rb +%{_datadir}/darkfish-rdoc/rubygems_plugin.rb %files assets %dir %{_datadir}/darkfish-rdoc/ diff --git a/fedora_darkfish.gemspec b/fedora_darkfish.gemspec deleted file mode 100644 index 2244fb1..0000000 --- a/fedora_darkfish.gemspec +++ /dev/null @@ -1,26 +0,0 @@ -Gem::Specification.new do |spec| - spec.name = 'fedora_darkfish' - spec.version = '6.4.0' - spec.authors = ['Jaroslav Prokop'] - spec.email = ['jar.prokop@volny.cz'] - - spec.summary = 'RDoc plugin for Fedora leveraging the Darkfish template' - spec.description = 'RDoc plugin for Fedora leveraging the Darkfish template' \ - 'that symlinks common files.' - spec.homepage = 'https://fedorapeople.org/cgit/jackorp/public_git/fedora_darkfish.git/commit/?h=rawhide' - spec.license = 'MIT' - - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = 'https://rubygems.org' - else - raise 'RubyGems 2.0 or newer is required to protect against ' \ - 'public gem pushes.' - end - - spec.files = Dir["lib/*.rb"] - - spec.add_development_dependency 'rake', '>= 12' - spec.add_development_dependency 'test_unit' -end diff --git a/fedora_darkfish.rb b/fedora_darkfish.rb index 28c3946..6bb9825 100644 --- a/fedora_darkfish.rb +++ b/fedora_darkfish.rb @@ -2,46 +2,53 @@ require 'rdoc' require 'rdoc/generator/darkfish' require 'rdoc/generator/json_index' -class RDoc::Generator::Darkfish - alias initialize_orig initialize +module RDoc::Generator::Fedora + class RDoc::Generator::Fedora::Darkfish < RDoc::Generator::Darkfish + RDoc::RDoc.add_generator(self) - def initialize store, options - options.template_dir = File.join __dir__, 'darkfish' - initialize_orig store, options - end + alias initialize_orig initialize + + def initialize store, options + options.template_dir = File.join __dir__, 'darkfish' - def install_rdoc_static_file source, destination, options # :nodoc: - return unless source.exist? + initialize_orig store, options - begin - FileUtils.mkdir_p File.dirname(destination), **options - FileUtils.ln_sf source, destination, **options - rescue + @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 -end -class RDoc::Generator::JsonIndex - alias generate_orig generate + class RDoc::Generator::Fedora::JsonIndex < RDoc::Generator::JsonIndex + alias generate_orig generate - def generate - generate_orig + def generate + generate_orig - out_dir = @base_dir + @options.op_dir + out_dir = @base_dir + @options.op_dir - template_dir = File.join __dir__, 'json_index' + 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 + 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 - end - # Don't generate gzipped content. Because we have always shipped also the - # original, it just increases the size. - def generate_gzipped + # Don't generate gzipped content. Because we have always shipped also the + # original, it just increases the size. + def generate_gzipped + end end end diff --git a/rubygems_plugin.rb b/rubygems_plugin.rb index f003ae3..574c693 100644 --- a/rubygems_plugin.rb +++ b/rubygems_plugin.rb @@ -1,93 +1,34 @@ -[: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 +# Make sure there are no `done_installing` hooks defined yet, so there is know +# starting position. +raise unless Gem.done_installing_hooks.empty? - args = @spec.rdoc_options - args.concat @spec.source_paths - args.concat @spec.extra_rdoc_files +# Initialize the RubyGems RDoc hook. +require "rubygems/rdoc" - case config_args = Gem.configuration[:rdoc] - when String then - args = args.concat config_args.split(' ') - when Array then - args = args.concat config_args - end +# Double check that there is only one `done_installing` hook loaded. +raise unless Gem.done_installing_hooks.size == 1 - delete_legacy_args args +# Subsequently drop the hook. +Gem.done_installing_hooks.pop - Dir.chdir @spec.full_gem_path do - options = ::RDoc::Options.new - options.default_title = "#{@spec.full_name} Documentation" - options.parse args - end +$LOAD_PATH.unshift __dir__ +require 'fedora_darkfish' - 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 +module Fedora + module RDoc + end +end - document 'ri', options, @ri_dir if - @generate_ri and (@force or not File.exist? @ri_dir) +class Fedora::RDoc::RubyGemsHook < RDoc::RubygemsHook + def self.generation_hook installer, specs + puts "FedoraRDoc.generation_hook - the `specs` could be modified to include additional `rdoc_options`" + super + end - document 'fedora', options, @rdoc_dir if - @generate_rdoc and (@force or not File.exist? @rdoc_dir) - end - end + def document generator, options, destination + generator = "fedora::#{generator}" + super end end -# Gem.post_install do -# puts require 'fedora_darkfish' -# end +Gem.done_installing(&Fedora::RDoc::RubyGemsHook.method(:generation_hook)) |