sphinx-proof
sphinx-proof copied to clipboard
ValueError: 'theorem ' is not in list
Describe the bug
context While trying to run the simple examples described at https://jupyterbook.org/content/proof.html, I receive an error (for all types).
expectation I expected jb to render the sphinx-proof directive.
bug But instead I receive a ValueError:
$ jupyter-book build mybook
Exception occurred:
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx_proof/nodes.py", line 38, in depart_enumerable_node
idx = self.body.index(f"{typ} {number} ")
ValueError: 'theorem ' is not in list
The full traceback has been saved in /tmp/sphinx-err-i514zz9f.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!
Traceback (most recent call last):
File "/workspace/.pip-modules/lib/python3.8/site-packages/jupyter_book/sphinx.py", line 167, in build_sphinx
app.build(force_all, filenames)
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/application.py", line 337, in build
self.builder.build_update()
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 294, in build_update
self.build(to_build,
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 358, in build
self.write(docnames, list(updated_docnames), method)
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 532, in write
self._write_serial(sorted(docnames))
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 542, in _write_serial
self.write_doc(docname, doctree)
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/builders/html/__init__.py", line 626, in write_doc
self.docwriter.write(doctree, destination)
File "/workspace/.pip-modules/lib/python3.8/site-packages/docutils/writers/__init__.py", line 78, in write
self.translate()
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/writers/html.py", line 71, in translate
self.document.walkabout(visitor)
File "/workspace/.pip-modules/lib/python3.8/site-packages/docutils/nodes.py", line 227, in walkabout
if child.walkabout(visitor):
File "/workspace/.pip-modules/lib/python3.8/site-packages/docutils/nodes.py", line 227, in walkabout
if child.walkabout(visitor):
File "/workspace/.pip-modules/lib/python3.8/site-packages/docutils/nodes.py", line 240, in walkabout
visitor.dispatch_departure(self)
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx/util/docutils.py", line 517, in dispatch_departure
method(node)
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx_proof/nodes.py", line 38, in depart_enumerable_node
idx = self.body.index(f"{typ} {number} ")
ValueError: 'theorem ' is not in list
Reproduce the bug
- Go to https://jupyterbook.org/content/proof.html
- Follow the examples.
- Attempt to build jb book.
List your environment
$ jb --version
Jupyter Book : 0.12.1
External ToC : 0.2.3
MyST-Parser : 0.15.2
MyST-NB : 0.13.1
Sphinx Book Theme : 0.1.10
Jupyter-Cache : 0.4.3
NbClient : 0.5.10
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Hello,
Maybe you have solved your problem?
I had the same problem. For me, the error was due to the fact that the file isn't included in any toctree. As a consequence, the theorem
was not numbered and was later defined as 'theorem '
(with 2 blank space). The error came from nodes.py
line 38 (release 0.1.3)
idx = self.body.index(f"{typ} {number} ")
The {number}
quantity was empty. I fixed this just by deleting the (useless) file...
IMHO, this issue should be fix: for Sphinx, a "ghost file", a file that is not listed by any other ones, raises a warning, not an error. Maybe there should be a verification that {number}
is not empty?
Hello,
Maybe you have solved your problem?
I had the same problem. For me, the error was due to the fact that the file isn't included in any toctree. As a consequence, the
theorem
was not numbered and was later defined as'theorem '
(with 2 blank space). The error came fromnodes.py
line 38 (release 0.1.3)idx = self.body.index(f"{typ} {number} ")
The
{number}
quantity was empty. I fixed this just by deleting the (useless) file...IMHO, this issue should be fix: for Sphinx, a "ghost file", a file that is not listed by any other ones, raises a warning, not an error. Maybe there should be a verification that
{number}
is not empty?
May I ask for your solution? What is the useless file? Because I am using Ablog, there will be a lot of files...
I don't know about Ablog, I use sphinx "directly".
Basically, I had a file, say myfile.rst
. The error came from this file, something like
Exception occurred:
File "/workspace/.pip-modules/lib/python3.8/site-packages/sphinx_proof/nodes.py", line 38, in depart_enumerable_node
idx = self.body.index(f"{typ} {number} ")
ValueError: 'theorem ' is not in list
This file, myfile.rst
was not included in any toctree
file and was thus inaccessible/invisible. This was the reason of the error.
So... I just have removed this myfile.rst
file which was actually useless. Another option would have to include myfile.rst
in a toctree but actually, I did not use this file, it was a legacy one that I forgot to delete.
For you, I would suggest:
- Check from which file the error comes from (look at the log, the last file called should be this one)
- When you found which file it is, check if it is included/listed in a toctree
- If not: do you need that file ? No -> delete; Yes-> Add it to a toctree
Hope it helps!
Thank you for your reply! Following your suggestion, I added the error-file to the toctree, and it was successfully loaded. Your advice was incredibly useful, and I am very thankful for it.
Excellent news!