diff --git a/src/pytkdocs/parsers/docstrings/google.py b/src/pytkdocs/parsers/docstrings/google.py index e2bf50f..7997e17 100644 --- a/src/pytkdocs/parsers/docstrings/google.py +++ b/src/pytkdocs/parsers/docstrings/google.py @@ -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