Skip to contentSkip to conversation

docs: conf.py: silence SyntaxWarning on js_splitter_code

PATCH Applied Quentin Schulz 2 participants 2 messages Jun 6, 2025 – Jun 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: conf.py: silence SyntaxWarning on js_splitter_code

From: Quentin Schulz <[email protected]>

The js_splitter_code string contains backslashes that Python tries to use as escape sequence but doesn't manage to, hence the following SyntaxWarning message:

documentation/conf.py:188: SyntaxWarning: invalid escape sequence '\p'
.split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}-]+/gu)

Considering that we want this to be sent verbatim to the JS, let's make this a raw string instead.

Fixes d4a98ee19e0c ("conf.py: tweak SearchEnglish to be hyphen-friendly")
---
 documentation/conf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
documentation/conf.py +1 -1
index ad60d911394561f16dc28b3d41329f08e6c0999b..1eca8756abac72d311b39144f65910d28b4e3aec 100644
@@ -182,7 +182,7 @@ class DashFriendlySearchEnglish(SearchEnglish):
     # Accept words that can include hyphens
     _word_re = re.compile(r'[\w\-]+')
 
-    js_splitter_code = """
+    js_splitter_code = r"""
 function splitQuery(query) {
     return query
         .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}-]+/gu)

---
base-commit: 406e8a8e30404c0538f5aa46f211540bae2b206b
change-id: 20250606-conf-syntax-warning-8593925b82b7

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>
#1 lore raw
Quoted 8 lines · Quentin Schulz

The js_splitter_code string contains backslashes that Python tries to use as escape sequence but doesn't manage to, hence the following SyntaxWarning message:

documentation/conf.py:188: SyntaxWarning: invalid escape sequence '\p'
.split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}-]+/gu)

[...]

Applied, thanks!

[1/1] docs: conf.py: silence SyntaxWarning on js_splitter_code

      commit: c1056672ef45b197136eb8815728d426337a5901

Best regards,

Signature · 1 line
Antonin Godard <[email protected]>