Skip to content

Commit

Permalink
fix: Fix Google parser missing lines ending with colon
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 2, 2022
1 parent e5ac0bb commit 2f7969c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ def parse( # noqa: WPS231
)
)
else:
offset -= 1
with suppress(IndexError):
current_section.append(lines[offset])
else:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_docstrings/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ def test_multiline_docstring():
assert not warnings


def test_unknown_matching_admonitions():
"""Properly handle offset when matching an unknown admonition (line ending with `:`)."""
docstring = """
First line.
Matching but unknown admonition type:
- Some list items
Ending line.
"""
sections, warnings = parse(docstring)
assert len(sections) == 1
assert sections[0].kind is DocstringSectionKind.text
# -2 because docstring is stripped
assert len(sections[0].value.splitlines()) == len(docstring.splitlines()) - 2
assert not warnings


def test_multiple_lines_in_sections_items():
"""Parse multi-line item description."""
docstring = """
Expand Down

0 comments on commit 2f7969c

Please # to comment.