sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
Other
64 stars 45 forks source link

SyntaxError in Matlab.py #205

Closed awohns closed 11 months ago

awohns commented 1 year ago

I am using matlabdomain to document Matlab code in this project. Since May, my readthedocs builds have been failing at the following module: sphinxcontrib/matlab.py

Here's the command it fails at: python -m sphinx -T -E -b html -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html

With the following output and traceback:

Running Sphinx v5.3.0 /home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/setuptools_scm/git.py:135: UserWarning: "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/checkouts/latest" is shallow and may cause errors warnings.warn(f'"{wd.path}" is shallow and may cause errors')

Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main args.pdb) File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 223, in init self.setup_extension(extension) File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 398, in setup_extension self.registry.load_extension(self, extname) File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 459, in load_extension mod = import_module(extname) File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinxcontrib/matlab.py", line 11, in from . import mat_documenters as doc File "", line 1 (self.modname=) ^ SyntaxError: invalid syntax

Exception occurred: File "/home/docs/checkouts/readthedocs.org/user_builds/ldgm/envs/latest/lib/python3.7/site-packages/sphinxcontrib/matlab.py", line 11, in from . import mat_documenters as doc File "", line 1 (self.modname=) ^ SyntaxError: invalid syntax The full traceback has been saved in /tmp/sphinx-err-0w16tjv4.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!

I'm pretty unsure what's wrong here, builds were not failing until May, and the changes we made in May only changed docstrings. Any pointers on what could have happend would be much appreciated! Thank you

rdzman commented 1 year ago

What version of matlabdomain are you using? And have you tried re-installing or updating?

It looks like it's hitting a syntax error in one of the matlabdomain files, because of the string (self.modname=), which I can't find in any recent versions of the code.

joeced commented 1 year ago

I tried building it locally with Python 3.9.5 and that works!

Output of pip freeze

alabaster==0.7.13
attrs==23.1.0
Babel==2.12.1
certifi==2023.5.7
charset-normalizer==3.2.0
colorama==0.4.6
docutils==0.18.1
idna==3.4
imagesize==1.4.1
importlib-metadata==6.8.0
Jinja2==3.1.2
jsonschema==4.18.4
jsonschema-specifications==2023.6.1
MarkupSafe==2.1.3
networkx==3.1
numpy==1.25.1
packaging==23.1
pandas==2.0.3
Pygments==2.15.1
python-dateutil==2.8.2
pytz==2023.3
referencing==0.29.3
requests==2.31.0
rpds-py==0.8.11
setuptools-scm==7.1.0
six==1.16.0
snowballstemmer==2.2.0
sphinx==6.2.1
sphinx-argparse==0.4.0
sphinx-copybutton==0.5.2
sphinx-issues==3.0.1
sphinx-rtd-theme==1.2.2
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-fulltoc==1.2.0
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-matlabdomain==0.19.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
svgwrite==1.4.3
tomli==2.0.1
tqdm==4.65.0
tskit==0.5.5
typing-extensions==4.7.1
tzdata==2023.3
urllib3==2.0.3
zipp==3.16.2

Can you link directly to read-the-docs output?

awohns commented 1 year ago

Thank you for your responses and my apologies for the late response. Here is a a link to the read-the-docs output

joeced commented 1 year ago

I found the problem. I use f-strings with the {self.modname=} syntax. This was only added in Python 3.8. In the build output it's using Python 3.7.

image

However, you specified Python 3.11 in your https://github.com/awohns/ldgm/blob/main/docs/.readthedocs.yml file?

Could the build be specified somewhere else, or in another branch?

joeced commented 11 months ago

As this is expected, I'll close the issue now.