summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo van Kemenade <hugovk@users.noreply.github.com>2022-12-05 21:26:28 (GMT)
committerGitHub <noreply@github.com>2022-12-05 21:26:28 (GMT)
commitf49c735e525cf031ddbfc19161aafac4fb18837b (patch)
tree715089c7799a1538b637e5de552c8993e15e4bd5
parentd8ab0a4dfa48f881b4ac9ab857d2e9de42f72828 (diff)
downloadcpython-f49c735e525cf031ddbfc19161aafac4fb18837b.zip
cpython-f49c735e525cf031ddbfc19161aafac4fb18837b.tar.gz
cpython-f49c735e525cf031ddbfc19161aafac4fb18837b.tar.bz2
Use sphinxext-opengraph to generate OpenGraph metadata (#99931)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
-rw-r--r--Doc/_static/og-image.pngbin0 -> 14572 bytes
-rw-r--r--Doc/conf.py34
-rw-r--r--Doc/requirements.txt1
-rw-r--r--Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst2
4 files changed, 33 insertions, 4 deletions
diff --git a/Doc/_static/og-image.png b/Doc/_static/og-image.png
new file mode 100644
index 0000000..0e80751
--- /dev/null
+++ b/Doc/_static/og-image.png
Binary files differ
diff --git a/Doc/conf.py b/Doc/conf.py
index 6fad5c6..c7d2f43 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -13,9 +13,25 @@ sys.path.append(os.path.abspath('includes'))
# General configuration
# ---------------------
-extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
- 'pyspecific', 'c_annotations', 'escape4chm',
- 'asdl_highlight', 'peg_highlight', 'glossary_search']
+extensions = [
+ 'asdl_highlight',
+ 'c_annotations',
+ 'escape4chm',
+ 'glossary_search',
+ 'peg_highlight',
+ 'pyspecific',
+ 'sphinx.ext.coverage',
+ 'sphinx.ext.doctest',
+]
+
+# Skip if downstream redistributors haven't installed it
+try:
+ import sphinxext.opengraph
+except ImportError:
+ pass
+else:
+ extensions.append('sphinxext.opengraph')
+
doctest_global_setup = '''
try:
@@ -114,7 +130,7 @@ html_additional_pages = {
html_use_opensearch = 'https://docs.python.org/' + version
# Additional static files.
-html_static_path = ['tools/static']
+html_static_path = ['_static', 'tools/static']
# Output file base name for HTML help builder.
htmlhelp_basename = 'python' + release.replace('.', '')
@@ -238,3 +254,13 @@ linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+']
# Relative filename of the data files
refcount_file = 'data/refcounts.dat'
stable_abi_file = 'data/stable_abi.dat'
+
+# sphinxext-opengraph config
+ogp_site_url = 'https://docs.python.org/3/'
+ogp_site_name = 'Python documentation'
+ogp_image = '_static/og-image.png'
+ogp_custom_meta_tags = [
+ '<meta property="og:image:width" content="200">',
+ '<meta property="og:image:height" content="200">',
+ '<meta name="theme-color" content="#3776ab">',
+]
diff --git a/Doc/requirements.txt b/Doc/requirements.txt
index 958665d..134f39d 100644
--- a/Doc/requirements.txt
+++ b/Doc/requirements.txt
@@ -8,6 +8,7 @@ sphinx==4.5.0
blurb
sphinx-lint==0.6.7
+sphinxext-opengraph>=0.7.1
# The theme used by the documentation is stored separately, so we need
# to install that as well.
diff --git a/Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst b/Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst
new file mode 100644
index 0000000..0c01a2c
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2022-12-02-17-08-08.gh-issue-99931.wC46hE.rst
@@ -0,0 +1,2 @@
+Use `sphinxext-opengraph <https://sphinxext-opengraph.readthedocs.io/>`__
+to generate `OpenGraph metadata <https://ogp.me/>`__.