def get_docstring_and_rest(filename):
with open(filename) as f:<EOL><INDENT>content = f.read()<EOL><DEDENT>node = ast.parse(content)<EOL>if not isinstance(node, ast.Module):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>".format(node.__class__.__name__))<EOL><DEDENT>if node.body and isinstance(node.body[<NUM_LIT:0>], ast.Expr) andisinstance(node.body[<NUM_LIT:0>].value, ast.Str):<EOL><INDENT>docstring_node = node.body[<NUM_LIT:0>]<EOL>docstring = docstring_node.value.s<EOL>rest = content.split('<STR_LIT:\n>', docstring_node.lineno)[-<NUM_LIT:1>]<EOL>return docstring, rest<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>.format(filename))<EOL><DEDENT>
Separate `filename` content between docstring and the rest

    Strongly inspired from ast.get_docstring.

    Returns
    -------
    docstring: str
        docstring of `filename`
    rest: str
        `filename` content without the docstring