summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Nilsson <troglobit@gmail.com>2019-09-28 14:16:01 +0200
committerJoachim Nilsson <troglobit@gmail.com>2019-09-28 14:16:01 +0200
commit914767589b901311c14c07e59d899bfe6d644ec9 (patch)
treee5b2900d58d4deb73e91084c9883776c6ce5ccb1
parent801be8857437f5bf9e78e913bb80e2c19159576b (diff)
downloadlibnet-914767589b901311c14c07e59d899bfe6d644ec9.tar.gz
Add missing fixmanpages script, lost after big merge
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
-rwxr-xr-xdoc/fixmanpages72
1 files changed, 72 insertions, 0 deletions
diff --git a/doc/fixmanpages b/doc/fixmanpages
new file mode 100755
index 0000000..f4f0081
--- /dev/null
+++ b/doc/fixmanpages
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# Doxygen's man page generation is unfortunately very rudimentary.
+#
+# So in addition to creating the libnet(3) and the libnet-config(1) man page
+# from two pod files, this (over-documented) script will also try to add a few
+# "finishing touches" to the two (or three or more) man pages generated by Doxygen.
+#
+# It will run after building libnet and after Doxygen generated all its
+# documentations. If you ever have to run it manually, you should do the same.
+# Apart from a few widely available GNU utilities, you'll also need pod2man
+# (aka libpod-latex-perl) to get it to work.
+
+echo "Finalizing man pages..."
+
+MANPAGENOTE='.SH "SEE ALSO"\n\.IX Header "SEE ALSO"\nlibnet(3), libnet\-config(1)\n.SH "AUTHORS"\n.IX Header "AUTHORS"\nThe original author of libnet is Mike D. Schiffman.\n.PP\nlibnet has been maintained and extensively enhanced since 2009 by Sam Roberts.\n.PP\nIt is currently maintained by Ali Abdulkadir and available at\n.PP\n.Vb 1\n\& <https://github.com/sgeto/libnet>\n.Ve\n.SH "BUGS"\n.IX Header "BUGS"\nFor bugs, questions, patch submissions, desirable enhancements, etc. see:\n.PP\n.Vb 1\n\& <https://github.com/sgeto/libnet/issues>\n.Ve\n.SH "COPYRIGHT"\n.IX Header "COPYRIGHT"\nlibnet is licensed under the 3\-Clause \s-1BSD\s0 License. You can basically\ndo whatever you want with it.'
+
+die() {
+ echo "$*" 1>&2
+ exit 1
+}
+
+MANDIR=$1
+if test x"$MANDIR" = x ; then
+ MANDIR=man/
+fi
+
+test -d $MANDIR/man3 || die "Could not locate $MANDIR/man3 directory."
+test -d $MANDIR/man1 || mkdir $MANDIR/man1 || die "Could not create $MANDIR/man1 directory."
+
+# For now, I will let Doxygen still produces its useless and totally misleading
+# man page for "libnet.h" and simply delete it now. That's mostly because not
+# doing so will also remove all references to "libnet.h" in all documentations.
+# And we wouldn't want that, would we?
+find $MANDIR/man3/ -name "libnet.h.3" -exec sh -c 'rm -f "$1"' _ {} \;
+
+# Let's create libnet.3 and the libnet-config.3 before dealing with the rest.
+# BTW: We're using this hideous date format because Doxygen generated man
+# pages have them set like this and our date format shouldn't look different.
+
+pod2man -d "$(date +%a\ %b\ %d\ %C%y)" -n LIBNET -c "libnet Programmers Guide" -s 3 -r "libnet-1.2-rc3" ../doc/libnet.Pod man/man3/libnet.3 || die "Could not create libnet.3 in $MANDIR/man/man3."
+
+# pod2html --title="libnet Programmers Guide" --noindex --infile=libnet.Pod --outfile=libnet.html
+
+pod2man -d "$(date +%a\ %b\ %d\ %C%y)" -n LIBNET-CONFIG -c "General Commands Manual" -s 1 -r "libnet-1.2-rc3" ../doc/libnet-config.Pod man/man1/libnet-config.1 || die "Could not create libnet-config.1 in $MANDIR/man/man1."
+
+cd "$MANDIR/man3" || die "Could not cd into $MANDIR/man3"
+
+# A little housekeeping...
+(find . -name "_*" -exec sh -c 'rm "$1"' _ {} \;) || die "could not remove all underscore-prefixed items"
+
+# renaming all man pages form "*.h.3" to just "*.3"
+(find . -name "*.h.3" -exec sh -c 'mv "$1" "${1%.h.3}.3"' _ {} \;) || die "could not rename all .h.3-suffixed items"
+
+# Changing the name of the man pages to all UPPERCASE.
+# FIXME make Doxygen properly generate docs for all other
+# libnet-*.h files and add them here
+sed -i -e '1!b;s/libnet\/libnet-functions\.h/LIBNET-FUNCTIONS/' libnet-functions.3
+sed -i -e '1!b;s/libnet\/libnet-macros\.h/LIBNET-MACROS/' libnet-macros.3
+
+# Adjusting version string, changing the title, removing both the path and
+# the ".h" extension from name section as well as adding a few more sections
+# to the end.
+for MAN in $(find . -name "libnet-*.3"); do
+ sed -i -e '1!b;s/Version\ /libnet-/' \
+ -e '1!b;s/"libnet"/"libnet\ Programmers \Guide"/' $MAN
+ sed -i -e '5 s/libnet\///' \
+ -e '/.SH "Author"/,/from the source code\&./c \nBe' $MAN
+ echo -e $MANPAGENOTE >> $MAN
+done
+
+echo "Done."