Sets up the argument parser and returns it

    :returns: the parser
    :rtype: :class:`argparse.ArgumentParser`
    :raises: None

def setup_argparse():
    """Sets up the argument parser and returns it

    :returns: the parser
    :rtype: :class:`argparse.ArgumentParser`
    :raises: None
    """

    parser = argparse.ArgumentParser(
        description="Builds the documentaion. First it runs gendoc to create rst files\
        for the source code. Then it runs sphinx make.\
        WARNING: this will delete the contents of the output dirs. You can use -nod.")
    ipath = os.path.join(thisdir, '../src')
    ipath = os.path.abspath(ipath)
    idefault = [ipath]
    parser.add_argument('-i', '--input', nargs='+', default=idefault,
                        help='list of input directories. gendoc is called for every\
                        source dir.\
                        Default is \'%s\'.' % ', '.join(idefault))
    opath = os.path.join(thisdir, 'reference')
    opath = os.path.abspath(opath)
    odefault = [opath]
    parser.add_argument('-o', '--output', nargs='+', default=odefault,
                        help='list of output directories. if you have multiple source\
                        directories, the corresponding output directorie is used.\
                        if there are less dirs than for source, the last output dir\
                        is used for the remaining source dirs.\
                        WARNING: the output directories are emptied by default. See -nod.\
                        Default is \'%s\'.' % ', '.join(odefault))
    gadefault = ['-T', '-f', '-e', '-o']
    parser.add_argument('-ga', '--gendocargs', nargs='*', default=gadefault,
                        help="list of arguments to pass to gendoc. use -gh for info.\
                        Default is \'%s\'" % ', '.join(gadefault))
    parser.add_argument('-nod', '--nodelete', action='store_true',
                        help='Do not empty the output directories first.')
    parser.add_argument('-gh', '--gendochelp', action='store_true',
                        help='print the help for gendoc and exit')
    return parser