]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Set `hosted_on` for Read the Docs builds (#114697)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Mon, 29 Jan 2024 21:24:21 +0000 (23:24 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Jan 2024 21:24:21 +0000 (14:24 -0700)
Doc/conf.py

index e12128ad356e1bebb7038abab2030ad4763f93a8..c2d57696aeeaa37c0110e9311caccc49477cd571 100644 (file)
@@ -6,7 +6,9 @@
 # The contents of this file are pickled, so don't put values in the namespace
 # that aren't pickleable (module imports are okay, they're removed automatically).
 
-import sys, os, time
+import os
+import sys
+import time
 sys.path.append(os.path.abspath('tools/extensions'))
 sys.path.append(os.path.abspath('includes'))
 
@@ -55,7 +57,7 @@ manpages_url = 'https://manpages.debian.org/{path}'
 
 # General substitutions.
 project = 'Python'
-copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y')
+copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
 
 # We look for the Include/patchlevel.h file in the current Python source tree
 # and replace the values accordingly.
@@ -302,6 +304,9 @@ html_theme_options = {
     'root_include_title': False   # We use the version switcher instead.
 }
 
+if os.getenv("READTHEDOCS"):
+    html_theme_options["hosted_on"] = '<a href="https://about.readthedocs.com/">Read the Docs</a>'
+
 # Override stylesheet fingerprinting for Windows CHM htmlhelp to fix GH-91207
 # https://github.com/python/cpython/issues/91207
 if any('htmlhelp' in arg for arg in sys.argv):
@@ -310,7 +315,7 @@ if any('htmlhelp' in arg for arg in sys.argv):
     print("It may be removed in the future\n")
 
 # Short title used e.g. for <title> HTML tags.
-html_short_title = '%s Documentation' % release
+html_short_title = f'{release} Documentation'
 
 # Deployment preview information
 # (See .readthedocs.yml and https://docs.readthedocs.io/en/stable/reference/environment-variables.html)
@@ -359,12 +364,9 @@ html_split_index = True
 
 latex_engine = 'xelatex'
 
-# Get LaTeX to handle Unicode correctly
 latex_elements = {
-}
-
-# Additional stuff for the LaTeX preamble.
-latex_elements['preamble'] = r'''
+    # For the LaTeX preamble.
+    'preamble': r'''
 \authoraddress{
   \sphinxstrong{Python Software Foundation}\\
   Email: \sphinxemail{docs@python.org}
@@ -372,13 +374,12 @@ latex_elements['preamble'] = r'''
 \let\Verbatim=\OriginalVerbatim
 \let\endVerbatim=\endOriginalVerbatim
 \setcounter{tocdepth}{2}
-'''
-
-# The paper size ('letter' or 'a4').
-latex_elements['papersize'] = 'a4'
-
-# The font size ('10pt', '11pt' or '12pt').
-latex_elements['pointsize'] = '10pt'
+''',
+    # The paper size ('letter' or 'a4').
+    'papersize': 'a4',
+    # The font size ('10pt', '11pt' or '12pt').
+    'pointsize': '10pt',
+}
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, document class [howto/manual]).
@@ -441,9 +442,9 @@ coverage_c_path = [
 
 # Regexes to find C items in the source files.
 coverage_c_regexes = {
-    'cfunction': (r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'),
-    'data': (r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)'),
-    'macro': (r'^#define ([^_][\w_]+)\(.*\)[\s|\\]'),
+    'cfunction': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)',
+    'data': r'^PyAPI_DATA\(.*\)\s+([^_][\w_]+)',
+    'macro': r'^#define ([^_][\w_]+)\(.*\)[\s|\\]',
 }
 
 # The coverage checker will ignore all C items whose names match these regexes