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 <9087854+AA-Turner@users.noreply.github.com>

* Add NEWS entry for C domain bang fix

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
(cherry picked from commit 9148c0d893)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
Miss Islington (bot) 2022-10-02 21:02:46 -07:00 committed by Pablo Galindo
parent 5e99363a74
commit 10818aa833
No known key found for this signature in database
GPG key ID: FFE87404168BD847
2 changed files with 27 additions and 0 deletions

View file

@ -234,3 +234,28 @@ linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+']
# Relative filename of the data files # Relative filename of the data files
refcount_file = 'data/refcounts.dat' refcount_file = 'data/refcounts.dat'
stable_abi_file = 'data/stable_abi.dat' stable_abi_file = 'data/stable_abi.dat'
# Sphinx 2 and Sphinx 3 compatibility
# -----------------------------------
# bpo-40204: Allow Sphinx 2 syntax in the C domain
c_allow_pre_v3 = True
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
# documentation is built with -W (warnings treated as errors).
c_warn_on_allowed_pre_v3 = False
# Fix '!' not working with C domain when pre_v3 is enabled
import sphinx
if sphinx.version_info[:2] < (5, 3):
from sphinx.domains.c import CXRefRole
original_run = CXRefRole.run
def new_run(self):
if self.disabled:
return super(CXRefRole, self).run()
return original_run(self)
CXRefRole.run = new_run

View file

@ -0,0 +1,2 @@
Fix ``!`` in c domain ref target syntax via a ``conf.py`` patch, so it works
as intended to disable ref target resolution.