Skip to content
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

Move ronn pages to lib #3997

Merged
merged 5 commits into from Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/install-rubygems.yml
Expand Up @@ -42,6 +42,8 @@ jobs:
run: bundle --version
- name: Check bundler man pages were installed and are properly picked up
run: bundle install --help | grep -q BUNDLE-INSTALL
- name: Check bundler fallback man pages are properly picked up
run: sudo rm $(which man) && bundle install --help
- name: Build bundler
run: gem build bundler.gemspec
working-directory: ./bundler
Expand Down
51 changes: 26 additions & 25 deletions Manifest.txt
Expand Up @@ -89,6 +89,32 @@ bundler/lib/bundler/installer/standalone.rb
bundler/lib/bundler/lazy_specification.rb
bundler/lib/bundler/lockfile_generator.rb
bundler/lib/bundler/lockfile_parser.rb
bundler/lib/bundler/man/.document
bundler/lib/bundler/man/bundle-add.1.ronn
bundler/lib/bundler/man/bundle-binstubs.1.ronn
bundler/lib/bundler/man/bundle-cache.1.ronn
bundler/lib/bundler/man/bundle-check.1.ronn
bundler/lib/bundler/man/bundle-clean.1.ronn
bundler/lib/bundler/man/bundle-config.1.ronn
bundler/lib/bundler/man/bundle-doctor.1.ronn
bundler/lib/bundler/man/bundle-exec.1.ronn
bundler/lib/bundler/man/bundle-gem.1.ronn
bundler/lib/bundler/man/bundle-info.1.ronn
bundler/lib/bundler/man/bundle-init.1.ronn
bundler/lib/bundler/man/bundle-inject.1.ronn
bundler/lib/bundler/man/bundle-install.1.ronn
bundler/lib/bundler/man/bundle-list.1.ronn
bundler/lib/bundler/man/bundle-lock.1.ronn
bundler/lib/bundler/man/bundle-open.1.ronn
bundler/lib/bundler/man/bundle-outdated.1.ronn
bundler/lib/bundler/man/bundle-platform.1.ronn
bundler/lib/bundler/man/bundle-pristine.1.ronn
bundler/lib/bundler/man/bundle-remove.1.ronn
bundler/lib/bundler/man/bundle-show.1.ronn
bundler/lib/bundler/man/bundle-update.1.ronn
bundler/lib/bundler/man/bundle-viz.1.ronn
bundler/lib/bundler/man/bundle.1.ronn
bundler/lib/bundler/man/gemfile.5.ronn
bundler/lib/bundler/match_platform.rb
bundler/lib/bundler/mirror.rb
bundler/lib/bundler/plugin.rb
Expand Down Expand Up @@ -253,55 +279,30 @@ bundler/lib/bundler/vlad.rb
bundler/lib/bundler/worker.rb
bundler/lib/bundler/yaml_serializer.rb
bundler/man/bundle-add.1
bundler/man/bundle-add.1.ronn
bundler/man/bundle-binstubs.1
bundler/man/bundle-binstubs.1.ronn
bundler/man/bundle-cache.1
bundler/man/bundle-cache.1.ronn
bundler/man/bundle-check.1
bundler/man/bundle-check.1.ronn
bundler/man/bundle-clean.1
bundler/man/bundle-clean.1.ronn
bundler/man/bundle-config.1
bundler/man/bundle-config.1.ronn
bundler/man/bundle-doctor.1
bundler/man/bundle-doctor.1.ronn
bundler/man/bundle-exec.1
bundler/man/bundle-exec.1.ronn
bundler/man/bundle-gem.1
bundler/man/bundle-gem.1.ronn
bundler/man/bundle-info.1
bundler/man/bundle-info.1.ronn
bundler/man/bundle-init.1
bundler/man/bundle-init.1.ronn
bundler/man/bundle-inject.1
bundler/man/bundle-inject.1.ronn
bundler/man/bundle-install.1
bundler/man/bundle-install.1.ronn
bundler/man/bundle-list.1
bundler/man/bundle-list.1.ronn
bundler/man/bundle-lock.1
bundler/man/bundle-lock.1.ronn
bundler/man/bundle-open.1
bundler/man/bundle-open.1.ronn
bundler/man/bundle-outdated.1
bundler/man/bundle-outdated.1.ronn
bundler/man/bundle-platform.1
bundler/man/bundle-platform.1.ronn
bundler/man/bundle-pristine.1
bundler/man/bundle-pristine.1.ronn
bundler/man/bundle-remove.1
bundler/man/bundle-remove.1.ronn
bundler/man/bundle-show.1
bundler/man/bundle-show.1.ronn
bundler/man/bundle-update.1
bundler/man/bundle-update.1.ronn
bundler/man/bundle-viz.1
bundler/man/bundle-viz.1.ronn
bundler/man/bundle.1
bundler/man/bundle.1.ronn
bundler/man/gemfile.5
bundler/man/gemfile.5.ronn
bundler/man/index.txt
hide_lib_for_update/note.txt
lib/rubygems.rb
Expand Down
4 changes: 2 additions & 2 deletions bundler/Rakefile
Expand Up @@ -79,8 +79,8 @@ namespace :man do
else
directory "man"

index = Dir["man/*.ronn"].map do |source|
ronn = "man/#{File.basename(source)}"
index = Dir["lib/bundler/man/*.ronn"].map do |source|
ronn = "lib/bundler/man/#{File.basename(source)}"
roff = "man/#{File.basename(source, ".ronn")}"

file roff => ["man", ronn] do
Expand Down
4 changes: 2 additions & 2 deletions bundler/doc/documentation/WRITING.md
Expand Up @@ -20,9 +20,9 @@ Don't see a man page for a command? Make a new page and send us a PR! We also we

## Creating a new man page

To create a new man page, simply create a new `.ronn` file in the `man/` directory.
To create a new man page, simply create a new `.ronn` file in the `lib/bundler/man/` directory.

For example: to create a man page for the command `bundle cookies` (not a real command, sadly), I would create a file `man/bundle-cookies.1.ronn` and add my documentation there.
For example: to create a man page for the command `bundle cookies` (not a real command, sadly), I would create a file `lib/bundler/man/bundle-cookies.1.ronn` and add my documentation there.

## Formatting

Expand Down
3 changes: 2 additions & 1 deletion bundler/lib/bundler/cli.rb
Expand Up @@ -134,7 +134,8 @@ def help(cli = nil)
if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
Kernel.exec "man #{man_page}"
else
puts File.read("#{File.dirname(man_page)}/#{File.basename(man_page)}.ronn")
fallback_man_path = File.expand_path("../man", __FILE__)
puts File.read("#{fallback_man_path}/#{File.basename(man_page)}.ronn")
end
elsif command_path = Bundler.which("bundler-#{cli}")
Kernel.exec(command_path, "--help")
Expand Down
1 change: 1 addition & 0 deletions bundler/lib/bundler/man/.document
@@ -0,0 +1 @@
# Ignore all files in this directory
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions bundler/spec/quality_spec.rb
Expand Up @@ -190,7 +190,7 @@ def check_for_specific_pronouns(filename)
line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
end
end
documented_settings = File.read("man/bundle-config.1.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
documented_settings = File.read("lib/bundler/man/bundle-config.1.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten

documented_settings.each do |s|
all_settings.delete(s)
Expand Down Expand Up @@ -249,7 +249,7 @@ def check_for_specific_pronouns(filename)
end

it "does not use require internally, but require_relative" do
exempt = %r{templates/|vendor/}
exempt = %r{templates/|man/|vendor/}
all_bad_requires = []
lib_tracked_files.each do |filename|
next if filename =~ exempt
Expand Down
66 changes: 25 additions & 41 deletions lib/rubygems/commands/setup_command.rb
Expand Up @@ -322,13 +322,10 @@ def install_lib(lib_dir)
libs.each do |tool, path|
say "Installing #{tool}" if @verbose

lib_files = rb_files_in path
lib_files.concat(bundler_template_files) if tool == 'Bundler'

pem_files = pem_files_in path
lib_files = files_in path

Dir.chdir path do
install_file_list(lib_files + pem_files, lib_dir)
install_file_list(lib_files, lib_dir)
end
end
end
Expand Down Expand Up @@ -514,44 +511,24 @@ def generate_default_dirs(install_destdir)
[lib_dir, bin_dir]
end

def pem_files_in(dir)
Dir.chdir dir do
Dir[File.join('**', '*pem')]
end
end

def rb_files_in(dir)
def files_in(dir)
Dir.chdir dir do
Dir[File.join('**', '*rb')]
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) }
end
end

# for installation of bundler as default gems
def bundler_man1_files_in(dir)
Dir.chdir dir do
Dir['bundle*.1{,.txt,.ronn}']
Dir['bundle*.1']
end
end

# for installation of bundler as default gems
def bundler_man5_files_in(dir)
Dir.chdir dir do
Dir['gemfile.5{,.txt,.ronn}']
end
end

def bundler_template_files
Dir.chdir "bundler/lib" do
Dir.glob(File.join('bundler', 'templates', '**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) }
end
end

# for cleanup old bundler files
def template_files_in(dir)
Dir.chdir dir do
Dir.glob(File.join('templates', '**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) }
Dir['gemfile.5']
end
end

Expand Down Expand Up @@ -591,11 +568,9 @@ def remove_old_lib_files(lib_dir)
lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler'
lib_dirs.each do |old_lib_dir, new_lib_dir|
lib_files = rb_files_in(new_lib_dir)
lib_files.concat(template_files_in(new_lib_dir)) if new_lib_dir =~ /bundler/
lib_files = files_in(new_lib_dir)

old_lib_files = rb_files_in(old_lib_dir)
old_lib_files.concat(template_files_in(old_lib_dir)) if old_lib_dir =~ /bundler/
old_lib_files = files_in(old_lib_dir)

to_remove = old_lib_files - lib_files

Expand All @@ -613,16 +588,25 @@ def remove_old_lib_files(lib_dir)
def remove_old_man_files(man_dir)
man_dirs = { man_dir => "bundler/man" }
man_dirs.each do |old_man_dir, new_man_dir|
["1", "5"].each do |section|
man_files = send(:"bundler_man#{section}_files_in", new_man_dir)
man1_files = bundler_man1_files_in(new_man_dir)

old_man_dir_with_section = "#{old_man_dir}/man#{section}"
old_man_files = send(:"bundler_man#{section}_files_in", old_man_dir_with_section)
old_man1_dir = "#{old_man_dir}/man1"
old_man1_files = bundler_man1_files_in(old_man1_dir)
old_man1_files += Dir.chdir(old_man1_dir) { Dir["bundle*.1.{txt,ronn}"] }

man_to_remove = old_man_files - man_files
man1_to_remove = old_man1_files - man1_files

remove_file_list(man_to_remove, old_man_dir_with_section)
end
remove_file_list(man1_to_remove, old_man1_dir)

man5_files = bundler_man5_files_in(new_man_dir)

old_man5_dir = "#{old_man_dir}/man5"
old_man5_files = bundler_man5_files_in(old_man5_dir)
old_man5_files += Dir.chdir(old_man5_dir) { Dir["gemfile.5.{txt,ronn}"] }

man5_to_remove = old_man5_files - man5_files

remove_file_list(man5_to_remove, old_man5_dir)
end
end

Expand Down
31 changes: 13 additions & 18 deletions test/rubygems/test_gem_commands_setup_command.rb
Expand Up @@ -26,12 +26,12 @@ def setup
bundler/exe/bundle
bundler/lib/bundler.rb
bundler/lib/bundler/b.rb
bundler/lib/bundler/man/bundle-b.1.ronn
bundler/lib/bundler/man/gemfile.5.ronn
bundler/lib/bundler/templates/.circleci/config.yml
bundler/lib/bundler/templates/.travis.yml
bundler/man/bundle-b.1
bundler/man/bundle-b.1.ronn
bundler/man/gemfile.5
bundler/man/gemfile.5.ronn
]

create_dummy_files(filelist)
Expand Down Expand Up @@ -155,23 +155,18 @@ def test_env_shebang_flag
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
end

def test_pem_files_in
assert_equal %w[rubygems/ssl_certs/rubygems.org/foo.pem],
@cmd.pem_files_in('lib').sort
end

def test_rb_files_in
assert_equal %w[rubygems.rb rubygems/test_case.rb],
@cmd.rb_files_in('lib').sort
def test_files_in
assert_equal %w[rubygems.rb rubygems/ssl_certs/rubygems.org/foo.pem rubygems/test_case.rb],
@cmd.files_in('lib').sort
end

def test_bundler_man1_files_in
assert_equal %w[bundle-b.1 bundle-b.1.ronn],
assert_equal %w[bundle-b.1],
@cmd.bundler_man1_files_in('bundler/man').sort
end

def test_bundler_man5_files_in
assert_equal %w[gemfile.5 gemfile.5.ronn],
assert_equal %w[gemfile.5],
@cmd.bundler_man5_files_in('bundler/man').sort
end

Expand All @@ -187,7 +182,7 @@ def test_install_lib
assert_path_exists File.join(dir, 'bundler.rb')
assert_path_exists File.join(dir, 'bundler/b.rb')

assert_path_exists File.join(dir, 'bundler/templates/.circleci/config.yml')
assert_path_exists File.join(dir, 'bundler/templates/.circleci/config.yml') unless RUBY_ENGINE == "truffleruby" # https://github.com/oracle/truffleruby/issues/2116
assert_path_exists File.join(dir, 'bundler/templates/.travis.yml')
end
end
Expand All @@ -199,9 +194,9 @@ def test_install_man
@cmd.install_man dir

assert_path_exists File.join("#{dir}/man1", 'bundle-b.1')
assert_path_exists File.join("#{dir}/man1", 'bundle-b.1.ronn')
refute_path_exists File.join("#{dir}/man1", 'bundle-b.1.ronn')
assert_path_exists File.join("#{dir}/man5", 'gemfile.5')
assert_path_exists File.join("#{dir}/man5", 'gemfile.5.ronn')
refute_path_exists File.join("#{dir}/man5", 'gemfile.5.ronn')
end
end

Expand Down Expand Up @@ -297,7 +292,7 @@ def test_remove_old_lib_files

@cmd.remove_old_lib_files lib

files_that_go.each {|file| refute_path_exists file }
files_that_go.each {|file| refute_path_exists(file) unless file == old_bundler_ci && RUBY_ENGINE == "truffleruby" } # https://github.com/oracle/truffleruby/issues/2116

files_that_stay.each {|file| assert_path_exists file }
end
Expand All @@ -313,8 +308,8 @@ def test_remove_old_man_files
gemfile_5_ronn = File.join man, 'man5', 'gemfile.5.ronn'
gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt'

files_that_go = [bundle_b_1_txt, gemfile_5_txt]
files_that_stay = [ruby_1, bundle_b_1, bundle_b_1_ronn, gemfile_5, gemfile_5_ronn]
files_that_go = [bundle_b_1_txt, bundle_b_1_ronn, gemfile_5_txt, gemfile_5_ronn]
files_that_stay = [ruby_1, bundle_b_1, gemfile_5]

create_dummy_files(files_that_go + files_that_stay)

Expand Down