import re


def format_docstring(docstring):
    """
    Strips whitespace from docstrings (both on the ends, and in the middle, replacing
    all sequential occurrences of whitespace with a single space).
    """
    if not docstring:
        return ''
    return re.sub(r'\s+', ' ', docstring).strip()