#! /bin/csh -f
#
# makeman [-d description] filename functions...
#
# Make a section 3 man page (called "function.3") for the given 'functions'.
# [The first non-flag argument is taken to be the name of the man page. dgl]
# Typically, you'll copy this file to some source code directory
# and tweak it as necessary.
# Remember to change appropriate contents below (organization, author, etc).
# Makeman calls 'cman', which presumes that an up to date tags file exists.
# Crude but useful.
#
# Michael Hawley (dagobah!mike)
# Lucasfilm Ltd.  May 1984

if ($#argv >= 1 && "$1" == "-d") then
	set Desc = " \- $2"
	shift
	shift
else
	set Desc = ""
endif

if ($#argv == 0) then
	set Output = $0.3
else
	set Output = $1.3
endif
shift

set last = $argv[${#argv}]
				# print header of man page
cat > $Output << EOF
.TH $1 3  "CARL"
.UC 4
.SH NAME
EOF

foreach i ($*)
	echo -n "$i" >> $Output
	if ($i != $last) echo -n ", " >> $Output
end
	# you'll want to change some of the following text:
cat >> $Output << EOF
$Desc
.SH SYNOPSIS
.ft CW
Player file.P
.br
#include <carl/Player.h>
.ft R

.PP
.SH DESCRIPTION
EOF
cman $* >> $Output	# insert function descriptions
	# print trailer for man page
cat >> $Output << EOF
.SH "SEE ALSO"
\fIPlayer\fP, by Gareth Loy, internal publication of the Center for
Music Experiment.
.SH AUTHOR
Gareth Loy, CARL
sdcarl!dgl
EOF
