3 # pod2manpage - convert pod file into manual page
5 # Copyright 2009-2014 Joachim Wiedorn <joodevel at joonet.de>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 if ! test /usr/bin/pod2man; then
25 echo "$0: Programm pod2man not found on the system!"
26 echo "$0: Please install perl (>= 5.6.0) on your system."
31 echo "Usage: $0 <manpage.pod>"
33 echo " The file manpage.pod needs a header with six lines:"
35 echo " manpage: <program name>"
36 echo " section: <manpage section>"
37 echo " title: <title string>"
38 echo " version: <version number>"
39 echo " datum: <modification date>"
44 if ! test -e "$1"; then
45 echo "$0: File $1 not found - Abort!"
49 NAME=`echo "$1" | sed -e 's/\.pod$//g'`
50 if ! test -e "${NAME}.pod"; then
51 echo "$0: File $1 is not a podfile - Abort!"
57 manpage=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
59 section=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
61 title=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
63 version=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
65 datum=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
67 # check for utf8 encoding
69 if [ `head -n20 $1 | grep ^=encoding | grep -c -i utf` -eq 1 ]; then
73 # convert pod to manpage
74 pod2man --section="$section" --center "$title" \
75 --release="$version" --date="$datum" ${mycoding} \
76 ${NAME}.pod ${NAME}.${section}
78 #man ./${NAME}.${section}
79 echo "Manpage ${NAME}.${section} created."