man: replace split header/footer with ERB template
This commit is contained in:
parent
b4b53e5067
commit
3680c4667f
@ -1,4 +1,5 @@
|
|||||||
require "formula"
|
require "formula"
|
||||||
|
require "erb"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
SOURCE_PATH = HOMEBREW_LIBRARY_PATH/"manpages"
|
SOURCE_PATH = HOMEBREW_LIBRARY_PATH/"manpages"
|
||||||
@ -38,22 +39,19 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_man_page
|
def build_man_page
|
||||||
header = (SOURCE_PATH/"header.1.md").read
|
template = (SOURCE_PATH/"brew.1.md.erb").read
|
||||||
footer = (SOURCE_PATH/"footer.1.md").read
|
|
||||||
|
|
||||||
commands = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}").
|
commands = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}").
|
||||||
sort_by { |source_file| source_file.basename.sub(/\.(rb|sh)$/, "") }.
|
sort_by { |source_file| source_file.basename.sub(/\.(rb|sh)$/, "") }.
|
||||||
map { |source_file|
|
map { |source_file|
|
||||||
source_file.read.
|
source_file.read.lines.
|
||||||
split("\n").
|
|
||||||
grep(/^#:/).
|
grep(/^#:/).
|
||||||
map { |line| line.slice(2..-1) }.
|
map { |line| line.slice(2..-1) }.
|
||||||
join("\n")
|
join
|
||||||
}.
|
}.
|
||||||
reject { |s| s.strip.empty? }.
|
reject { |s| s.strip.empty? }
|
||||||
join("\n\n")
|
|
||||||
|
|
||||||
header + commands + footer
|
ERB.new(template, nil, ">").result(binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_man_page(markup, target)
|
def convert_man_page(markup, target)
|
||||||
|
|||||||
@ -1,4 +1,43 @@
|
|||||||
|
brew(1) -- The missing package manager for OS X
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
|
||||||
|
`brew` `--version`<br>
|
||||||
|
`brew` <command> [`--verbose`|`-v`] [<options>] [<formula>] ...
|
||||||
|
|
||||||
|
## 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` <formula>:
|
||||||
|
Install <formula>.
|
||||||
|
|
||||||
|
* `remove` <formula>:
|
||||||
|
Uninstall <formula>.
|
||||||
|
|
||||||
|
* `update`:
|
||||||
|
Fetch the newest version of Homebrew from GitHub using `git`(1).
|
||||||
|
|
||||||
|
* `list`:
|
||||||
|
List all installed formulae.
|
||||||
|
|
||||||
|
* `search` <text>|`/`<text>`/`:
|
||||||
|
Perform a substring search of formula names for <text>. If <text> is
|
||||||
|
surrounded with slashes, then it is interpreted as a regular expression.
|
||||||
|
The search for <text> is extended online to some popular taps.
|
||||||
|
If no search term is given, all locally available formulae are listed.
|
||||||
|
|
||||||
|
## COMMANDS
|
||||||
|
|
||||||
|
<%= commands.join("\n") %>
|
||||||
|
|
||||||
* `--cache`:
|
* `--cache`:
|
||||||
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
|
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
|
||||||
@ -1,38 +0,0 @@
|
|||||||
brew(1) -- The missing package manager for OS X
|
|
||||||
===============================================
|
|
||||||
|
|
||||||
## SYNOPSIS
|
|
||||||
|
|
||||||
`brew` `--version`<br>
|
|
||||||
`brew` <command> [`--verbose`|`-v`] [<options>] [<formula>] ...
|
|
||||||
|
|
||||||
## 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` <formula>:
|
|
||||||
Install <formula>.
|
|
||||||
|
|
||||||
* `remove` <formula>:
|
|
||||||
Uninstall <formula>.
|
|
||||||
|
|
||||||
* `update`:
|
|
||||||
Fetch the newest version of Homebrew from GitHub using `git`(1).
|
|
||||||
|
|
||||||
* `list`:
|
|
||||||
List all installed formulae.
|
|
||||||
|
|
||||||
* `search` <text>|`/`<text>`/`:
|
|
||||||
Perform a substring search of formula names for <text>. If <text> is
|
|
||||||
surrounded with slashes, then it is interpreted as a regular expression.
|
|
||||||
The search for <text> is extended online to some popular taps.
|
|
||||||
If no search term is given, all locally available formulae are listed.
|
|
||||||
|
|
||||||
## COMMANDS
|
|
||||||
Loading…
x
Reference in New Issue
Block a user