Skip to content

Commit d3714ca

Browse files
hugovkCAM-Gerlach
authored andcommitted
Use sphinxext-opengraph to generate OpenGraph metadata (pythonGH-99931)
(cherry picked from commit f49c735) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent f43b3d5 commit d3714ca

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:
@@ -109,7 +125,7 @@
109125
html_use_opensearch = 'https://docs.python.org/' + version
110126

111127
# Additional static files.
112-
html_static_path = ['tools/static']
128+
html_static_path = ['_static', 'tools/static']
113129

114130
# Output file base name for HTML help builder.
115131
htmlhelp_basename = 'python' + release.replace('.', '')
@@ -234,3 +250,13 @@
234250
# Relative filename of the data files
235251
refcount_file = 'data/refcounts.dat'
236252
stable_abi_file = 'data/stable_abi.dat'
253+
254+
# sphinxext-opengraph config
255+
ogp_site_url = 'https://docs.python.org/3/'
256+
ogp_site_name = 'Python documentation'
257+
ogp_image = '_static/og-image.png'
258+
ogp_custom_meta_tags = [
259+
'<meta property="og:image:width" content="200">',
260+
'<meta property="og:image:height" content="200">',
261+
'<meta name="theme-color" content="#3776ab">',
262+
]

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)