Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
igonro committed May 27, 2020
1 parent 9ee138c commit 9365643
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pytkdocs/parsers/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,20 @@ def read_examples_section(self, lines: List[str], start_index: int) -> Tuple[Opt
Returns:
A tuple containing a `Section` (or `None`) and the index at which to continue parsing.
"""

def auto_generate_code_blocks(example_text: str, lang: str = "python") -> str:
parsed_lines = []
example_lines = example_text.split("\n")
is_code_example = False
is_code_block = False
for i, line in enumerate(example_lines):
if line.lstrip().startswith('>>>') and not is_code_example and not is_code_block:
if line.lstrip().startswith(">>>") and not is_code_example and not is_code_block:
is_code_example = True
parsed_lines.append(line.replace(line.lstrip(), "") + "```" + lang)

parsed_lines.append(line)

if is_code_example and not line.lstrip().startswith('>>>') and not is_code_block:
if is_code_example and not line.lstrip().startswith(">>>") and not is_code_block:
if example_lines[i + 1].lstrip().startswith(">>>"):
continue
is_code_example = False
Expand Down

0 comments on commit 9365643

Please sign in to comment.