On Mon, 9 Jun 2025 at 17:38, Paolo Bonzini <pbonz...@redhat.com> wrote: > > On 6/9/25 18:18, Peter Maydell wrote: > > Ping^2 on this one? > > No objections if it's the easiest way to solve the issue. > > Alternatively, is there a Sphinx way to write something in the spirit of > > #ifdef DEFINE_THE_LABEL > .. _label > #endif
Unfortunately not. Sphinx's conditional-content stuff is a bit odd, and only works for actual docs, not for sections, labels, etc: https://www.sphinx-doc.org/en/master/usage/extensions/ifconfig.html https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags IIRC this is because under the hood the conditionalisation only takes effect quite late, when it's about to emit something: they really act just as filters on the output. So you can't conditionalise a directive or anything that needs to take effect at the parsing stage. https://pypi.org/project/sphinx-selective-exclude/ is an extension that tries to work around this, but it hasn't been updated in years and it probably doesn't work with newer sphinx versions. -- PMM