New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: -np.inf as default argument not rendering correctly in DIRECT docstring #16385
Comments
Other occurrences of the problem with
It looks like there are two issues here:
Maybe the numpydoc devs have seen this before: @jarrodmillman, @larsoner, @rossbar, is this a known issue? |
Another example: the spurious space shows up in the rendering of the |
I added the "upstream bug" tag. This is probably a bug in Sphinx itself or in the theme used by SciPy, NumPy and Pandas. |
If there is nothing we can/should do, then we should close it IMO. |
It might be better to leave it open until the cause of the problem has been identified, and we know which version of which upstream tool fixes the problem. |
Would adding |
@dschmitz89, it turns out that the problem is a bug in Sphinx: sphinx-doc/sphinx#10550 The proposed fix is in sphinx-doc/sphinx#10551 I'll close this issue when that Sphinx pull request is merged, because then we'll have a definitive resolution of the issue: the problem is fixed in Sphinx 5.1.0. Using |
@WarrenWeckesser : from what I understood, the Sphinx bug will fix the additional space but we would still see |
I would be fine with seeing |
import shutil
from pathlib import Path
from sphinx.cmd.make_mode import run_make_mode
def write(filename, text): Path(filename).write_text(text, encoding="utf-8")
write("conf.py", '''\
import os, sys
sys.path.insert(0, os.path.abspath(".."))
extensions = ["sphinx.ext.autodoc"]
autodoc_preserve_defaults = True
''')
write("extra_white.py", '''\
def func(axis=-0x1): ...
''')
write("index.rst", '''\
.. autofunction:: extra_white.func
''')
shutil.rmtree("_build", ignore_errors=True)
run_make_mode(["html", ".", "_build", "-T", "-W"]) A |
Thanks @AA-Turner, that makes sense. So if we used that option in SciPy now we would get |
I confirmed the spacing issue will be resolved with Sphinx 5.1.0 (see sphinx-doc/sphinx#10551 (comment)). |
|
Well this should not really happen as it would be a bad design. Default arguments should always be simple things like string, scalars, booleans, None. Anything else would break (e.g. using an empty dict which leads to bugs) and is an anti pattern. |
Over in the Sphinx repo, sphinx-doc/sphinx#10551 has been merged and the fix for the extra space will be in Sphinx 5.1.0. I'm closing this issue, because I think the extra space was the main problem. Of course, our web site won't reflect this change until we build it with Sphinx 5.1, so if anyone is even more conservative about closing this than I am and thinks it should remain open until our web site is actually fixed, feel free to reopen the issue. I think the question of enabling |
I am even less conservative so 😉 What we might want to discuss on the ML is the other issue/enhancement. |
The fix will be in Sphinx 5.1.0, which is not released yet. It looks like Sphinx has a release cadence of about two months, and 5.0.0 was released May 29, so I wouldn't expect 5.1.0 to be released until the end of July. |
Status update: It looks like the 1.9.0 docs were built with Sphinx <5.1.0, so they still have the spurious space, e.g. https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.direct.html. A newer version of Sphinx is used to build the development version of the docs, so in those the problem is fixed: https://scipy.github.io/devdocs/reference/generated/scipy.optimize.direct.html |
Maybe we should just bump the minimal version for Sphinx. |
There is a minor annoyance in the docstring of the recently added
direct
algorithm:sphinx cannot correctly parse
-np.inf
. I tried to google the issue but could not find an immediate fix. Maybe a more experienced sphinx user has an idea?The text was updated successfully, but these errors were encountered: