Skip to content

Commit

Permalink
fixup! feat: numpydoc parse unknown sections as admonitions
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 14, 2024
1 parent 3ab6c0f commit 721127a
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/griffe/docstrings/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,25 +820,31 @@ def parse(
elif _is_empty_line(lines[offset]):
current_section.append("")

# End of the docstring, wrap up.
elif is_end:
current_section.append(lines[offset])
_append_section(sections, current_section, admonition_title)
admonition_title = ""
current_section = []

# Dash line after regular, non-empty line.
elif is_end or _is_dash_line(lines[offset + 1]):
elif _is_dash_line(lines[offset + 1]):
# Finish reading current section.
if is_end:
current_section.append(lines[offset])
_append_section(sections, current_section, admonition_title)
admonition_title = ""
current_section = []
if not is_end:
# Start parsing new (known) section.
if line_lower in _section_kind:
reader = _section_reader[_section_kind[line_lower]]
section, offset = reader(docstring, offset=offset + 2, **options) # type: ignore[operator]
if section:
sections.append(section)
# Start parsing admonition.
else:
admonition_title = lines[offset]
offset += 1 # skip next dash line

# Start parsing new (known) section.
if line_lower in _section_kind:
admonition_title = ""
reader = _section_reader[_section_kind[line_lower]]
section, offset = reader(docstring, offset=offset + 2, **options) # type: ignore[operator]
if section:
sections.append(section)

# Start parsing admonition.
else:
admonition_title = lines[offset]
offset += 1 # skip next dash line

# Regular line.
else:
Expand Down

0 comments on commit 721127a

Please sign in to comment.