From 73f11dcc584a672af7e17738cba08a50f119176a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Sat, 19 Oct 2024 19:49:04 +0200 Subject: [PATCH] fix: Always render cross-references outside of signatures Issue-mkdocstrings#700: https://github.com/mkdocstrings/mkdocstrings/issues/700 --- .../material/_base/expression.html.jinja | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja index c34c0be..4aea143 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/expression.html.jinja @@ -32,15 +32,16 @@ which is a tree-like structure representing a Python expression. {%- set annotation = full -%} {%- endif -%} {%- for title, path in annotation|split_path(full) -%} - {%- if config.signature_crossrefs -%} - {%- if signature -%} - {%- filter stash_crossref(length=title|length) -%} - {{ title }} - {%- endfilter -%} - {%- else -%} + {%- if not signature -%} + {#- Always render cross-references outside of signatures. We don't need to stash them. -#} + {{ title }} + {%- elif config.signature_crossrefs -%} + {#- We're in a signature and cross-references are enabled, we must render one and stash it. -#} + {%- filter stash_crossref(length=title|length) -%} {{ title }} - {%- endif -%} + {%- endfilter -%} {%- else -%} + {#- We're in a signature but cross-references are disabled, we just render the title. -#} {{ title }} {%- endif -%} {%- if not loop.last -%}.{%- endif -%}