sphinx-contrib / matlabdomain

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

NoneType AttributeError in import_object #114

Closed dumpadu closed 3 years ago

dumpadu commented 3 years ago

First of all: good work and thanks a lot for the development of this extension.

When I start sphinx with this extension (latest version), the build runs into an exception:

Exception occurred: File "*\python\3.6.5\lib\site-packages\sphinxcontrib\mat_documenters.py", line 917, in import_object if self.object.attrs.get('Static'): AttributeError: 'NoneType' object has no attribute 'attrs'

I added a local security check by extending the condition (if self.object and ...), the build run successfully and the result fits for me. Is this the right way or is the problem to be found elsewhere?

joeced commented 3 years ago

Hi. Can you provide a small example that triggers this behavior?

Andrey1994 commented 3 years ago

I see exactly the same, will provide a link to the project soon

Andrey1994 commented 3 years ago

https://github.com/brainflow-dev/brainflow/pull/202

I've added the same security check, build run with warnings about NoneType obj and seems like some doc string missed

joeced commented 3 years ago

@Andrey1994 can you point me to the log where I can see the error.

Andrey1994 commented 3 years ago

In requirements replace my fork by upstream version from pypi and you will reproduce it

joeced commented 3 years ago

When I try to build the docs (on Windows) I run into the following error:

brainflow\docs>make html
Running Sphinx v3.2.1
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 87 source files that are out of date
updating environment: [new config] 87 added, 0 changed, 0 removed
C:\Users\Jorgen\Documents\github\brainflow\docs\.venv\Lib\site-packages\mne\viz\_brain\tests\test.ipynb:6: WARNING: Each notebook should have at least one section title

Notebook error:
DeadKernelError in .venv\Lib\site-packages\nbclient\tests\files\Autokill.ipynb:
Kernel died

Can you please advice?

I see that you set the version of Sphinx to 3.2.1, I tried doing that on the tests, but they all pass.

Andrey1994 commented 3 years ago

I can not reproduce it

Notebook error:
DeadKernelError in .venv\Lib\site-packages\nbclient\tests\files\Autokill.ipynb:

and in rtd there is no such issue,

Did you use exactly the same versions of all packages from requirements.txt?

joeced commented 3 years ago

Here's what I did: (Note: I had to remove everything nbsphinx related in the docs/conf.py file to make it work!)

cd brainflow
python -m venv .venv
.venv\Scripts\activate
pip install -r docs\requirements.txt
cd docs
make html

Now It will run, but produces warnings.

However, I did try having a Python virtual environment in docs/.venv/. This generates the error. It looks like a problem with autosummary. There is an old bug (#37) that discusses autosummary issues, but I never dived into it.

I can't see where you generate the docs in the Github actions, can you point me to it?

Andrey1994 commented 3 years ago

Yes, there are warnings about Nonetype object from matlab extension, if you replace matlabdomain package patched by me by upstream package there will be this error instead warnings

Andrey1994 commented 3 years ago

https://github.com/brainflow-dev/brainflow/blob/matlab_docs/docs/requirements.txt#L13

Andrey1994 commented 3 years ago

I dont generate docs in github actions, it uses readthedocs to build it

Andrey1994 commented 3 years ago

You can find deployed docs here https://brainflow.readthedocs.io/en/matlab_docs/UserAPI.html#matlab-api-reference and as you can see there are some doc strings ignored also static methods are not recognized correctly(only the first one recognized as static method). I think its a result of workaround which I applied to original issue mentioned here and real fix needed instead

Andrey1994 commented 3 years ago

I know what was wrong.

I use code style with space before openning bracket and its 100% valid in matlab, but seems like parser here doesnt expect it and fails

joeced commented 3 years ago

I'll look at it again tonight. That is why I seek out minimal failing examples - it makes it easier to find the issue :)

joeced commented 3 years ago

Found the bug - and you were correct. We didn't handle trailing spaces correctly. It is fixed now - and I'll release a new version ASAP. Waiting for travis-ci to build it.