- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Exception when sorting warning messages if a warning has no line number #10498
Comments
Actually it wasnt the extlinks warning. Instead if you have an image with an alt field that has exactly the same text as a preceding heading, you get the message with None as a linenumber. |
Here is the commit I made to workaround it in my project: kovidgoyal/calibre@bece999 |
@kovidgoyal do you have a single file reproducer please? A |
Also, your commit message says "Workaround yet another regression in Sphinx" -- what are the other regressions? Can we fix them? We'd like for upgrading Sphinx versions to be as painless as possible, so any help would be really useful here. Thanks, |
On Tue, May 31, 2022 at 09:23:24AM -0700, Adam Turner wrote:
@kovidgoyal do you have a single file reproducer please?
I described the issue pretty accurately I believe, but here you go:
```rst
test
=====
title
------
.. image:: cover.jpg
:alt: title
```
As for other regressions, they were in the past, with previous upgrades,
and I have reported them.
|
Edit: the 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", '''\
extensions = ['sphinx.ext.extlinks']
''')
write("index.rst", '''\
lorem ipsum dolar sit amet
--------------------------
.. image:: placeholder_image.jpg
:alt: lorem ipsum dolar sit amet
''')
shutil.rmtree("_build", ignore_errors=True)
run_make_mode(["gettext", ".", "_build", "-T"]) run as A |
touch conf.py |
Docutils doesn't set a line number for image nodes with alt text for some reason, reported as bug#449 We could patch Docutils, or add the workaround you suggested -- I'm inclined to go with the latter as it is more general (although might hide similar problems in the future) A |
On Tue, May 31, 2022 at 10:22:14AM -0700, Adam Turner wrote:
Docutils doesn't set a line number for image nodes with alt text for some reason, reported as [bug#449](https://sourceforge.net/p/docutils/bugs/449/)
Its not image nodes with alt text but image nodes with alt text that is
the same as the text of a previous title.
We could patch Docutils, or add the workaround you suggested -- I'm inclined to go with the latter as it is more general (although might hide similar problems in the future)
A proper workaround is to check for no line number and issue a warning
and then use the sort fix I suggested.
|
>>> print(core.publish_doctree(".. image:: placeholder_image.jpg")[0].line)
1
>>> print(core.publish_doctree(".. image:: placeholder_image.jpg\n :alt: blah")[0].line)
None This example has no title, yet still fails. A |
The PR has been updated to issue a warning, thanks for the suggestion. A |
Fixed by #10503. It will be released as v5.0.1 soon (within a few days). Please wait for a while. |
Describe the bug
In sphinx 5.0 there is a new warning about extlinks. This warning has no associated linenumber. This breaks Catalog.iter with the following traceback:
The fix is simply to change the sorting of positions to:
How to Reproduce
Use extlinks with sphinx 5
Expected behavior
No response
Your project
calibre
Screenshots
No response
OS
Linux
Python version
3.10.4
Sphinx version
5.0.0
Sphinx extensions
No response
Extra tools
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: