Skip to content

Commit 10818aa

Browse files
miss-islingtonCAM-Gerlach
authored andcommitted
gh-97740: Fix bang in Sphinx C domain ref target syntax (GH-97741)
* gh-97740: Fix bang in Sphinx C domain ref target syntax Co-authored-by: Adam Turner <[email protected]> * Add NEWS entry for C domain bang fix Co-authored-by: Adam Turner <[email protected]> (cherry picked from commit 9148c0d) Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 5e99363 commit 10818aa

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Doc/conf.py

+25
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,28 @@
234234
# Relative filename of the data files
235235
refcount_file = 'data/refcounts.dat'
236236
stable_abi_file = 'data/stable_abi.dat'
237+
238+
# Sphinx 2 and Sphinx 3 compatibility
239+
# -----------------------------------
240+
241+
# bpo-40204: Allow Sphinx 2 syntax in the C domain
242+
c_allow_pre_v3 = True
243+
244+
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
245+
# documentation is built with -W (warnings treated as errors).
246+
c_warn_on_allowed_pre_v3 = False
247+
248+
# Fix '!' not working with C domain when pre_v3 is enabled
249+
import sphinx
250+
251+
if sphinx.version_info[:2] < (5, 3):
252+
from sphinx.domains.c import CXRefRole
253+
254+
original_run = CXRefRole.run
255+
256+
def new_run(self):
257+
if self.disabled:
258+
return super(CXRefRole, self).run()
259+
return original_run(self)
260+
261+
CXRefRole.run = new_run
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix ``!`` in c domain ref target syntax via a ``conf.py`` patch, so it works
2+
as intended to disable ref target resolution.

0 commit comments

Comments
 (0)