

def parse_lit(self, lines):
    '\n        Parse a string line-by-line delineating comments and code\n\n        :returns: An tuple of boolean/list-of-string pairs. True designates a\n            comment; False designates code.\n        '
    comment_char = '#'
    comment = re.compile('^\\s*{0}[ \\n]'.format(comment_char))
    section_test = (lambda val: bool(comment.match(val)))
    sections = []
    for (is_doc, group) in itertools.groupby(lines, section_test):
        if is_doc:
            text = [comment.sub('', i).rstrip('\r\n') for i in group]
        else:
            text = [i.rstrip('\r\n') for i in group]
        sections.append((is_doc, text))
    return sections

dataset/ETHPy150Open saltstack/salt/doc/_ext/saltdomain.py LiterateCoding.parse_lit/original