diff --git a/src/example.py b/src/example.py index 86496060aa7c694e0ff8576dda210a0ab831475e..3eac41504e23eee2e7c5b72a9e9fe06d6f5680de 100644 --- a/src/example.py +++ b/src/example.py @@ -29,10 +29,17 @@ def is_body_of_example(line: str): Returns true if the line is part of the body of an example. ''' return line == "" or \ + line.startswith("\n") or \ line.startswith(".") or \ line.startswith("#") or \ line.startswith(" ") or \ bool(re.match(r'^[a-zA-Z_]*:',line)) + +def is_last_line(line: str, txt): + ''' + Returns true if it is the last line of the text. + ''' + return line == txt[len(txt)-1] def get_example_file_name(line: str): ''' @@ -88,6 +95,8 @@ def parse_all_examples(txt): new_example = "# " + filename + "\n" + linetext elif new_example != "" and is_body_of_example(linetext): new_example = new_example + "\n" + linetext + if is_last_line(line, txt): + res.append(Example(filename, new_example)) elif len(new_example) > 0: res.append(Example(filename, new_example)) new_example = ""