def section(name, underline_char='='):
    """ Generate reST section directive with the given underline.

    :Examples:

    >>> section('My section')
    '''
    My section
    ==========
    <BLANKLINE>
    '''

    >>> section('Subsection', '~')
    '''
    Subsection
    ~~~~~~~~~~
    <BLANKLINE>
    '''

    """
    name_len  = len(name)
    return '\n'.join((
        '',
        name,
        underline_char * name_len,
        '',
    ))