jupyter / jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
https://jupyter-sphinx.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
188 stars 65 forks source link

Latex output is no longer default python.tex #280

Open bnavigator opened 2 months ago

bnavigator commented 2 months ago

With Sphinx 7.4 (and possibly earlier) The test suite fails:

[  181s] ____________________________ test_builder_priority _____________________________
[  181s] 
[  181s] doctree = <function doctree.<locals>.doctree at 0x7fdfe8f5c040>
[  181s] 
[  181s]     def test_builder_priority(doctree):
[  181s]         source = """
[  181s]         .. jupyter-execute::
[  181s]     
[  181s]             display({"text/plain": "I am html output", "text/latex": "I am latex"})
[  181s]         """
[  181s]         config = (
[  181s]             "render_priority_html = ['text/plain', 'text/latex']\n"
[  181s]             "render_priority_latex = ['text/latex', 'text/plain']"
[  181s]         )
[  181s]         _, app, _ = doctree(source, config=config, return_all=True, buildername="html")
[  181s]         html = (Path(app.outdir) / "index.html").read_text()
[  181s]         assert "I am html output" in html
[  181s]         _, app, _ = doctree(source, config=config, return_all=True, buildername="latex")
[  181s] >       latex = (Path(app.outdir) / "python.tex").read_text()
[  181s] 
[  181s] tests/test_execute.py:780: 
[  181s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  181s] /usr/lib64/python3.10/pathlib.py:1134: in read_text
[  181s]     with self.open(mode='r', encoding=encoding, errors=errors) as f:
[  181s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  181s] 
[  181s] self = PosixPath('/tmp/tmp92typn82/_build/latex/python.tex'), mode = 'r'
[  181s] buffering = -1, encoding = 'locale', errors = None, newline = None
[  181s] 
[  181s]     def open(self, mode='r', buffering=-1, encoding=None,
[  181s]              errors=None, newline=None):
[  181s]         """
[  181s]         Open the file pointed by this path and return a file object, as
[  181s]         the built-in open() function does.
[  181s]         """
[  181s]         if "b" not in mode:
[  181s]             encoding = io.text_encoding(encoding)
[  181s] >       return self._accessor.open(self, mode, buffering, encoding, errors,
[  181s]                                    newline)
[  181s] E       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp92typn82/_build/latex/python.tex'

The expected output is actually in _build/latex/projectnamenotset.tex

This patch helps for the last release:

diff -ur jupyter-sphinx-0.5.3.orig/tests/test_execute.py jupyter-sphinx-0.5.3/tests/test_execute.py
--- jupyter-sphinx-0.5.3.orig/tests/test_execute.py 2024-09-15 20:14:34.086132369 +0200
+++ jupyter-sphinx-0.5.3/tests/test_execute.py  2024-09-15 20:15:06.323782290 +0200
@@ -52,6 +52,7 @@
         source_trees.append(src_dir)

         conf_contents = "extensions = ['%s']" % entrypoint
+        conf_contents += "\nproject = 'python'"
         if config is not None:
             conf_contents += "\n" + config
         (src_dir / "conf.py").write_text(conf_contents, encoding="utf8")

But it would have to be adapted in order to fit with #265