From 9f4fa5f12e05899bb4c5ba19da353de6b47ccc33 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Fri, 12 May 2017 14:19:54 -0500 Subject: [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 ``` --- Rakefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'Rakefile') 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 -- cgit v1.2.1