sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
69 stars 45 forks source link

Error when parsing mlapp file with no descriptions #195

Closed luhuhis closed 1 year ago

luhuhis commented 1 year ago

Hi, after upgrading from version 0.18 to 0.19 (or 0.20rc3), I get the following error:

Extension error (sphinxcontrib.matlab):
Handler <function analyze at 0x7f8c003ad480> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, NoneType found)

Is it possible to somehow increase the verbosity of the errors and provide more details on why this could happen? With the current error message it's impossible for me to see where the error might come from.

By the way, thanks to everyone who contributed to this project. Very useful.

joeced commented 1 year ago

You can increase the verbosity of sphinx with:

sphinx-build -vvv -b html . _build\html > sphinx.log

This will pipe all trace messages to the sphinx.log file at high verbosity level (´-vvv`). I hope this helps you.

And sorry that it throws an error.

luhuhis commented 1 year ago

This is the full error message:

Traceback (most recent call last):
  File "/home/luis/.local/lib/python3.10/site-packages/sphinx/events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/matlab.py", line 844, in analyze
    mat_types.analyze(app)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 143, in analyze
    recursive_find_all(root)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 83, in recursive_find_all
    recursive_find_all(o)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 83, in recursive_find_all
    recursive_find_all(o)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 83, in recursive_find_all
    recursive_find_all(o)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 81, in recursive_find_all
    o.safe_getmembers()
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 474, in safe_getmembers
    value = self.getter(key, None)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 538, in getter
    entity = MatObject.matlabify(".".join([self.package, name]))
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 301, in matlabify
    return MatObject.parse_mlappfile(mlappfile, name, path)
  File "/home/luis/.local/lib/python3.10/site-packages/sphinxcontrib/mat_types.py", line 414, in parse_mlappfile
    docstring = "\n\n".join(doc)
TypeError: sequence item 0: expected str instance, NoneType found

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

Traceback (most recent call last):
  File "/home/luis/.local/lib/python3.10/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/home/luis/.local/lib/python3.10/site-packages/sphinx/application.py", line 268, in __init__
    self._init_builder()
  File "/home/luis/.local/lib/python3.10/site-packages/sphinx/application.py", line 339, in _init_builder
    self.events.emit('builder-inited')
  File "/home/luis/.local/lib/python3.10/site-packages/sphinx/events.py", line 107, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function analyze at 0x7f848da123b0> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, NoneType found)

Extension error (sphinxcontrib.matlab):
Handler <function analyze at 0x7f848da123b0> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, NoneType found)

I guess its having trouble parsing an mlapp file?

joeced commented 1 year ago

Definitely look that way. Please upload the file, so I can have look at the parsing issue

luhuhis commented 1 year ago

Unfortunately I cannot provide the mlapp file. However, I found a solution:

https://github.com/sphinx-contrib/matlabdomain/blob/13dd4c0d5a5c79a7a2582bdbaca2162125538c65/sphinxcontrib/mat_types.py#L267-L270

if I change this to

        if coreDesc is not None and coreDesc.text is not None:
            doc.append(coreDesc.text)
        if metaDesc is not None and metaDesc.text is not None:
            doc.append(metaDesc.text)

the error is gone.

joeced commented 1 year ago

Can you make a pull request for that? I'm away from a computer for some weeks

man. 26. jun. 2023 15.08 skrev Luis Altenkort @.***>:

Unfortunately I cannot provide the mlapp file. However, I found a solution:

https://github.com/sphinx-contrib/matlabdomain/blob/13dd4c0d5a5c79a7a2582bdbaca2162125538c65/sphinxcontrib/mat_types.py#L267C1-L270

if I change this to

    if coreDesc is not None and coreDesc.text is not None:
        doc.append(coreDesc.text)
    if metaDesc is not None and metaDesc.text is not None:
        doc.append(metaDesc.text)

the error is gone.

— Reply to this email directly, view it on GitHub https://github.com/sphinx-contrib/matlabdomain/issues/195#issuecomment-1607436447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFM3BSRR26LHI5CJ26C7P3DXNGCUHANCNFSM6AAAAAAZRUVRE4 . You are receiving this because you commented.Message ID: @.***>

luhuhis commented 1 year ago

Sure, there it is