def group_functions(lines): """Yield lists of lines, where each list constitutes a single function declaration. """ current_function = [] for line in hashcomments.filter_out_comments(lines): if INITIAL_DECLARATION_REGEXP.match(line): continue if not line[0].isspace() and current_function: yield current_function current_function = [] current_function.append(line) if current_function: yield current_function