Skip to content

feat: remove annotations for properties in attributes section of summary #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading