From bd596a1df9b02ab880347191f7c6ce4bce52fc00 Mon Sep 17 00:00:00 2001 From: Uchechukwu Orji Date: Tue, 4 Feb 2025 21:48:43 +0100 Subject: [PATCH] feat: remove annotations for properties in attributes summary section --- src/mkdocstrings_handlers/python/rendering.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mkdocstrings_handlers/python/rendering.py b/src/mkdocstrings_handlers/python/rendering.py index 836e4164..e298997a 100644 --- a/src/mkdocstrings_handlers/python/rendering.py +++ b/src/mkdocstrings_handlers/python/rendering.py @@ -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] )