def pretty_exe_doc(program, parser, stack=1, under='-'):
    """
    Takes the name of a script and a parser that will give the help message for it.
    The module that called this function will then add a header to the docstring
    of the script, followed immediately by the help message generated
    by the OptionParser

    :param str program: Name of the program that we want to make the header
    :param optparser.Option parser: Either a parser or a callable with no arguments
                                    that will give the desired parser
    :param int stack: How far up the stack to get the docstring to change
    :param str under: The character you want for the program underline
    """

    if os.path.basename(sys.argv[0]) == 'sphinx-build':
        # Get the calling module
        mod = inspect.getmodule(inspect.stack()[stack][0])

        # Get parser
        _parser = parser() if '__call__' in dir(parser) else parser

        # Make the parser use the correct program
        _parser.set_usage(mod.__usage__.replace('%prog', program))

        # Modify docs by adding a header and usate
        mod.__doc__ = '\n'.join(['', program, under * len(program), '::', ''] +
                                ['    %s' % l for l in _parser.format_help().split('\n')]) + \
                                mod.__doc__
Takes the name of a script and a parser that will give the help message for it.
    The module that called this function will then add a header to the docstring
    of the script, followed immediately by the help message generated
    by the OptionParser

    :param str program: Name of the program that we want to make the header
    :param optparser.Option parser: Either a parser or a callable with no arguments
                                    that will give the desired parser
    :param int stack: How far up the stack to get the docstring to change
    :param str under: The character you want for the program underline