Skip to content

Commit 0cb0611

Browse files
st0012vinistock
andcommittedMar 21, 2025
Allow installing RDoc from a git source
Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com>
1 parent 894b2f1 commit 0cb0611

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed
 

Diff for: ‎Rakefile

+12-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,18 @@ parsed_files = PARSER_FILES.map do |parser_file|
8888
end
8989

9090
task "#{path}.gem" => package_parser_files
91-
desc "Generate all files used racc and kpeg"
92-
task :generate => parsed_files
91+
92+
desc "Generate all files use racc and kpeg"
93+
task :generate do
94+
unless ENV.key?('BUNDLE_GEMFILE')
95+
Gem.install 'racc', '> 1.4.10'
96+
Gem.install 'kpeg', '>= 1.3.3'
97+
end
98+
99+
parsed_files.each do |file_name|
100+
Rake::Task[file_name].invoke
101+
end
102+
end
93103

94104
task :clean do
95105
parsed_files.each do |path|

Diff for: ‎ext/rdoc/extconf.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
# Generate all parse files using racc and kpeg. This is not necessary for regular gem installation, but it is when
4+
# installing RDoc from the git source. Without this, the generated parse files would not exist and RDoc would not work
5+
system("rake generate") if Dir.exist?(File.join("..", "..", ".git"))
6+
7+
# RDoc doesn't actually have a native extension, but a Makefile needs to exist in order to successfully install the gem
8+
require "mkmf"
9+
create_makefile("rdoc/rdoc")

Diff for: ‎rdoc.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
3535
s.bindir = "exe"
3636
s.executables = ["rdoc", "ri"]
3737
s.require_paths = ["lib"]
38+
s.extensions = ["ext/rdoc/extconf.rb"]
3839
# for ruby core repository. It was generated by
3940
# `git ls-files -z`.split("\x0").each {|f| puts " #{f.dump}," unless f.start_with?(*%W[test/ spec/ features/ .]) }
4041
non_lib_files = [

0 commit comments

Comments
 (0)