Skip to content

Commit b6c9893

Browse files
committed
feat: Add config option for annotations paths verbosity
1 parent fe16b54 commit b6c9893

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/mkdocstrings_handlers/python/handler.py

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class PythonHandler(BaseHandler):
7878
"docstring_section_style": "table",
7979
"members": None,
8080
"filters": ["!^_[^_]"],
81+
"annotations_path": "brief",
8182
}
8283
"""
8384
Attributes: Default rendering options:
@@ -88,6 +89,7 @@ class PythonHandler(BaseHandler):
8889
show_object_full_path (bool): Show the full Python path of objects that are children of the root object (for example, classes in a module). When False, `show_object_full_path` overrides. Default: `False`.
8990
show_category_heading (bool): When grouped by categories, show a heading for each category. Default: `False`.
9091
show_if_no_docstring (bool): Show the object heading even if it has no docstring or children with docstrings. Default: `False`.
92+
annotations_path: The verbosity for annotations path: `brief` (recommended), or `source` (as written in the source). Default: `"brief"`.
9193
show_signature (bool): Show method and function signatures. Default: `True`.
9294
show_signature_annotations (bool): Show the type annotations in method and function signatures. Default: `False`.
9395
separate_signature (bool): Whether to put the whole signature in a code block below the heading. Default: `False`.

src/mkdocstrings_handlers/python/templates/material/_base/expression.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
{%- elif original_expression is string -%}
77
{{ original_expression }}
88
{%- else -%}
9-
<span data-autorefs-optional{% if original_expression.full != original_expression.source %}-hover{% endif %}="{{ original_expression.full }}">{{ original_expression.source }}</span>
9+
{%- with annotation = original_expression|attr(config.annotations_path) -%}
10+
<span data-autorefs-optional{% if annotation != original_expression.full %}-hover{% endif %}="{{ original_expression.full }}">{{ annotation }}</span>
11+
{%- endwith -%}
1012
{%- endif -%}

0 commit comments

Comments
 (0)