#!/bin/sh
MANDIR=debian/man
mkdir -p $MANDIR

VERSION=`dpkg-parsechangelog | awk '/^Version:/ {print $2}' | sed -e 's/^[0-9]*://' -e 's/-.*//' -e 's/[+~]dfsg$//'`
NAME=`grep "^Description:" debian/control | sed 's/^Description: *//' | head -n1`
PROGNAME=`grep "^Package:" debian/control | sed 's/^Package: *//' | head -n1`

AUTHOR=".SH AUTHOR\n \
This manpage was written by $DEBFULLNAME for the Debian distribution and\n \
can be used for any other usage of the program.\
"

# If program name is different from package name or title should be
# different from package short description change this here
progname=AlignSets.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Multiple aligns input sequences by group" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=AssemblePairs.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Assembles paired-end reads into a single sequence" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=BuildConsensus.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Builds a consensus sequence for each set of input sequences" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=ClusterSets.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Cluster sequences by group" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=CollapseSeq.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="emoves duplicate sequences from FASTA/FASTQ files" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=ConvertHeaders.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Converts sequence headers to the pRESTO format" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=EstimateError.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Calculates annotation set error rates" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=FilterSeq.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Filters sequences in FASTA/FASTQ files" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=MaskPrimers.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Removes primers and annotates sequences with primer and barcode identifiers" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=PairSeq.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Sorts and matches sequence records with matching coordinates across files" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=ParseHeaders.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Parses pRESTO annotations in FASTA/FASTQ sequence headers" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=ParseLog.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Parses records in the console log of pRESTO modules" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=SplitSeq.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Sorts, samples and splits FASTA/FASTQ sequence files" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=UnifyHeaders.py
help2man --no-info --no-discard-stderr --help-option=" --help" \
         --name="Unifies annotation fields based on grouping scheme" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

echo "$MANDIR/*.1" > debian/manpages

cat <<EOT
Please enhance the help2man output.
The following web page might be helpful in doing so:
    http://liw.fi/manpages/
EOT
