Skip to content

Commit

Permalink
feat: remove annotations for properties in attributes section
Browse files Browse the repository at this point in the history
  • Loading branch information
elfkuzco committed Feb 4, 2025
1 parent 0ca64be commit 856cfbd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/mkdocstrings_handlers/python/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,20 @@ def do_as_attributes_section(
Returns:
An attributes docstring section.
"""
def _parse_docstring_description(attribute: Attribute) -> str:
if attribute.docstring is None:
return ""
lines = attribute.docstring.value.lstrip().split("\n", 1)
if ":" in lines[0]:
_, line = lines[0].split(":", 1)
lines = [line, *lines[1:]]
return lines[0]

return DocstringSectionAttributes(
[
DocstringAttribute(
name=attribute.name,
description=attribute.docstring.value.split("\n", 1)[0] if attribute.docstring else "",
description=_parse_docstring_description(attribute),
annotation=attribute.annotation,
value=attribute.value, # type: ignore[arg-type]
)
Expand Down

0 comments on commit 856cfbd

Please sign in to comment.