diff --git a/Doc/conf.py b/Doc/conf.py index 0a436d7affcdb6..909f992d9d821a 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -249,3 +249,18 @@ # 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 diff --git a/Misc/NEWS.d/next/Documentation/2022-10-02-10-58-52.gh-issue-97741.39l023.rst b/Misc/NEWS.d/next/Documentation/2022-10-02-10-58-52.gh-issue-97741.39l023.rst new file mode 100644 index 00000000000000..8da9c92f6fd879 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2022-10-02-10-58-52.gh-issue-97741.39l023.rst @@ -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.