Skip to content

Commit

Permalink
Separate man page for brew-man
Browse files Browse the repository at this point in the history
Also, revise main man page, and update brew-man command to handle
multiple input files.
  • Loading branch information
adamv committed Nov 7, 2010
1 parent d26b4f6 commit 06294a8
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 166 deletions.
30 changes: 22 additions & 8 deletions Library/Contributions/examples/brew-man
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

set -e
shopt -s nullglob

man1_suffix="share/man/man1/brew.1"
source_path="$HOMEBREW_REPOSITORY/Library/Contributions/manpages"
target_file="$HOMEBREW_REPOSITORY/$man1_suffix"
SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Contributions/manpages"
TARGET_PATH="$HOMEBREW_REPOSITORY/share/man/man1"
LINKED_PATH="$HOMEBREW_PREFIX/share/man/man1"


die (){
Expand All @@ -14,22 +15,35 @@ die (){

test "$1" = '--link' || \
test "$1" = '-l' && {
ln -s "$target_file" "$HOMEBREW_PREFIX/$man1_suffix"
[[ $TARGET_PATH == $LINKED_PATH ]] && exit 0

for page in "$TARGET_PATH"/*.1
do
ln -s $page $LINKED_PATH
done
exit 0
}

/usr/bin/which -s ronn || die "You need to \"gem install ronn\" and put it in your path."

test "$1" = '--server' || \
test "$1" = '-s' && {
echo "Manpage test server: http://localhost:1207/"
echo "Man page test server: http://localhost:1207/"
echo "Control-C to exit."
ronn --server $source_path/*
ronn --server $SOURCE_PATH/*
exit 0
}

echo "Writing manpage to $target_file"
ronn --roff --pipe --organization='Homebrew' --manual='brew' $source_path/brew.1.md > $target_file
echo "Writing manpages to $TARGET_PATH"

for i in "$SOURCE_PATH"/*.md
do
# Get the filename only, without the .md extension
j=`basename $i`
target_file="$TARGET_PATH/${j%\.md}"

ronn --roff --pipe --organization='Homebrew' --manual='brew' $i > $target_file
done

test "$1" = '--verbose' || \
test "$1" = '-v' && {
Expand Down
43 changes: 43 additions & 0 deletions Library/Contributions/manpages/brew-man.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
brew-man(1) -- Generate man pages for Homebrew
==============================================

## SYNOPSIS

`brew man` [--verbose]
`brew man` --link
`brew man` --server

## DESCRIPTION

Generates man pages for Homebrew using [`ronn`][ronn].

`brew man` by itself updates the man pages from the source files.

With `--link`, symlinks generated man pages to `share/man` under
the Homebrew Prefix.

With `--server`, starts ronn's dev server.


[ronn]: http://rtomayko.github.com/ronn/
"Ronn"

## OPTIONS
* `-v`, `--verbose`:
Run `man brew` after generating man pages.

* `-l`, `--link`:
Creates symlinks from the generated man pages to the Homebrew Prefix,
typically `/usr/local`. Useful when Homebrew itself is not installed
directly into `/usr/local`.

* `-s`, `--server`:
Starts ronn's test server.

## SEE ALSO

`brew`(1)

## BUGS

See Issues on GitHub: <http://github.com/mxcl/homebrew/issues>
Loading

0 comments on commit 06294a8

Please sign in to comment.