sphinx-contrib / matlabdomain

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

`BuildEnvironment.warn_node` is deprecated #101

Closed denisrosset closed 3 years ago

denisrosset commented 4 years ago

Thus, instead of emitting a warning, Sphinx crashes hard when there is a problem with reference resolution. Full output below.

Running Sphinx v2.3.1
[autosummary] generating autosummary for: api/base.rst, api/groups.rst, api/index.rst, index.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 4 source files that are out of date
updating environment: [new config] 4 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                                                                    
WARNING: [sphinxcontrib-matlabdomain] Parsing failed in +replab.SedumiData. Check if valid MATLAB code.
WARNING: [sphinxcontrib-matlabdomain] Parsing failed in +replab.CommutantVar. Check if valid MATLAB code.
/home/denis/w/replab/sphinxdocs/_src/+replab:docstring of +replab.Monoid:3: WARNING: Unknown target name: "https://en.wikipedia.org/wiki/monoid".
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... WARNING: unsupported theme option 'globaltoc_depth' given
done
/home/denis/software/jupyter-env/lib/python3.6/site-packages/guzzle_sphinx_theme/guzzle_sphinx_theme/layout.html:198: RemovedInSphinx30Warning: To modify script_files in the theme is deprecated. Please insert a <script> tag directly in your theme instead.
writing output... [ 50%] api/groups                                                                                                                                
Exception occurred:
  File "/home/denis/software/jupyter-env/lib/python3.6/site-packages/sphinxcontrib/matlab.py", line 735, in resolve_xref
    env.warn_node(
AttributeError: 'BuildEnvironment' object has no attribute 'warn_node'
joeced commented 4 years ago

Could you provide some minimal example that has this error?

denisrosset commented 4 years ago

There it is:

https://github.com/denisrosset/sphinxcontrib-matlabdomain-report

Note that I'm doing weird things with references (autogenerating references for inherited members), so that's probably what triggers the original warning. I'm fine with that (and found that not using the dot prefix solves the problem).

The triggered warning is quite fragile, and some attempts to minimize the report further were unsuccessful, thus I'm leaving the code as it is.

The bug report concerns the way the warning is triggered by the Matlab domain, by calling warn_node that has probably been deprecated. I was unable to find which Sphinx version deprecated that method though.

joeced commented 4 years ago

Thanks for the link. I have been busy at home and at work, and had no time to look into this yet. But I'll try to squeeze it in.

denisrosset commented 4 years ago

No problem, it's sitting there and not going away

joeced commented 4 years ago

Finally, had some time to look at this. I can confirm, that the it indeed triggers this warning. I found the commit where warn_node was removed: https://github.com/sphinx-doc/sphinx/commit/02afc357ef530910b136396e611bf66351af1901 - and as you found, no alternative. I'll try to figure out how to warn.

Edit: Found a fix. @denisrosset would it be okay to include part of the repo you created as a test?

denisrosset commented 4 years ago

Absolutely! please take anything you want. If you want me to run some tests too; happy to do so.

joeced commented 3 years ago

I just looked at it again - and it seems I can replace warn_node with a simple logger warning. Would that be ok for your use-case?