sphinx-contrib / matlabdomain

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

Extension error during build related to an mlapp file #207

Closed willem-pennings closed 1 year ago

willem-pennings commented 1 year ago

I am getting the following error which I have traced back to the presence of an mlapp file that is located in a subfolder of the matlab_src_dir.

Traceback (most recent call last):
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinx\events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\matlab.py", line 844, in analyze
    mat_types.analyze(app)
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 136, in analyze
    recursive_find_all(root)
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 75, in recursive_find_all
    o.safe_getmembers()
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 458, in safe_getmembers
    value = self.getter(key, None)
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 522, in getter
    entity = MatObject.matlabify(".".join([self.package, name]))
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 289, in matlabify
    return MatObject.parse_mlappfile(mlappfile, name, path)
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinxcontrib\mat_types.py", line 402, 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 "c:\git\model\documentation\.venv\lib\site-packages\sphinx\cmd\build.py", line 279, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinx\application.py", line 262, in __init__
    self._init_builder()
  File "c:\git\model\documentation\.venv\lib\site-packages\sphinx\application.py", line 335, in _init_builder
    self.events.emit('builder-inited')
  File "c:\git\model\documentation\.venv\lib\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 0x000001992BCFF280> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, NoneType found)

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

After temporarily removing the mlapp file, the build proceeds without issues.

If I open the mlapp file as a zip and locate the coreProperties.xml and appMetadata.xml files, they have the following content:

coreProperties.xml (some fields redacted):

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dcterms:created xsi:type="dcterms:W3CDTF">2023-01-05T15:18:58Z</dcterms:created>
  <dc:creator>Redacted</dc:creator>
  <dc:description></dc:description>
  <dcterms:modified xsi:type="dcterms:W3CDTF">2023-07-07T14:35:34Z</dcterms:modified>
  <dc:title>Redacted</dc:title>
  <cp:version>0.4</cp:version>
</cp:coreProperties>

appMetadata.xml (some fields redacted):

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<metadata xmlns="http://schemas.mathworks.com/appDesigner/app/2017/appMetadata">
    <description>Redacted</description>
    <MLAPPVersion>2</MLAPPVersion>
    <minimumSupportedMATLABRelease>R2018a</minimumSupportedMATLABRelease>
    <screenshotMode>auto</screenshotMode>
    <uuid>0b75b99d-07f9-4040-a1a6-832532321323</uuid>
    <AppType>Standard</AppType>
    <componentProducts/>
    <imageRelativePaths/>
    <userComponents/>
</metadata>

Hope this is sufficient!

joeced commented 1 year ago

That was reported earlier and fixed in #196. It's available in a pre-release:

pip install sphinxcontrib-matlabdomain==0.20.0rc8