[m-rev.] diff: fix man-page formatting

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Oct 10 20:43:25 AEST 2002


This fixes a problem where the man page for "mmc"
was not properly formatting the sub-headings such as
"Optional feature compilation model options:" and "Debugging".

Branches: main
Estimated hours taken: 3

doc/make_manpage:
	Handle sub-headings better.

Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: doc/make_manpage
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/make_manpage,v
retrieving revision 1.8
diff -u -d -r1.8 make_manpage
--- doc/make_manpage	5 Feb 2002 12:06:14 -0000	1.8
+++ doc/make_manpage	10 Oct 2002 10:42:10 -0000
@@ -14,52 +14,63 @@
 # 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 ]*:/.
+# Section headings must match /[\/A-Za-z ]*:/.
 # We insert the `.SH' command for them,
-# convert them to uppercase, and replace "USAGE" with "SYNOPSIS".
+# convert them to uppercase, delete the ":",
+# and replace "USAGE" with "SYNOPSIS".
+
+# Section sub-headings start with spaces.
+# We insert the `.SH' command for them.
 
 # Option headings start with a tab and then a `-'.
 # We put them in bold, and indent them differently.
 
+# Each line of the main text must start with a tab.
+# We change the tab to "\&".
+
 program="$1"
 name="`basename $program `"
-quote="'"
 
-manpage="`$program --help 2>&1 \
+trap 'rm -f /tmp/make_manpage$$' 1 2 3 13 15
+$program --help 2>&1 \
 	| sed	\
-		-e '/^[\/A-Za-z ]*:[ 	]/s//.SH &\\
+		-e '/^[\/A-Za-z ]*:[ 	]/s//.SH "&"\
 /'			\
-		-e '/^[\/A-Za-z ]*:/s//.SH &\\
+		-e '/^[\/A-Za-z ]*:/s//.SH "&"\
 /'			\
-		-e '/^	[^-	].*:/s/^	.*$/	.Ve\\
-.B\\
-.Vb 1\\
-\\\\\\& &\\
-.Ve\\
+		-e '/^ .*/s//.SH "&"\
+/'			\
+		-e '/^	[^-	].*:/s/^	.*$/	.Ve\
+.B\
+.Vb 1\
+\\\& &\
+.Ve\
 .Vb 2/' 					\
-		-e '/^	-/s/^	.*$/	.Ve\\
-.B\\
-.Vb 1\\
-\\\\\\& &\\
-.Ve\\
+		-e '/^	-/s/^	.*$/	.Ve\
+.B\
+.Vb 1\
+\\\& &\
+.Ve\
 .Vb 2/' 					\
-		-e 's/\\\\& 	/\\\\\\& /' \
-		-e 's/^		/	\\\\\\&	/g' 	\
+		-e 's/\\& 	/\\\& /' \
+		-e 's/^		/	\\\&	/g' 	\
 		-e 's/^	//' \
 	| sed	\
-		-e '/^.SH [\/A-Za-z ]*:/y/\
+		-e '/^.SH "[\/A-Za-z ]*:[ 	]*"/y/\
 abcdefghijklmnopqrstuvwxyz:/\
 ABCDEFGHIJKLMNOPQRSTUVWXYZ /' \
-		-e 's/^.SH USAGE/.SH SYNOPSIS/' \
-	`"
+		-e 's/^.SH "USAGE[ 	]*"/.SH "SYNOPSIS"/' \
+	> /tmp/make_manpage$$ 
+manpage="`cat /tmp/make_manpage$$`"
+rm -f /tmp/make_manpage$$
 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'`"
+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'`"
+	first_half="`echo \"$manpage\" | sed '/^.SH \"OPTIONS *\"/,$d'`"
+	last_half="`echo \"$manpage\" | sed -n '/^.SH \"OPTIONS *\"/,$p'`"
 fi
 
 cat <<EOF
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list