All of lore.kernel.org
 help / color / mirror / Atom feed
* Sphinx and the :any: role
@ 2021-05-11 17:31 John Snow
  2021-05-11 22:34 ` John Snow
  0 siblings, 1 reply; 2+ messages in thread
From: John Snow @ 2021-05-11 17:31 UTC (permalink / raw)
  To: QEMU Developers, Peter Maydell; +Cc: Paolo Bonzini, Markus Armbruster

For the purposes of my QAPI generator cleanup (adding docstrings and 
mypy static types to ./scripts/qapi), I have a series of patches I've 
been carrying off-list that changes the behavior of how Sphinx 
cross-references work.

Presently, `foo` in our Sphinx docs is interpreted as the "content" 
role, and has "no special meaning".

I experimented with what would happen if we change this to the "any" 
role, which interprets `foo` as a cross-reference to *something* named 
"foo". If no reference is found, it emits a build error.

(Many existing usages of `foo` must be changed to ``foo`` to enable this 
to work.)

I found this useful for testing and writing Python docstrings, because 
it keeps the syntax cleaner than having to write :py:func:`foo` or 
:py:meth:`foo` and so on. It keeps the docstrings less syntax-heavy when 
reading them outside of the Sphinx rendered output.

I would have liked to propose we actually adopt this change, however 
I've noticed a problem with this in our CI builds.

Sphinx 3.2.1 (The current version we seem to test against in our Fedora 
container) has a race condition (?) where occasionally kernel-doc will 
crash outright:

Exception occurred:
   File "/usr/lib/python3.9/site-packages/sphinx/domains/c.py", line 
3751, in resolve_any_xref
     return [('c:' + self.role_for_objtype(objtype), retnode)]
TypeError: can only concatenate str (not "NoneType") to str

The full traceback has been saved in /tmp/sphinx-err-v6iqwtf9.log, if 
you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error 
message can be provided next time.
A bug report can be filed in the tracker at 
<https://github.com/sphinx-doc/sphinx/issues>. Thanks!


It's not actually clear WHICH thing Sphinx is choking on here, exactly 
-- it's just some bug in Sphinx's C domain handling of resolving 
cross-references.

This is fixed in 3.3.1, I believe closed with one of these issues:

https://github.com/sphinx-doc/sphinx/issues/8364
https://github.com/sphinx-doc/sphinx/issues/8388


I'm not sure if there's anything I can do here -- we probably can't 
require such a modern version of Sphinx just yet, I haven't done the 
legwork to check. I also haven't been able to diagnose the exact 
invocation that seems to trigger these failures, so it's not clear if 
there's a workaround just yet.

I'm still interested in making our cross-referencing a bit more robust, 
but maybe my hands are tied on that front for now.

--js



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-11 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 17:31 Sphinx and the :any: role John Snow
2021-05-11 22:34 ` John Snow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.