Skip to content

Commit

Permalink
feat: Add config option for annotations paths verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Apr 30, 2022
1 parent fe16b54 commit b6c9893
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/mkdocstrings_handlers/python/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class PythonHandler(BaseHandler):
"docstring_section_style": "table",
"members": None,
"filters": ["!^_[^_]"],
"annotations_path": "brief",
}
"""
Attributes: Default rendering options:
Expand All @@ -88,6 +89,7 @@ class PythonHandler(BaseHandler):
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`.
show_category_heading (bool): When grouped by categories, show a heading for each category. Default: `False`.
show_if_no_docstring (bool): Show the object heading even if it has no docstring or children with docstrings. Default: `False`.
annotations_path: The verbosity for annotations path: `brief` (recommended), or `source` (as written in the source). Default: `"brief"`.
show_signature (bool): Show method and function signatures. Default: `True`.
show_signature_annotations (bool): Show the type annotations in method and function signatures. Default: `False`.
separate_signature (bool): Whether to put the whole signature in a code block below the heading. Default: `False`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
{%- elif original_expression is string -%}
{{ original_expression }}
{%- else -%}
<span data-autorefs-optional{% if original_expression.full != original_expression.source %}-hover{% endif %}="{{ original_expression.full }}">{{ original_expression.source }}</span>
{%- with annotation = original_expression|attr(config.annotations_path) -%}
<span data-autorefs-optional{% if annotation != original_expression.full %}-hover{% endif %}="{{ original_expression.full }}">{{ annotation }}</span>
{%- endwith -%}
{%- endif -%}

0 comments on commit b6c9893

Please sign in to comment.