Skip to content

Commit

Permalink
fix: Remove type from property docstring summary in summary sections
Browse files Browse the repository at this point in the history
PR-242: #242
  • Loading branch information
elfkuzco authored Feb 5, 2025
1 parent 0ca64be commit 15f2cd4
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_summary(attribute: Attribute) -> str:
if attribute.docstring is None:
return ""
line = attribute.docstring.value.split("\n", 1)[0]
if ":" in line and attribute.docstring.parser_options.get("returns_type_in_property_summary", False):
_, line = line.split(":", 1)
return line

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

0 comments on commit 15f2cd4

Please sign in to comment.