Skip to content

Commit 15f2cd4

Browse files
authored
fix: Remove type from property docstring summary in summary sections
PR-242: #242
1 parent 0ca64be commit 15f2cd4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/mkdocstrings_handlers/python/rendering.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,20 @@ def do_as_attributes_section(
539539
Returns:
540540
An attributes docstring section.
541541
"""
542+
543+
def _parse_docstring_summary(attribute: Attribute) -> str:
544+
if attribute.docstring is None:
545+
return ""
546+
line = attribute.docstring.value.split("\n", 1)[0]
547+
if ":" in line and attribute.docstring.parser_options.get("returns_type_in_property_summary", False):
548+
_, line = line.split(":", 1)
549+
return line
550+
542551
return DocstringSectionAttributes(
543552
[
544553
DocstringAttribute(
545554
name=attribute.name,
546-
description=attribute.docstring.value.split("\n", 1)[0] if attribute.docstring else "",
555+
description=_parse_docstring_summary(attribute),
547556
annotation=attribute.annotation,
548557
value=attribute.value, # type: ignore[arg-type]
549558
)

0 commit comments

Comments
 (0)