diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb
index 112eff60dc..164eca9b12 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)
diff --git a/Library/Homebrew/manpages/footer.1.md b/Library/Homebrew/manpages/brew.1.md.erb
similarity index 88%
rename from Library/Homebrew/manpages/footer.1.md
rename to Library/Homebrew/manpages/brew.1.md.erb
index 5ff6656a7b..5fc1d7e6dd 100644
--- a/Library/Homebrew/manpages/footer.1.md
+++ b/Library/Homebrew/manpages/brew.1.md.erb
@@ -1,4 +1,43 @@
+brew(1) -- The missing package manager for OS X
+===============================================
+## SYNOPSIS
+
+`brew` `--version`
+`brew` [`--verbose`|`-v`] [] [] ...
+
+## DESCRIPTION
+
+Homebrew is the easiest and most flexible way to install the UNIX tools Apple
+didn't include with OS X.
+
+## ESSENTIAL COMMANDS
+
+For the full command list, see the [COMMANDS][] section.
+
+With `--verbose` or `-v`, many commands print extra debugging information. Note that these flags should only appear after a command.
+
+ * `install` :
+ Install .
+
+ * `remove` :
+ Uninstall .
+
+ * `update`:
+ Fetch the newest version of Homebrew from GitHub using `git`(1).
+
+ * `list`:
+ List all installed formulae.
+
+ * `search` |`/``/`:
+ Perform a substring search of formula names for . If is
+ surrounded with slashes, then it is interpreted as a regular expression.
+ The search for is extended online to some popular taps.
+ If no search term is given, all locally available formulae are listed.
+
+## COMMANDS
+
+<%= commands.join("\n") %>
* `--cache`:
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
diff --git a/Library/Homebrew/manpages/header.1.md b/Library/Homebrew/manpages/header.1.md
deleted file mode 100644
index 7caf028db9..0000000000
--- a/Library/Homebrew/manpages/header.1.md
+++ /dev/null
@@ -1,38 +0,0 @@
-brew(1) -- The missing package manager for OS X
-===============================================
-
-## SYNOPSIS
-
-`brew` `--version`
-`brew` [`--verbose`|`-v`] [] [] ...
-
-## DESCRIPTION
-
-Homebrew is the easiest and most flexible way to install the UNIX tools Apple
-didn't include with OS X.
-
-## ESSENTIAL COMMANDS
-
-For the full command list, see the [COMMANDS][] section.
-
-With `--verbose` or `-v`, many commands print extra debugging information. Note that these flags should only appear after a command.
-
- * `install` :
- Install .
-
- * `remove` :
- Uninstall .
-
- * `update`:
- Fetch the newest version of Homebrew from GitHub using `git`(1).
-
- * `list`:
- List all installed formulae.
-
- * `search` |`/``/`:
- Perform a substring search of formula names for . If is
- surrounded with slashes, then it is interpreted as a regular expression.
- The search for is extended online to some popular taps.
- If no search term is given, all locally available formulae are listed.
-
-## COMMANDS