From 271cfba9b787e8745659a3d6c9350b9b17c51eb0 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 7 Jan 2023 18:46:35 +0200 Subject: [PATCH 1/3] Generate social media cards per page --- Doc/conf.py | 19 ++++++++++++------- Doc/requirements.txt | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Doc/conf.py b/Doc/conf.py index b4a924b7bf0857..be63bf4a9797e8 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -621,11 +621,16 @@ # Options for sphinxext-opengraph # ------------------------------- -ogp_site_url = 'https://docs.python.org/3/' +ogp_site_url = 'https://hugovk-cpython.readthedocs.io/en/ogp_social_cards/' ogp_site_name = 'Python documentation' -ogp_image = '_static/og-image.png' -ogp_custom_meta_tags = [ - '', - '', - '', -] +# ogp_image = '_static/og-image.png' +# ogp_custom_meta_tags = [ +# '', +# '', +# '', +# ] + +ogp_social_cards = { + "image": "_static/og-image.png", + "line_color": "#3776ab", +} diff --git a/Doc/requirements.txt b/Doc/requirements.txt index 32ff8f74d05bb6..73ef5ebcd3c015 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -19,3 +19,5 @@ sphinx-notfound-page~=1.0.0 python-docs-theme>=2023.3.1,!=2023.7 -c constraints.txt + +matplotlib From fbc5651b3b564379736470fd2da60f40879a5ca2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 20 Jan 2025 23:02:32 +0000 Subject: [PATCH 2/3] Use the create-social-cards tag --- Doc/conf.py | 25 ++++++++++++++----------- Doc/requirements.txt | 2 -- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Doc/conf.py b/Doc/conf.py index be63bf4a9797e8..ed64708487f7e3 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -621,16 +621,19 @@ # Options for sphinxext-opengraph # ------------------------------- -ogp_site_url = 'https://hugovk-cpython.readthedocs.io/en/ogp_social_cards/' +ogp_site_url = 'https://docs.python.org/3/' ogp_site_name = 'Python documentation' -# ogp_image = '_static/og-image.png' -# ogp_custom_meta_tags = [ -# '', -# '', -# '', -# ] - -ogp_social_cards = { - "image": "_static/og-image.png", - "line_color": "#3776ab", +ogp_social_cards = { # Used when matplotlib is installed + 'image': '_static/og-image.png', + 'line_color': '#3776ab', } +ogp_custom_meta_tags = [ + '', +] +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 += [ + '', + '', + ] diff --git a/Doc/requirements.txt b/Doc/requirements.txt index 73ef5ebcd3c015..32ff8f74d05bb6 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -19,5 +19,3 @@ sphinx-notfound-page~=1.0.0 python-docs-theme>=2023.3.1,!=2023.7 -c constraints.txt - -matplotlib From d59e7d820bec6d31405b3ed024818000c2b7ae88 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 20 Jan 2025 23:48:18 +0000 Subject: [PATCH 3/3] Remove ``social_previews`` folder before archiving --- Doc/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/Makefile b/Doc/Makefile index 53af6aca659cef..710f1f6466c425 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -205,6 +205,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)