def automodule(name, members=True):
    """ Generate reST automodule directive for the given module.

    :Examples:

    >>> automodule('my.test.module')
    '''
    .. automodule:: my.test.module
        :members:
    <BLANKLINE>
    '''

    """
    lines = [
        '',
        '.. automodule:: {}'.format(name),
    ]
    if members:
        lines.append('    :members:')

    lines.append('')
    return '\n'.join(lines)