diff mbox series

[1/3] conf.py: properly escape backslashes for latex_elements

Message ID 20240328-yocto-patches-v1-1-1124fa0bc532@theobroma-systems.com
State New
Headers show
Series new yocto-patches ML + some typo/syntax fixes | expand

Commit Message

Quentin Schulz March 28, 2024, 3:07 p.m. UTC
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>

There are some syntax warnings returned by Python:
"""
yocto-docs/documentation/conf.py:162: SyntaxWarning: invalid escape sequence '\P'
  'passoptionstopackages': '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
yocto-docs/documentation/conf.py:163: SyntaxWarning: invalid escape sequence '\s'
  'preamble': '\setcounter{tocdepth}{2}',
"""

Backslashes must be doubled in Python string literals to avoid
interpretation as escape sequence, c.f.
https://www.sphinx-doc.org/en/master/latex.html#module-latex.

Cc: Quentin Schulz <foss+yocto@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
 documentation/conf.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Opdenacker March 29, 2024, 11:12 a.m. UTC | #1
Hi Quentin

Thanks for the patch!

On 3/28/24 at 16:07, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>
> There are some syntax warnings returned by Python:
> """
> yocto-docs/documentation/conf.py:162: SyntaxWarning: invalid escape sequence '\P'
>    'passoptionstopackages': '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
> yocto-docs/documentation/conf.py:163: SyntaxWarning: invalid escape sequence '\s'
>    'preamble': '\setcounter{tocdepth}{2}',
> """
>
> Backslashes must be doubled in Python string literals to avoid
> interpretation as escape sequence, c.f.
> https://www.sphinx-doc.org/en/master/latex.html#module-latex.

What command(s) were you running to get the error? I didn't see it.
Anyway:
Reviewed-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Merged into "master-next"
Cheers
Michael.
Quentin Schulz March 29, 2024, 11:16 a.m. UTC | #2
Hi Michael,

On 3/29/24 12:12, Michael Opdenacker wrote:
> Hi Quentin
> 
> Thanks for the patch!
> 
> On 3/28/24 at 16:07, Quentin Schulz wrote:
>> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>>
>> There are some syntax warnings returned by Python:
>> """
>> yocto-docs/documentation/conf.py:162: SyntaxWarning: invalid escape 
>> sequence '\P'
>>    'passoptionstopackages': 
>> '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
>> yocto-docs/documentation/conf.py:163: SyntaxWarning: invalid escape 
>> sequence '\s'
>>    'preamble': '\setcounter{tocdepth}{2}',
>> """
>>
>> Backslashes must be doubled in Python string literals to avoid
>> interpretation as escape sequence, c.f.
>> https://www.sphinx-doc.org/en/master/latex.html#module-latex.
> 
> What command(s) were you running to get the error? I didn't see it.

Normal build instructions, just using Python 3.12.2 on Fedora 39.

https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

"""
A backslash-character pair that is not a valid escape sequence now 
generates a SyntaxWarning, instead of DeprecationWarning. For example, 
re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid 
escape sequence, use raw strings for regular expression: 
re.compile(r"\d+\.\d+")). In a future Python version, SyntaxError will 
eventually be raised, instead of SyntaxWarning. (Contributed by Victor 
Stinner in gh-98401.)
"""

Cheers,
Quentin
diff mbox series

Patch

diff --git a/documentation/conf.py b/documentation/conf.py
index a64685ec9..35c5c1453 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -159,8 +159,8 @@  html_last_updated_fmt = '%b %d, %Y'
 html_secnumber_suffix = " "
 
 latex_elements = {
-    'passoptionstopackages': '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
-    'preamble': '\setcounter{tocdepth}{2}',
+    'passoptionstopackages': '\\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
+    'preamble': '\\setcounter{tocdepth}{2}',
 }
 
 # Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG