Building upon this, here is another attempt:

https://fedorapeople.org/cgit/vondruch/public_git/darkfish.git/commit/?h=rawhide&id=487234ef5f64f78291ce767a8a989649ee941c73

https://koji.fedoraproject.org/koji/taskinfo?taskID=94460961


While I have reverted back to non gem approach, the RubyGems plugin hook can still be utilized. I have reverted from the gem approach, because it allows to have the template outside of the RubyGems directory structure, while it does not prohibit to install RubyGems hook.

I have also tried different approaches, such as having full featured RDoc extension, but the RDoc templates are loaded quite late in the process [1], so they would not be available for the RubyGems generator.

This iteration also removes monkey patching in favor of inheritance.

Last but not least, this iteration helps me a bit with clarification of the name of the project. The generators has to have `RDoc::Generator::` prefix, therefore the class is named `RDoc::Generator::Fedora::Darkfish` (and there is also `RDoc::Generator::Fedora::JsonIndex`), therefore I think the package/project should be named fedora-darkfish. I'm still not clear if `rdoc` suffix/prefix would help. While long, maybe `rdoc-generator-fedora-darkfish` prefix would correlate with the class name the best and it would hint to  RDoc and Darkfish. Should there be another generators packaged, they could possibly follow similar scheme (while in theory the should have rubygem- prefix 🫣).


PTAL and let me know what do you think about this approach. Thx


Vít


[1] https://github.com/ruby/rdoc/blob/45259f9024b7d08ae2ba119c9a02983bf672f10c/lib/rdoc/rdoc.rb#L532-L546


Dne 01. 11. 22 v 18:53 Vít Ondruch napsal(a):


Dne 26. 10. 22 v 17:32 Vít Ondruch napsal(a):
We could also try to somehow modify the Gem.done_installing hooks and remove the RDoc hook and replace it with ours.


Building upon this idea, I am attaching an proof of concept. This loads the original RubyGems RDoc hook, removes it an replaces by a custom hook. In this custom hook (which is inherited from the original code), the generator name can be modified from "darkfish" to something completely different and hence load the custom generator (which can inherit from Darkfish). The options could also be potentially modified to change the #setup_generator method.

Another option could be leave the generator as it is and have additional hook, which would run after the default generators and update the generated content. While tempting, I still think the generator/template should be extracted from RDoc and therefore this is less appealing option IMHO.


BTW we could also use the hook to remove the `--document=ri,rdoc` option from `%gem_install` macro [1]. But that would be probably too much magic.


Vít



[1] https://src.fedoraproject.org/rpms/ruby/blob/588a4ae9f02928d7bedbcf46a739d36b0a76e632/f/macros.rubygems#_31