From 69cff98e276fb86f92b6ed06affb1e49083304f9 Mon Sep 17 00:00:00 2001
From: Andre <maan@meins.(none)>
Date: Thu, 25 Jan 2007 20:56:34 +0100
Subject: [PATCH] command_util.sh: improve man page generation

Read the global tag SN (section name) and output simple *roff text.
---
 command_util.sh | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/command_util.sh b/command_util.sh
index ba5e99e2..d6626c25 100755
--- a/command_util.sh
+++ b/command_util.sh
@@ -51,6 +51,8 @@ read_header()
 			includes="$includes
 #include \"$file_name.h\""
 			;;
+		SN:)
+			section_name="$value"
 		esac
 	done
 	if test -z "$header_comment" -o -z "$c_file_comment" \
@@ -127,39 +129,30 @@ ${line# }"
 
 dump_man()
 {
-	echo "NAME"
-	printf "\t$name_txt - $desc_txt\n"
-	echo "SYNOPSIS"
-	printf "\t$syn_txt\n"
-	echo "DESCRIPTION"
+	echo ".SS \"$name_txt\""
+	echo "$desc_txt"
+	echo
+	echo "\\fBusage: \\fP$syn_txt"
+	echo
 	echo "$help_txt"
+	echo
 	if test -n "$perms_txt"; then
-		echo "PERMISSIONS"
+		echo -n "\\fBpermissions:\\fP "
 		if test "$perms_txt" = "0"; then
-			printf "\t(none)\n"
+			echo "(none)"
 		else
-			printf "\t$perms_txt\n"
+			echo "$perms_txt"
 		fi
 	fi
-
+	echo
 }
 
 
 com_man()
 {
-	local cn="$(grep ^codename Makefile.in)"
-	local ver="$(grep ^AC_INIT configure.ac \
-		| cut -f 2 -d ',')"
-	cn=${cn#*=}
-	ver=${ver# *[}
-	ver=${ver%]}
-	echo "r=paraslash-$ver (cn: $cn)"
 	local n
-	local txtdir=txt
-	local mandir=man/man1
-	local htmldir=html
-	local pfx="$1"
-	mkdir -p $txtdir $mandir $htmldir || exit 1
+	echo "[$section_name]"
+	echo
 	while : ; do
 		read_one_command
 		if test $ret -lt 0; then
@@ -168,12 +161,10 @@ com_man()
 		if test $ret -eq 0; then
 			break
 		fi
-		n=$pfx-$name_txt
-		echo "pfx: $pfx, name: $n"
-		dump_man > $txtdir/$n.txt
-		txt2man -t "$n" -r "$r"  < $txtdir/$n.txt \
-			| sed -e 1d > $mandir/$n.1
-		man2html $mandir/$n.1 > $htmldir/$n.html
+		dump_man #> $txtdir/$n.txt
+#		txt2man -t "$n" -r "$r"  < $txtdir/$n.txt \
+#			| sed -e 1d > $mandir/$n.1
+#		man2html $mandir/$n.1 > $htmldir/$n.html
 	done
 }
 
-- 
2.39.5