Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f24f241

Browse files
authored
[3.13] Generate social media preview cards for the documentation (GH-132101) (#132344)
1 parent f30a251 commit f24f241

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Doc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ dist-html:
204204
find dist -name 'python-$(DISTVERSION)-docs-html*' -exec rm -rf {} \;
205205
$(MAKE) html
206206
cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
207+
rm -rf dist/python-$(DISTVERSION)-docs-html/_images/social_previews/
207208
tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
208209
bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
209210
(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)

Doc/conf.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,19 @@
616616
# Options for sphinxext-opengraph
617617
# -------------------------------
618618

619-
ogp_site_url = 'https://docs.python.org/3/'
619+
ogp_canonical_url = 'https://docs.python.org/3/'
620620
ogp_site_name = 'Python documentation'
621-
ogp_image = '_static/og-image.png'
621+
ogp_social_cards = { # Used when matplotlib is installed
622+
'image': '_static/og-image.png',
623+
'line_color': '#3776ab',
624+
}
622625
ogp_custom_meta_tags = [
623-
'<meta property="og:image:width" content="200">',
624-
'<meta property="og:image:height" content="200">',
625626
'<meta name="theme-color" content="#3776ab">',
626627
]
628+
if 'create-social-cards' not in tags: # noqa: F821
629+
# Define a static preview image when not creating social cards
630+
ogp_image = '_static/og-image.png'
631+
ogp_custom_meta_tags += [
632+
'<meta property="og:image:width" content="200">',
633+
'<meta property="og:image:height" content="200">',
634+
]

Doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sphinx~=8.2.0
1111

1212
blurb
1313

14-
sphinxext-opengraph~=0.9.0
14+
sphinxext-opengraph~=0.10.0
1515
sphinx-notfound-page~=1.0.0
1616

1717
# The theme used by the documentation is stored separately, so we need

0 commit comments

Comments
 (0)