def append_to_doc(doc, content):
    """
    Append content to the doc string.

    Args:
        doc (str): The original doc string.
        content (str): The new doc string, which should be a standalone section.

    Returns:
        str: The modified doc string.
    """
    content = '\n'.join(l.rstrip() for l in content.split('\n'))
    content = content.lstrip('\n')
    content = content.rstrip('\n')

    # fast path: doc is empty, just wrap the content
    if not doc:
        # the empty line before the content might be required for the
        # sphinx to correctly parse the section.
        if not content.startswith('\n'):
            content = '\n' + content
        if not content.endswith('\n'):
            content = content + '\n'
        return content

    # slow path: doc is not empty, parse it
    # find the indent of the doc string.
    indent = 0
    for line in doc.split('\n'):
        if line and line.strip() and line.startswith(' '):
            for c in line:
                if c != ' ':
                    break
                indent += 1
            break
    indent = ' ' * indent

    # compose the docstring
    contents = [doc, '\n']
    if not doc.endswith('\n'):
        contents.append('\n')

    for line in content.split('\n'):
        if not line.strip():
            contents.append('\n')
        else:
            contents.append(indent + line + '\n')

    return ''.join(contents)