Parse text in cartouche format and return a reStructuredText equivalent

    Args:
        lines: A sequence of strings representing the lines of a single
            docstring as read from the source by Sphinx. This string should be
            in a format that can be parsed by cartouche.

    Returns:
        A list of lines containing the transformed docstring as
        reStructuredText as produced by cartouche.

    Raises:
        RuntimeError: If the docstring cannot be parsed.

def parse_cartouche_text(lines):
    '''Parse text in cartouche format and return a reStructuredText equivalent

    Args:
        lines: A sequence of strings representing the lines of a single
            docstring as read from the source by Sphinx. This string should be
            in a format that can be parsed by cartouche.

    Returns:
        A list of lines containing the transformed docstring as
        reStructuredText as produced by cartouche.

    Raises:
        RuntimeError: If the docstring cannot be parsed.
    '''
    indent_lines = unindent(lines)
    indent_lines = pad_blank_lines(indent_lines)
    indent_lines = first_paragraph_indent(indent_lines)
    indent_paragraphs = gather_lines(indent_lines)
    parse_tree = group_paragraphs(indent_paragraphs)
    syntax_tree = extract_structure(parse_tree)
    result = syntax_tree.render_rst()
    ensure_terminal_blank(result)
    return result