Skip to content

Commit e1d2dfc

Browse files
committed
fix: Warn when examples section is empty
Issue #194: mkdocstrings/mkdocstrings#194
1 parent 73990a1 commit e1d2dfc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/pytkdocs/parsers/docstrings/google.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,11 @@ def read_examples_section(self, lines: List[str], start_index: int) -> Tuple[Opt
429429
elif current_example:
430430
sub_sections.append((Section.Type.EXAMPLES, "\n".join(current_example)))
431431

432-
return Section(Section.Type.EXAMPLES, sub_sections), i
432+
if sub_sections:
433+
return Section(Section.Type.EXAMPLES, sub_sections), i
434+
435+
self.error(f"Empty examples section at line {start_index}")
436+
return None, i
433437

434438

435439
def is_empty_line(line) -> bool:

0 commit comments

Comments
 (0)