]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Generate social media preview cards for the documentation (#132101)
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>
Sat, 5 Apr 2025 14:20:06 +0000 (15:20 +0100)
committerGitHub <noreply@github.com>
Sat, 5 Apr 2025 14:20:06 +0000 (14:20 +0000)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Doc/Makefile
Doc/conf.py
Doc/requirements.txt

index b8896da4a918691b95e025a4ecc8d0c1579eafc5..c8a749a02a89ecad8257d7c4b1d450109b74dbbe 100644 (file)
@@ -204,6 +204,7 @@ dist-html:
        find dist -name 'python-$(DISTVERSION)-docs-html*' -exec rm -rf {} \;
        $(MAKE) html
        cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
+       rm -rf dist/python-$(DISTVERSION)-docs-html/_images/social_previews/
        tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
        bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
        (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
index 7c7acc8029c73261735e4595367d3bb518c1de92..cfd8b3a16dc8f74177c6dad80a37bd42a739af65 100644 (file)
@@ -624,11 +624,19 @@ stable_abi_file = 'data/stable_abi.dat'
 # Options for sphinxext-opengraph
 # -------------------------------
 
-ogp_site_url = 'https://docs.python.org/3/'
+ogp_canonical_url = 'https://docs.python.org/3/'
 ogp_site_name = 'Python documentation'
-ogp_image = '_static/og-image.png'
+ogp_social_cards = {  # Used when matplotlib is installed
+    'image': '_static/og-image.png',
+    'line_color': '#3776ab',
+}
 ogp_custom_meta_tags = [
-    '<meta property="og:image:width" content="200" />',
-    '<meta property="og:image:height" content="200" />',
     '<meta name="theme-color" content="#3776ab" />',
 ]
+if 'create-social-cards' not in tags:  # noqa: F821
+    # Define a static preview image when not creating social cards
+    ogp_image = '_static/og-image.png'
+    ogp_custom_meta_tags += [
+        '<meta property="og:image:width" content="200" />',
+        '<meta property="og:image:height" content="200" />',
+    ]
index 2e429f46b43408dd3f81aae3b3756e4ba7a214f3..a2960ea9aa0203251fa88ee87749cbef51094472 100644 (file)
@@ -11,7 +11,7 @@ sphinx~=8.2.0
 
 blurb
 
-sphinxext-opengraph~=0.9.0
+sphinxext-opengraph~=0.10.0
 sphinx-notfound-page~=1.0.0
 
 # The theme used by the documentation is stored separately, so we need