Allow installing RDoc from a git source
This implements option 2 in #1107, which is to use extconf.rb to conditionally run rake generate when the gem is installed as a git source.
To make sure the target machine has the required dependencies for the generation, I modified rake generate to conditionally install the kpeg and racc.
@nobu Thanks for the suggestions 👍
@nobu Would you mind giving this another look? If you're not against it, I'd like to give it a try.
This does not work, at least when I tested it.
The problem is, extconf.rb is executed from the root directory, so the relative path (computed from Dir.pwd is wrong):
The fix is:
git_path = File.expand_path("../../.git", __dir__)
if File.exist?(git_path)
system("rake generate")
end
At least that gets us to the next issue:
> ruby ./ext/rdoc/extconf.rb
Generating lib/rdoc/markdown.rb...
rake aborted!
Gem::GemNotFoundException: can't find gem kpeg (>= 0) with executable kpeg (Gem::GemNotFoundException)
/home/samuel/.gem/ruby/3.4.1/bundler/gems/rdoc-c75f094920b3/Rakefile:80:in 'block (2 levels) in <top (required)>'
Tasks: TOP => generate => lib/rdoc/markdown.rb
(See full trace by running task with --trace)
creating Makefile
Would it be crazy to do this:
# rdoc.gemspec
if ENV["RDOC_FROM_SOURCE"] # or something better???
gem "kpeg"
...