def join_match_funcdef(tokens):
    """Join the pieces of a pattern-matching function together."""
    if len(tokens) == 2:
        (func, insert_after_docstring), body = tokens
        docstring = None
    elif len(tokens) == 3:
        (func, insert_after_docstring), docstring, body = tokens
    else:
        raise CoconutInternalException("invalid docstring insertion tokens", tokens)
    # insert_after_docstring and body are their own self-contained suites, but we
    # expect them to both be one suite, so we have to join them together
    insert_after_docstring, dedent = split_trailing_indent(insert_after_docstring)
    indent, body = split_leading_indent(body)
    indentation = collapse_indents(dedent + indent)
    return (
        func
        + (docstring if docstring is not None else "")
        + insert_after_docstring
        + indentation
        + body
    )
def join_match_funcdef ( tokens ) : if len ( tokens ) == 2 : ( func , insert_after_docstring ) , body = tokens docstring = None elif len ( tokens ) == 3 : ( func , insert_after_docstring ) , docstring , body = tokens else : raise CoconutInternalException ( "invalid docstring insertion tokens" , tokens ) insert_after_docstring , dedent = split_trailing_indent ( insert_after_docstring ) indent , body = split_leading_indent ( body ) indentation = collapse_indents ( dedent + indent ) return ( func + ( docstring if docstring is not None else "" ) + insert_after_docstring + indentation + body )
Join the pieces of a pattern-matching function together.