Closed jakelishman closed 1 year ago
This behaviour was added in #290, which did add a test in test_sphinx_output
, but this test causes Sphinx to emit the same warning mentioned in this issue which doesn't cause a test failure.
It seems @hoodmane this was a regression introduced.
Oops didn't notice the warning. I guess the fix is simple enough.
As an aside, it occurs to me that this code would all be a lot simpler if we could manipulate a tree instead of strings containing a whitespace-sensitive markup format...
@jakelishman, this broke https://github.com/tox-dev/pyproject-api/actions/runs/3933433212. Can you take a look, please?
I think your CI run there is broken by 1.21.0 and fixed by the PR of mine you just merged (and the 1.21.1 release you just cut, thanks!). Could you try re-running your CI? I was unable to reproduce the failure locally with 1.21.1, but could if I pinned sphinx-autodoc-typehints
to 1.21.0.
In the 1.21.0 release, the position of the emitted
:rtype:
field seems to have changed so that it is now earlier in the docstring, rather than reliably being at the end. This is fine, except when the place the injector chooses to place it is immediately before a.. <whatever>::
directive. There doesn't seem to reliable be a blank line inserted after it, and if not, Sphinx complains that the field list ends unexpectedly.For example, given this Python file
tmp/__init__.py
:and this Sphinx
conf.py
:running Sphinx's
make html
gives:The docstring enters
_inject_types_to_docstring
asand is modified to
This also happens if there's any regular text before the
.. rubric:: notes
as well (which is a bit more of a realistic scenario).