Skip to content

Commit f798a1e

Browse files
committed
refactor: Allow first name in a separate signature to be highlighted as a function name
1 parent d62daa7 commit f798a1e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/mkdocstrings_handlers/python/rendering.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ def do_format_signature(
166166
),
167167
)
168168

169+
# Since we highlight the signature without `def`,
170+
# Pygments sees it as a function call and not a function definition.
171+
# The result is that the function name is not parsed as such,
172+
# but instead as a regular name: `n` CSS class instead of `nf`.
173+
# To fix it, we replace the first occurrence of an `n` CSS class
174+
# with an `nf` one, unless we found `nf` already.
175+
if signature.find('class="nf"') == -1:
176+
signature = signature.replace('class="n"', 'class="nf"', 1)
177+
169178
if stash:
170179
for key, value in stash.items():
171180
signature = re.sub(rf"\b{key}\b", value, signature)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy