Skip to content

Commit f49c735

Browse files
hugovkCAM-Gerlach
andauthored
Use sphinxext-opengraph to generate OpenGraph metadata (#99931)
Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent d8ab0a4 commit f49c735

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

Doc/_static/og-image.png

14.2 KB
Loading

Doc/conf.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@
1313
# General configuration
1414
# ---------------------
1515

16-
extensions = ['sphinx.ext.coverage', 'sphinx.ext.doctest',
17-
'pyspecific', 'c_annotations', 'escape4chm',
18-
'asdl_highlight', 'peg_highlight', 'glossary_search']
16+
extensions = [
17+
'asdl_highlight',
18+
'c_annotations',
19+
'escape4chm',
20+
'glossary_search',
21+
'peg_highlight',
22+
'pyspecific',
23+
'sphinx.ext.coverage',
24+
'sphinx.ext.doctest',
25+
]
26+
27+
# Skip if downstream redistributors haven't installed it
28+
try:
29+
import sphinxext.opengraph
30+
except ImportError:
31+
pass
32+
else:
33+
extensions.append('sphinxext.opengraph')
34+
1935

2036
doctest_global_setup = '''
2137
try:
@@ -114,7 +130,7 @@
114130
html_use_opensearch = 'https://docs.python.org/' + version
115131

116132
# Additional static files.
117-
html_static_path = ['tools/static']
133+
html_static_path = ['_static', 'tools/static']
118134

119135
# Output file base name for HTML help builder.
120136
htmlhelp_basename = 'python' + release.replace('.', '')
@@ -238,3 +254,13 @@
238254
# Relative filename of the data files
239255
refcount_file = 'data/refcounts.dat'
240256
stable_abi_file = 'data/stable_abi.dat'
257+
258+
# sphinxext-opengraph config
259+
ogp_site_url = 'https://docs.python.org/3/'
260+
ogp_site_name = 'Python documentation'
261+
ogp_image = '_static/og-image.png'
262+
ogp_custom_meta_tags = [
263+
'<meta property="og:image:width" content="200">',
264+
'<meta property="og:image:height" content="200">',
265+
'<meta name="theme-color" content="#3776ab">',
266+
]

Doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sphinx==4.5.0
88
blurb
99

1010
sphinx-lint==0.6.7
11+
sphinxext-opengraph>=0.7.1
1112

1213
# The theme used by the documentation is stored separately, so we need
1314
# to install that as well.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Use `sphinxext-opengraph <https://sphinxext-opengraph.readthedocs.io/>`__
2+
to generate `OpenGraph metadata <https://ogp.me/>`__.

0 commit comments

Comments
 (0)