From 856cfbd90bf182418bf8cf47e2d26f0595fa947f 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 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 836e416..312baa4 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_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] )