summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-05-12 14:19:54 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-05-12 14:19:54 -0500
commit9f4fa5f12e05899bb4c5ba19da353de6b47ccc33 (patch)
treecf2e3e7f0d358f4004b0e4fe1c77c3615a15c905
parent31297d10a33e095e2f4b523b99264f777eb0238d (diff)
downloadbundler-9f4fa5f12e05899bb4c5ba19da353de6b47ccc33.tar.gz
[Rakefile] Generate man/index in man:build
Results in the following: ``` Gemfile(5) gemfile.5 bundle(1) bundle.1 bundle-add(1) bundle-add.1 bundle-binstubs(1) bundle-binstubs.1 bundle-check(1) bundle-check.1 bundle-clean(1) bundle-clean.1 bundle-config(1) bundle-config.1 bundle-exec(1) bundle-exec.1 bundle-gem(1) bundle-gem.1 bundle-info(1) bundle-info.1 bundle-init(1) bundle-init.1 bundle-inject(1) bundle-inject.1 bundle-install(1) bundle-install.1 bundle-lock(1) bundle-lock.1 bundle-open(1) bundle-open.1 bundle-outdated(1) bundle-outdated.1 bundle-package(1) bundle-package.1 bundle-platform(1) bundle-platform.1 bundle-pristine(1) bundle-pristine.1 bundle-show(1) bundle-show.1 bundle-update(1) bundle-update.1 bundle-viz(1) bundle-viz.1 ```
-rw-r--r--Rakefile21
-rw-r--r--man/index.txt15
2 files changed, 19 insertions, 17 deletions
diff --git a/Rakefile b/Rakefile
index d9ffc70059..bb37a9666f 100644
--- a/Rakefile
+++ b/Rakefile
@@ -240,12 +240,15 @@ begin
namespace :man do
directory "man"
+ index = []
sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") }
sources.map do |basename|
ronn = "man/#{basename}.ronn"
- manual_section = ".1" unless basename =~ /.*(\d+)\Z/
+ manual_section = ".1" unless basename =~ /\.(\d+)\Z/
roff = "man/#{basename}#{manual_section}"
+ index << [ronn, File.basename(roff)]
+
file roff => ["man", ronn] do
sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}"
end
@@ -257,9 +260,23 @@ begin
task :build_all_pages => "#{roff}.txt"
end
+ file "index.txt" do
+ index.map! do |(ronn, roff)|
+ [File.read(ronn).split(" ").first, roff]
+ end
+ index = index.sort_by(&:first)
+ justification = index.map {|(n, _f)| n.length }.max + 4
+ File.open("man/index.txt", "w") do |f|
+ index.each do |name, filename|
+ f << name.ljust(justification) << filename << "\n"
+ end
+ end
+ end
+ task :build_all_pages => "index.txt"
+
task :clean do
leftovers = Dir["man/*"].reject do |f|
- File.extname(f) == ".ronn" || f == "man/index.txt"
+ File.extname(f) == ".ronn"
end
rm leftovers if leftovers.any?
end
diff --git a/man/index.txt b/man/index.txt
deleted file mode 100644
index e3b38c46db..0000000000
--- a/man/index.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Gemfile(5) gemfile.5
-bundle-install bundle-install.1
-bundle-update bundle-update.1
-bundle-package bundle-package.1
-bundle-exec bundle-exec.1
-bundle-config bundle-config.1
-bundle-platform bundle-platform.1
-bundle-gem bundle-gem.1
-bundle-clean bundle-clean.1
-bundle-check bundle-check.1
-bundle-init bundle-init.1
-bundle-inject bundle-inject.1
-bundle-open bundle-open.1
-bundle-show bundle-show.1
-bundle-viz bundle-viz.1