Code cells not rendered under 0.4.0
CommonClimate opened this issue · 11 comments
Hi,
I'm trying to switch the Pyleoclim to use jupyter-sphinx
instead of IPython directives to execute our code and produce figures for the docs. Having installed jupyter-sphinx
0.4.0, I've modified our conf.py
file so the extensions now list jupyter_sphinx
as per your updated instructions, and the doc build (with Sphinx 5.3.0) fails with the following error message:
Exception occurred:
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/jupyter_sphinx/ast.py", line 46, in load_content
raise OSError(f"File {filename} not found or reading it failed")
OSError: File /Users/julieneg/Documents/GitHub/Pyleoclim_util/doc_build/core/python not found or reading it failed
The full traceback has been saved in /var/folders/bf/_x19bm694857h_hrw44j0p7w0000gn/T/sphinx-err-bpckb7ne.log, if you want to report the issue to the developers.
If I revert to jupyter_sphinx.execute
in conf.py, the doc does build, but the HTML is blank where there should be jupyter cells (code and figures).(I'd share the HTML output, but GitHub doesn't allow that). I've set SPHINXOPTS=-v
but I get no error message, so it's hard to diagnose the problem. Any tips on how to troubleshoot?
For a start, do you observe the same problem when building e.g. jupyter-sphinx docs in your environment?
Thank you for the prompt action @akhmerov . Indeed, this is for a local build using Python 3.10.8. Here are the contents of my environment.yml file.
A MWE is this:
.. jupyter-execute::
data = pd.read_csv('https://raw.githubusercontent.com/LinkedEarth/Pyleoclim_util/Development/example_data/soi_data.csv',skiprows=0,header=1)
ts = pyleo.Series(time=data.iloc[:,1], value=data.iloc[:,2], time_name='Year C.E', value_name='SOI', label='SOI')
ssa = ts.ssa()
fig, ax = ssa.modeplot()
pyleo.closefig(fig)
(where pd is the standard pandas alias, and pyleo resolves to "pyleoclim", our package, cited above. However, I'm pretty sure any Matplotlib command would reproduce the problem)
Let me know if you need any other information.
packages
name: pyleo310
channels:
- conda-forge
- defaults
dependencies: - _ipython_minor_entry_point=8.7.0=hb6b4a82_0
- alabaster=0.7.12=py_0
- anyio=3.6.2=pyhd8ed1ab_0
- appnope=0.1.3=pyhd8ed1ab_0
- argon2-cffi=21.3.0=pyhd8ed1ab_0
- argon2-cffi-bindings=21.2.0=py310h90acd4f_3
- asttokens=2.2.1=pyhd8ed1ab_0
- attrs=22.1.0=pyh71513ae_1
- babel=2.11.0=pyhd8ed1ab_0
- backcall=0.2.0=pyh9f0ad1d_0
- backports=1.0=pyhd8ed1ab_3
- backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
- beautifulsoup4=4.11.1=pyha770c72_0
- bleach=5.0.1=pyhd8ed1ab_0
- brotli=1.0.9=hb7f2c08_8
- brotli-bin=1.0.9=hb7f2c08_8
- brotlipy=0.7.0=py310h90acd4f_1005
- bzip2=1.0.8=h0d85af4_4
- c-ares=1.18.1=h0d85af4_0
- ca-certificates=2022.12.7=h033912b_0
- cartopy=0.21.1=py310h578c2b2_0
- certifi=2022.12.7=pyhd8ed1ab_0
- cffi=1.15.1=py310ha78151a_3
- charset-normalizer=2.1.1=pyhd8ed1ab_0
- colorama=0.4.6=pyhd8ed1ab_0
- comm=0.1.2=pyhd8ed1ab_0
- contourpy=1.0.6=py310ha23aa8a_0
- cryptography=38.0.4=py310hdd0c95c_0
- cycler=0.11.0=pyhd8ed1ab_0
- debugpy=1.6.4=py310h7a76584_0
- decorator=5.1.1=pyhd8ed1ab_0
- defusedxml=0.7.1=pyhd8ed1ab_0
- entrypoints=0.4=pyhd8ed1ab_0
- executing=1.2.0=pyhd8ed1ab_0
- flit-core=3.8.0=pyhd8ed1ab_0
- fonttools=4.38.0=py310h90acd4f_1
- freetype=2.12.1=h3f81eb7_1
- geos=3.11.1=hf0c8a7f_0
- gettext=0.21.1=h8a4c099_0
- glib=2.74.1=hbc0c0cd_1
- glib-tools=2.74.1=hbc0c0cd_1
- gst-plugins-base=1.21.2=h37e1711_0
- gstreamer=1.21.2=h1d18e73_0
- icu=70.1=h96cf925_0
- idna=3.4=pyhd8ed1ab_0
- imagesize=1.4.1=pyhd8ed1ab_0
- importlib-metadata=5.1.0=pyha770c72_0
- importlib_resources=5.10.1=pyhd8ed1ab_0
- ipykernel=6.19.2=pyh736e0ef_0
- ipython=8.7.0=pyhd1c38e8_0
- ipython_genutils=0.2.0=py_1
- ipywidgets=8.0.3=pyhd8ed1ab_0
- jedi=0.18.2=pyhd8ed1ab_0
- jinja2=3.1.2=pyhd8ed1ab_1
- jpeg=9e=hac89ed1_2
- jsonschema=4.17.3=pyhd8ed1ab_0
- jupyter=1.0.0=py310h2ec42d9_8
- jupyter_client=7.4.8=pyhd8ed1ab_0
- jupyter_console=6.4.4=pyhd8ed1ab_0
- jupyter_core=5.1.0=py310h2ec42d9_0
- jupyter_events=0.5.0=pyhd8ed1ab_0
- jupyter_server=2.0.1=pyhd8ed1ab_0
- jupyter_server_terminals=0.4.2=pyhd8ed1ab_0
- jupyter_sphinx=0.4.0=py310h2ec42d9_1
- jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
- jupyterlab_widgets=3.0.4=pyhd8ed1ab_0
- kiwisolver=1.4.4=py310ha23aa8a_1
- krb5=1.19.3=hb98e516_0
- lcms2=2.14=h90f4b2a_0
- lerc=4.0.0=hb486fe8_0
- libblas=3.9.0=16_osx64_openblas
- libbrotlicommon=1.0.9=hb7f2c08_8
- libbrotlidec=1.0.9=hb7f2c08_8
- libbrotlienc=1.0.9=hb7f2c08_8
- libcblas=3.9.0=16_osx64_openblas
- libclang=15.0.6=default_h20dc2f0_0
- libclang13=15.0.6=default_hc4b5f92_0
- libcurl=7.86.0=h581aaea_1
- libcxx=14.0.6=hccf4f1f_0
- libdeflate=1.14=hb7f2c08_0
- libedit=3.1.20191231=h0678c8f_2
- libev=4.33=haf1e3a3_1
- libffi=3.4.2=h0d85af4_5
- libgfortran=5.0.0=11_3_0_h97931a8_27
- libgfortran5=11.3.0=h082f757_27
- libglib=2.74.1=h4c723e1_1
- libiconv=1.17=hac89ed1_0
- liblapack=3.9.0=16_osx64_openblas
- libllvm15=15.0.6=h7001e86_0
- libnghttp2=1.47.0=h5aae05b_1
- libogg=1.3.4=h35c211d_1
- libopenblas=0.3.21=openmp_h429af6e_3
- libopus=1.3.1=hc929b4f_1
- libpng=1.6.39=ha978bb4_0
- libpq=15.1=hb1ae2b1_1
- libsodium=1.0.18=hbcb3906_1
- libsqlite=3.40.0=ha978bb4_0
- libssh2=1.10.0=h47af595_3
- libtiff=4.4.0=hdb44e8a_4
- libvorbis=1.3.7=h046ec9c_0
- libwebp-base=1.2.4=h775f41a_0
- libxcb=1.13=h0d85af4_1004
- libxml2=2.10.3=hb9e07b5_0
- libzlib=1.2.13=hfd90126_4
- llvm-openmp=15.0.6=h61d9ccf_0
- markupsafe=2.1.1=py310h90acd4f_2
- matplotlib-base=3.6.2=py310he725631_0
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- mistune=2.0.4=pyhd8ed1ab_0
- munkres=1.1.4=pyh9f0ad1d_0
- mysql-common=8.0.31=hc4b2c72_0
- mysql-libs=8.0.31=h8658499_0
- nbclassic=0.4.8=pyhd8ed1ab_0
- nbclient=0.7.2=pyhd8ed1ab_0
- nbconvert=7.2.6=pyhd8ed1ab_0
- nbconvert-core=7.2.6=pyhd8ed1ab_0
- nbconvert-pandoc=7.2.6=pyhd8ed1ab_0
- nbformat=5.7.0=pyhd8ed1ab_0
- nbsphinx=0.8.10=pyhd8ed1ab_0
- ncurses=6.3=h96cf925_1
- nest-asyncio=1.5.6=pyhd8ed1ab_0
- notebook=6.5.2=pyha770c72_1
- notebook-shim=0.2.2=pyhd8ed1ab_0
- nspr=4.35=hea0b92c_0
- nss=3.78=ha8197d3_0
- numpy=1.23.5=py310h1b7c290_0
- numpydoc=1.5.0=pyhd8ed1ab_0
- openjpeg=2.5.0=h5d0d7b0_1
- openssl=3.0.7=hfd90126_1
- packaging=22.0=pyhd8ed1ab_0
- pandoc=2.19.2=h694c41f_1
- pandocfilters=1.5.0=pyhd8ed1ab_0
- parso=0.8.3=pyhd8ed1ab_0
- pcre2=10.40=h1c4e4bc_0
- pexpect=4.8.0=pyh1a96a4e_2
- pickleshare=0.7.5=py_1003
- pillow=9.2.0=py310hffcf78b_3
- pip=22.3.1=pyhd8ed1ab_0
- pkgutil-resolve-name=1.3.10=pyhd8ed1ab_0
- platformdirs=2.6.0=pyhd8ed1ab_0
- proj=9.1.0=hcbd9701_0
- prometheus_client=0.15.0=pyhd8ed1ab_0
- prompt-toolkit=3.0.36=pyha770c72_0
- prompt_toolkit=3.0.36=hd8ed1ab_0
- psutil=5.9.4=py310h90acd4f_0
- pthread-stubs=0.4=hc929b4f_1001
- ptyprocess=0.7.0=pyhd3deb0d_0
- pure_eval=0.2.2=pyhd8ed1ab_0
- pycparser=2.21=pyhd8ed1ab_0
- pygments=2.13.0=pyhd8ed1ab_0
- pyopenssl=22.1.0=pyhd8ed1ab_0
- pyparsing=3.0.9=pyhd8ed1ab_0
- pyproj=3.4.1=py310h8c678d5_0
- pyqt=5.15.7=py310hdd03f62_2
- pyqt5-sip=12.11.0=py310h415000c_2
- pyrsistent=0.19.2=py310h90acd4f_0
- pyshp=2.3.1=pyhd8ed1ab_0
- pysocks=1.7.1=pyha2e5f31_6
- python=3.10.8=he7542f4_0_cpython
- python-dateutil=2.8.2=pyhd8ed1ab_0
- python-fastjsonschema=2.16.2=pyhd8ed1ab_0
- python-json-logger=2.0.1=pyh9f0ad1d_0
- python.app=1.4=py310h90acd4f_1
- python_abi=3.10=3_cp310
- pytz=2022.6=pyhd8ed1ab_0
- pyyaml=6.0=py310h90acd4f_5
- pyzmq=24.0.1=py310hf615a82_1
- qt-main=5.15.6=h0916ed4_4
- qtconsole=5.4.0=pyhd8ed1ab_0
- qtconsole-base=5.4.0=pyha770c72_0
- qtpy=2.3.0=pyhd8ed1ab_0
- readline=8.1.2=h3899abd_0
- requests=2.28.1=pyhd8ed1ab_1
- scipy=1.9.3=py310h240c617_2
- send2trash=1.8.0=pyhd8ed1ab_0
- setuptools=65.5.1=pyhd8ed1ab_0
- shapely=2.0.0=py310h4e43f2a_0
- sip=6.7.5=py310h7a76584_0
- six=1.16.0=pyh6c4a22f_0
- sniffio=1.3.0=pyhd8ed1ab_0
- snowballstemmer=2.2.0=pyhd8ed1ab_0
- soupsieve=2.3.2.post1=pyhd8ed1ab_0
- sphinx=5.3.0=pyhd8ed1ab_0
- sphinxcontrib-applehelp=1.0.2=py_0
- sphinxcontrib-devhelp=1.0.2=py_0
- sphinxcontrib-htmlhelp=2.0.0=pyhd8ed1ab_0
- sphinxcontrib-jsmath=1.0.1=py_0
- sphinxcontrib-qthelp=1.0.3=py_0
- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_2
- sqlite=3.40.0=h9ae0607_0
- stack_data=0.6.2=pyhd8ed1ab_0
- terminado=0.17.1=pyhd1c38e8_0
- tinycss2=1.2.1=pyhd8ed1ab_0
- tk=8.6.12=h5dbffcc_0
- toml=0.10.2=pyhd8ed1ab_0
- tornado=6.2=py310h90acd4f_1
- traitlets=5.7.1=pyhd8ed1ab_0
- typing_extensions=4.4.0=pyha770c72_0
- tzdata=2022g=h191b570_0
- unicodedata2=15.0.0=py310h90acd4f_0
- urllib3=1.26.13=pyhd8ed1ab_0
- wcwidth=0.2.5=pyh9f0ad1d_2
- webencodings=0.5.1=py_1
- websocket-client=1.4.2=pyhd8ed1ab_0
- wheel=0.38.4=pyhd8ed1ab_0
- widgetsnbextension=4.0.4=pyhd8ed1ab_0
- xorg-libxau=1.0.9=h35c211d_0
- xorg-libxdmcp=1.1.3=h35c211d_0
- xz=5.2.6=h775f41a_0
- yaml=0.2.5=h0d85af4_2
- zeromq=4.3.4=he49afe7_1
- zipp=3.11.0=pyhd8ed1ab_0
- zstd=1.5.2=hfa58983_4
- pip:
- bagit==1.8.1
- cython==0.29.32
- demjson3==3.0.6
- dill==0.3.6
- docutils==0.17.1
- joblib==1.2.0
- lipd==0.2.8.8
- llvmlite==0.39.1
- multiprocess==0.70.14
- networkx==2.8.8
- nibabel==4.0.2
- nitime==0.9
- numba==0.56.4
- pandas==1.5.2
- pathos==0.3.0
- patsy==0.5.3
- ply==3.11
- pox==0.3.2
- ppft==1.7.6.6
- pyhht==0.1.0
- readthedocs-sphinx-search==0.1.2
- scikit-learn==1.2.0
- seaborn==0.12.1
- sphinx-rtd-theme==1.1.1
- statsmodels==0.13.5
- tabulate==0.9.0
- tftb==0.1.4
- threadpoolctl==3.1.0
- tqdm==4.64.1
- unidecode==1.3.6
- wget==3.2
- xlrd==2.0.1
I've tried building the jupyter-sphinx docs with the latest sphinx, and I cannot reproduce the issue, so it should be working at least in the simplest setting. Could this be something about the theme you are using or so?
Unfortunately your MWE is neither minimal nor working, please see an example guideline. I don't have the bandwidth to install the pyleoclim development environment. To figure out what goes wrong I would also need a minimal conf.py
and an index.rst
that reproduces the failure. Please also exclude the packages that aren't relevant for the error from the environment.
Fair enough. The issue with making a truly minimal working example is that our documentation is very large, so whittling it down to what you want is a challenge.
Instead, I cloned your repo to experiment locally, editing jupyter-sphinx's conf.py
so that it is very similar to pyleoclim's (same sphinx extensions, same html theme, etc). So far everything runs as it should for your doc, but not mine. That rules out basic bugs, but it doesn't tell me why mine fails.
The main difference I can spot is that in pyleoclim, the code cells to render/execute are embedded in docstrings, which are parsed by sphinx.ext.autodoc
. As far as I can see, that is not the case for your documentation, so it is my leading hypothesis for the source of the bug. A telling sign is that building your doc generates a "jupyter" directory that contains a .py file, a .ipynb file and a png file for the inline figure generated; that folder and similar files never get created when I build my doc with .. jupyter-execute::
in my source code's docstrings (and the jupyter-execute directive in conf.py
, naturally).
Your doc says that " jupyter-execute
may also be used in docstrings within your Python code, and will be executed
when they are included with Sphinx autodoc." Have you tested that using Sphinx 5.3.0 and jupyter-sphinx 0.4.0?
I tried an example where I added this section to your index.rst file
SsaRes (pyleoclim.SsaRes)
"""""""""""""""""""""""""
.. autoclass:: pyleoclim.core.ssares.SsaRes
:members:
then ran Sphinx (using make clean html
). I got the following error message, which may be related to something more basic, but that's where I got stuck:
# Sphinx version: 5.3.0
# Python version: 3.10.8 (CPython)
# Docutils version: 0.19
# Jinja2 version: 3.1.2
# Last messages:
# Running Sphinx v5.3.0
# Loaded extensions:
# sphinx.ext.mathjax (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/mathjax.py
# sphinxcontrib.applehelp (1.0.2) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinxcontrib/applehelp/__init__.py
# sphinxcontrib.devhelp (1.0.2) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinxcontrib/devhelp/__init__.py
# sphinxcontrib.htmlhelp (2.0.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinxcontrib/htmlhelp/__init__.py
# sphinxcontrib.serializinghtml (1.1.5) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinxcontrib/serializinghtml/__init__.py
# sphinxcontrib.qthelp (1.0.3) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinxcontrib/qthelp/__init__.py
# alabaster (0.7.12) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/alabaster/__init__.py
# sphinx.ext.autodoc.preserve_defaults (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/preserve_defaults.py
# sphinx.ext.autodoc.type_comment (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/type_comment.py
# sphinx.ext.autodoc.typehints (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/typehints.py
# sphinx.ext.autodoc (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/__init__.py
# sphinx.ext.doctest (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/doctest.py
# sphinx.ext.viewcode (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/viewcode.py
# sphinx.ext.coverage (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/coverage.py
# sphinx.ext.autosummary (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autosummary/__init__.py
# sphinx.ext.intersphinx (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/intersphinx.py
# sphinx.ext.napoleon (5.3.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/napoleon/__init__.py
# jupyter_sphinx (0.4.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/jupyter_sphinx/__init__.py
# matplotlib.sphinxext.plot_directive (3.6.2) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/matplotlib/sphinxext/plot_directive.py
# IPython.sphinxext.ipython_console_highlighting (unknown version) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/IPython/sphinxext/ipython_console_highlighting.py
# IPython.sphinxext.ipython_directive (unknown version) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/IPython/sphinxext/ipython_directive.py
# numpydoc (1.5.0) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/numpydoc/__init__.py
# sphinx_search.extension (0.1.2) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx_search/extension.py
# sphinx_rtd_theme (unknown version) from /Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx_rtd_theme/__init__.py
Traceback (most recent call last):
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/jupyter_sphinx/ast.py", line 43, in load_content
with Path(filename).open() as f:
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/pathlib.py", line 1119, in open
return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/Users/julieneg/Documents/GitHub/jupyter-sphinx/doc/source/python'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/cmd/build.py", line 281, in build_main
app.build(args.force_all, args.filenames)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/application.py", line 347, in build
self.builder.build_update()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 310, in build_update
self.build(to_build,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 326, in build
updated_docnames = set(self.read())
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 433, in read
self._read_serial(docnames)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 454, in _read_serial
self.read_doc(docname)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 510, in read_doc
publisher.publish()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/core.py", line 224, in publish
self.document = self.reader.read(self.source, self.parser,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/io.py", line 104, in read
self.parse()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/readers/__init__.py", line 76, in parse
self.parser.parse(self.input, document)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/parsers.py", line 78, in parse
self.statemachine.run(inputlines, document, inliner=self.inliner)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 169, in run
results = StateMachineWS.run(self, input_lines, input_offset,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
self.section(title, source, style, lineno - 1, messages)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
self.new_subsection(title, lineno, messages)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
newabsoffset = self.nested_parse(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
self.section(title, source, style, lineno - 1, messages)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
self.new_subsection(title, lineno, messages)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
newabsoffset = self.nested_parse(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2355, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
return method(self, expmatch)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
return self.run_directive(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
result = directive_instance.run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/directive.py", line 159, in run
result = parse_generated_content(self.state, params.result, documenter)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/ext/autodoc/directive.py", line 106, in parse_generated_content
state.nested_parse(content, 0, node)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2355, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
return method(self, expmatch)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
return self.run_directive(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
result = directive_instance.run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/domains/__init__.py", line 281, in run
return super().run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/directives/__init__.py", line 263, in run
nested_parse_with_titles(self.state, self.content, contentnode)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/util/nodes.py", line 340, in nested_parse_with_titles
return state.nested_parse(content, 0, node, match_titles=1)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
self.explicit_list(blank_finish)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
newline_offset, blank_finish = self.nested_list_parse(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
return method(self, expmatch)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
return self.run_directive(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
result = directive_instance.run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/domains/__init__.py", line 281, in run
return super().run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/directives/__init__.py", line 263, in run
nested_parse_with_titles(self.state, self.content, contentnode)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/sphinx/util/nodes.py", line 340, in nested_parse_with_titles
return state.nested_parse(content, 0, node, match_titles=1)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
state_machine.run(block, input_offset, memo=self.memo,
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
context, next_state, result = self.check_line(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
return method(match, context, next_state)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2355, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
return method(self, expmatch)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
return self.run_directive(
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
result = directive_instance.run()
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/jupyter_sphinx/ast.py", line 136, in run
content = load_content(self, location, logger)
File "/Users/julieneg/opt/miniconda3/envs/pyleo310/lib/python3.10/site-packages/jupyter_sphinx/ast.py", line 46, in load_content
raise OSError(f"File {filename} not found or reading it failed")
OSError: File /Users/julieneg/Documents/GitHub/jupyter-sphinx/doc/source/python not found or reading it failed
Sorry if this is trivial or useless to you ; it seems like a path is not correctly specified, but I cannot figure out how to fix this. The pyleoclim package is already imported in conf.py
, but perhaps autodoc requires the source code to be in the same folder? Do you know what is going on? I'd appreciate any help.
Best,
Julien
I still cannot reproduce the issue.
I've done the following:
- Add
sphinx.ext.autodoc
toconf.py
of jupyter-sphinx. - Add
.. autoclass:: jupyter_sphinx.ast.JupyterWidgetStateNode
somewhere in theindex.rst
- Extend the docstring of
jupyter_sphinx.ast.JupyterWidgetStateNode
with
.. jupyter-execute::
print("hello")
I then build the docs and see
Come to think of it, the code branch that yields the errors is a part of the literal include option; are you doing anything with literal includes?
With apologies for the silly question: what do you mean by "literal includes"?
Nvm. I found this, which seems relevant. My doc build obviously is triggering that branch of load_content()
, but I am not consciously using any literal includes, so my autoclass
call (or something else in pyleoclim's docstrings) must be calling that under the hood.
Here's what I added to the jupyter-sphinx index.rst
:
Jupyter Sphinx Extension
========================
.. toctree::
:maxdepth: 2
:caption: Contents:
Jupyter-sphinx is a Sphinx extension that executes embedded code in a Jupyter
kernel, and embeds outputs of that code in the document. It has support
for rich output such as images, Latex math and even javascript widgets, and
it allows to enable `thebelab <https://thebelab.readthedocs.io/>`_ for live
code execution with minimal effort.
Installation
------------
Get jupyter-sphinx from pip:
.. code-block:: bash
pip install jupyter-sphinx
or conda:
.. code-block:: bash
conda install jupyter_sphinx -c conda-forge
SsaRes (pyleoclim.SsaRes)
-------------------------
.. autoclass:: pyleoclim.core.ssares.SsaRes
:members:
Enabling the extension
----------------------
To enable the extension, add ``jupyter_sphinx`` to your enabled extensions in
``conf.py``:
.. code-block:: python
extensions = [
'jupyter_sphinx',
]
(in between Installation and Enabling the extension).
If you want to see how the docstrings of SsaRes are defined, look here
@CommonClimate is this issue still a problem or can it be considered as solved ?
Thank you for following up. My amazing student @jordanplanders managed to resolve this issue back in June, and our documentation now proudly uses jupyter-sphinx. Thanks for the amazing work!