| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  | shopt -s nullglob | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  | SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Contributions/manpages" | 
					
						
							|  |  |  | TARGET_PATH="$HOMEBREW_REPOSITORY/share/man/man1" | 
					
						
							|  |  |  | LINKED_PATH="$HOMEBREW_PREFIX/share/man/man1" | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | die (){ | 
					
						
							|  |  |  |     echo $1 | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test "$1" = '--link' || \ | 
					
						
							|  |  |  | test "$1" = '-l' && { | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  |   [[ $TARGET_PATH == $LINKED_PATH ]] && exit 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for page in "$TARGET_PATH"/*.1 | 
					
						
							|  |  |  |   do | 
					
						
							|  |  |  |     ln -s $page $LINKED_PATH | 
					
						
							|  |  |  |   done | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  |   exit 0 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-16 15:14:20 +13:00
										 |  |  | /usr/bin/which ronn &>/dev/null || die "You need to \"gem install ronn\" and put it in your path." | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | test "$1" = '--server' || \ | 
					
						
							|  |  |  | test "$1" = '-s' && { | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  |   echo "Man page test server: http://localhost:1207/" | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  |   echo "Control-C to exit." | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  |   ronn --server $SOURCE_PATH/* | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  |   exit 0 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-06 14:18:15 -07:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-03 19:02:10 +01:00
										 |  |  | if test "$1" = '--verbose' || test "$1" = '-v' | 
					
						
							|  |  |  | then | 
					
						
							| 
									
										
										
										
											2010-06-03 22:29:20 -07:00
										 |  |  |   man brew | 
					
						
							| 
									
										
										
										
											2012-03-03 19:02:10 +01:00
										 |  |  | fi |