Skip to content

Commit 856cfbd

Browse files
committed
feat: remove annotations for properties in attributes section
1 parent 0ca64be commit 856cfbd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/mkdocstrings_handlers/python/rendering.py

Lines changed: 10 additions & 1 deletion
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+
def _parse_docstring_description(attribute: Attribute) -> str:
543+
if attribute.docstring is None:
544+
return ""
545+
lines = attribute.docstring.value.lstrip().split("\n", 1)
546+
if ":" in lines[0]:
547+
_, line = lines[0].split(":", 1)
548+
lines = [line, *lines[1:]]
549+
return lines[0]
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_description(attribute),
547556
annotation=attribute.annotation,
548557
value=attribute.value, # type: ignore[arg-type]
549558
)

0 commit comments

Comments
 (0)