Skip to content

Commit 827f77e

Browse files
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 f595067 commit 827f77e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Doc/conf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,18 @@
244244
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
245245
# documentation is built with -W (warnings treated as errors).
246246
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
Lines changed: 2 additions & 0 deletions
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)