import re


def normalize_summary(summary):
    """Return normalized docstring summary."""
    # Remove newlines
    summary = re.sub(r'\s*\n\s*', ' ', summary.rstrip())

    # Add period at end of sentence
    if (
        summary and
        (summary[-1].isalnum() or summary[-1] in ['"', "'"]) and
        (not summary.startswith('#'))
    ):
        summary += '.'

    return summary