aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions/cmds/brew-man
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Contributions/cmds/brew-man')
-rwxr-xr-xLibrary/Contributions/cmds/brew-man51
1 files changed, 51 insertions, 0 deletions
diff --git a/Library/Contributions/cmds/brew-man b/Library/Contributions/cmds/brew-man
new file mode 100755
index 000000000..8afe2029d
--- /dev/null
+++ b/Library/Contributions/cmds/brew-man
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+shopt -s nullglob
+
+SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Contributions/manpages"
+TARGET_PATH="$HOMEBREW_REPOSITORY/share/man/man1"
+LINKED_PATH="$HOMEBREW_PREFIX/share/man/man1"
+
+
+die (){
+ echo $1
+ exit 1
+}
+
+test "$1" = '--link' || \
+test "$1" = '-l' && {
+ [[ $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 "Man page test server: http://localhost:1207/"
+ echo "Control-C to exit."
+ ronn --server $SOURCE_PATH/*
+ exit 0
+}
+
+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
+
+if test "$1" = '--verbose' || test "$1" = '-v'
+then
+ man brew
+fi