#!/bin/sh #-----------------------------------------------------------------------------# # Copyright (C) 1997-1998 The University of Melbourne. # This file may only be copied under the terms of the GNU General # Public Licence - see the file COPYING in the Mercury distribution. #-----------------------------------------------------------------------------# # # make_manpage: create Unix man page from help message. # # Usage: make_manpage # # This file takes the output of ` --help' # and turns it into a Unix-style man page by # massaging it a bit and inserting some extra stuff that is # the same for all the Mercury man pages. # Section headings must match /[A-Za-z ]*:/. # We insert the `.SH' command for them, # convert them to uppercase, and replace "USAGE" with "SYNOPSIS". # Option headings start with a tab and then a `-'. # We put them in bold, and indent them differently. program="$1" name="`basename $program `" quote="'" manpage="`$program --help 2>&1 \ | sed \ -e '/^[A-Za-z ]*:[ ]/s//.SH &\\ /' \ -e '/^[A-Za-z ]*:/s//.SH &\\ /' \ -e '/^ [^- ].*:/s/^ .*$/ .Ve\\ .B\\ .Vb 1\\ \\\\\\& &\\ .Ve\\ .Vb 2/' \ -e '/^ -/s/^ .*$/ .Ve\\ .B\\ .Vb 1\\ \\\\\\& &\\ .Ve\\ .Vb 2/' \ -e 's/\\\\& /\\\\\\& /' \ -e 's/^ / \\\\\\& /g' \ -e 's/^ //' \ | sed \ -e '/^.SH [A-Za-z ]*:/y/\ abcdefghijklmnopqrstuvwxyz:/\ ABCDEFGHIJKLMNOPQRSTUVWXYZ /' \ -e 's/^.SH USAGE/.SH SYNOPSIS/' \ `" uppername="$name" if echo "$manpage" | grep '^.SH ARGUMENTS' > /dev/null; then first_half="`echo \"$manpage\" | sed '/^.SH ARGUMENTS/,$d'`" last_half="`echo \"$manpage\" | sed -n '/^.SH ARGUMENTS/,$p'`" else first_half="`echo \"$manpage\" | sed '/^.SH OPTIONS/,$d'`" last_half="`echo \"$manpage\" | sed -n '/^.SH OPTIONS/,$p'`" fi cat <. .SH COPYRIGHT This program and its documentation are copyright by the University of Melbourne. They may be copied only under the terms of the GNU General Public License \- see the file COPYING in the Mercury distribution. .SH "SEE ALSO" .P The Mercury User's Guide. .P The GNU General Public License. .ex EOF