Skip to content

Allow installing RDoc from a git source #1113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,18 @@ parsed_files = PARSER_FILES.map do |parser_file|
end

task "#{path}.gem" => package_parser_files
desc "Generate all files used racc and kpeg"

desc "Generate all files use racc and kpeg"
task :generate => parsed_files

unless ENV.key?('BUNDLE_GEMFILE')
task :gem_install do
Gem.install 'racc', '> 1.4.10'
Gem.install 'kpeg', '>= 1.3.3'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colby-swandale do you know if there's any rubygems API to better handle these dependencies without bundler?

Copy link
Member

@colby-swandale colby-swandale May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand the context where Bundler wouldn't be available?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundler will be available, but this will be executed in 2 scenarios:

  • When a developer runs rake generate (or any tasks that depend on it) manually
  • When a user installs RDoc through git source

In the later case, I want to avoid installing all of RDoc's development dependencies as most of them aren't needed for generating the missing files.

end
file parsed_files => :gem_install
end

task :clean do
parsed_files.each do |path|
File.delete(path) if File.exist?(path)
Expand Down
9 changes: 9 additions & 0 deletions ext/rdoc/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# Generate all parse files using racc and kpeg. This is not necessary for regular gem installation, but it is when
# installing RDoc from the git source. Without this, the generated parse files would not exist and RDoc would not work
system("rake generate") if File.exist?("../../.git")

# RDoc doesn't actually have a native extension, but a Makefile needs to exist in order to successfully install the gem
require "mkmf"
create_makefile("rdoc/rdoc")
1 change: 1 addition & 0 deletions rdoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
s.bindir = "exe"
s.executables = ["rdoc", "ri"]
s.require_paths = ["lib"]
s.extensions = ["ext/rdoc/extconf.rb"]
# for ruby core repository. It was generated by
# `git ls-files -z`.split("\x0").each {|f| puts " #{f.dump}," unless f.start_with?(*%W[test/ spec/ features/ .]) }
non_lib_files = [
Expand Down
Loading