sphinx-contrib / matlabdomain

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

Vague error when there is an empty @ClassFolder #225

Closed willem-pennings closed 8 months ago

willem-pennings commented 8 months ago

Due to some kind of Git quirk, I sometimes end up with empty directories in my MATLAB file tree. They could be class directories, like @Test. It turns out that if this is the case, building the documentation fails with a very vague error which I had been scratching my head over for quite some time now:

Extension error (sphinxcontrib.matlab):
Handler <function analyze at 0x000002A1322DE340> for event 'builder-inited' threw an exception (exception: )

I usually build using make html but when running using sphinx-build the verbosity is better and I found out that this error is due to the assertion in mat_types.py:254:

Traceback (most recent call last):
  File "C:\...\.venv\Lib\site-packages\sphinx\events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\sphinxcontrib\matlab.py", line 844, in analyze
    mat_types.analyze(app)
  File "C:\...\.venv\Lib\site-packages\sphinxcontrib\mat_types.py", line 254, in analyze
    assert len(class_entities) == 1
AssertionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\...\.venv\Lib\site-packages\sphinx\cmd\build.py", line 293, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\sphinx\application.py", line 272, in __init__
    self._init_builder()
  File "C:\...\.venv\Lib\site-packages\sphinx\application.py", line 343, in _init_builder
    self.events.emit('builder-inited')
  File "C:\...\.venv\Lib\site-packages\sphinx\events.py", line 108, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function analyze at 0x000001FBDA819C60> for event 'builder-inited' threw an exception (exception: )

I can imagine that others might run into this issue, too, so is it perhaps an idea to handle this situation?

joeced commented 8 months ago

Sorry for the late reply.

I have observed several issues of this kind after the update related to this update (https://github.com/sphinx-contrib/matlabdomain/commit/2cf37c32d14724384f947c8bb6b2252c67e2016a).

I will look into it soon