aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/man.rb
diff options
context:
space:
mode:
authorMartin Afanasjew2016-04-17 05:33:21 +0200
committerMartin Afanasjew2016-04-17 20:43:27 +0200
commit3680c4667f1a47000c0152ca34bc3af7c41825ac (patch)
tree3472665409394a743344b5ac6a39f8f34eeea5a7 /Library/Homebrew/cmd/man.rb
parentb4b53e5067f8bd0e7bdb37e537ba99a0bb73285f (diff)
downloadbrew-3680c4667f1a47000c0152ca34bc3af7c41825ac.tar.bz2
man: replace split header/footer with ERB template
Diffstat (limited to 'Library/Homebrew/cmd/man.rb')
-rw-r--r--Library/Homebrew/cmd/man.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb
index 112eff60d..164eca9b1 100644
--- a/Library/Homebrew/cmd/man.rb
+++ b/Library/Homebrew/cmd/man.rb
@@ -1,4 +1,5 @@
require "formula"
+require "erb"
module Homebrew
SOURCE_PATH = HOMEBREW_LIBRARY_PATH/"manpages"
@@ -38,22 +39,19 @@ module Homebrew
end
def build_man_page
- header = (SOURCE_PATH/"header.1.md").read
- footer = (SOURCE_PATH/"footer.1.md").read
+ template = (SOURCE_PATH/"brew.1.md.erb").read
commands = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}").
sort_by { |source_file| source_file.basename.sub(/\.(rb|sh)$/, "") }.
map { |source_file|
- source_file.read.
- split("\n").
+ source_file.read.lines.
grep(/^#:/).
map { |line| line.slice(2..-1) }.
- join("\n")
+ join
}.
- reject { |s| s.strip.empty? }.
- join("\n\n")
+ reject { |s| s.strip.empty? }
- header + commands + footer
+ ERB.new(template, nil, ">").result(binding)
end
def convert_man_page(markup, target)