sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.52k stars 2.12k forks source link

Problem with PIL and sphinx_pyreverse : cannot treat an SVG image generated #11042

Closed cyrduf closed 9 months ago

cyrduf commented 1 year ago

Describe the bug

Hello, I install graphviz 2.44.1, Pillow 9.3.0 and sphinx-pyreverse==0.0.17 My goal is to générate uml diagrams from python project.

I add this in my conf.py for sphinx :

extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.coverage", "sphinx.ext.ifconfig", "sphinx.ext.viewcode", "sphinx.ext.inheritance_diagram", "sphinx_autodoc_typehints", "sphinx.ext.graphviz", "sphinxcontrib.seqdiag", "sphinxcontrib.actdiag", "sphinxcontrib.blockdiag", "sphinxcontrib.nwdiag", "sphinxcontrib.rackdiag", "sphinxcontrib.packetdiag", "sphinx_pyreverse", "recommonmark", ]

Pyreverse configuration

sphinx_pyreverse_output = 'svg' sphinx_pyreverse_filter_mode = 'ALL' sphinx_pyreverse_module_names = "y" sphinx_pyreverse_show_builtin = False sphinx_pyreverse_all_associated = True

sphinx_pyreverse_show_associated = 2

sphinx_pyreverse_all_ancestors = True

sphinx_pyreverse_show_ancestors = 2

sphinx_pyreverse_only_classnames = False

And this in a rst file for generation : my file is in a subdirectory : .../MyProject/MyDir1/MyModulePython1.py

.. uml:: MyProject.MyDir1.MyModulePython1 :classes: :packages:

But It never works !!!!

The traces:

-- Build files have been written to: /home/userproj/PROJECT/MyProject/build [ 14%] Checking sources code style ... [ 28%] Checking sources code style done [ 28%] Built target check_style [ 42%] Clean pycache directories in sources [ 42%] Built target clean_pycache [ 57%] Building MyProject-8.0.7-py3-none-any.whl ... [ 71%] Building MyProject-8.0.7-py3-none-any.whl done [ 71%] Built target build_wheel [ 85%] Build sphinx documentation ... Sphinx v4.5.0 en cours d'exécution chargement des traductions [en]... fait création du dossier de destinataire... fait Construction en cours [mo] : cibles périmées pour les fichiers po 0 Construction [html] : cibles périmées pour les fichiers sources 44 Mise à jour de l'environnement : [nouvelle configuration] 44 ajouté(s), 0 modifié(s), 0 supprimé(s) /usr/local/lib/python3.8/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document
warn("Container node skipped: type={0}".format(mdnode.t)) sphinx-pyreverse: Running: pyreverse --output svg --project MyProject.MyDir1.MyModulePython1 --filter-mode ALL --all-ancestors --all-associated --module-names y MyProject.MyDir1.MyModulePython1

Une exception a été levée : File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 3186, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file '/home/userproj/PROJECT/MyProject/share/doc/uml_images/classes_MyProject.MyDir1.MyModulePython1.svg' Le traceback complet a été sauvé dans /tmp/sphinx-err-0hbdqplp.log, au cas où vous souhaiteriez signaler le problème aux développeurs.
Merci de rapporter ceci s'il s'agit d'une erreur utilisateur, afin d'améliorer le message d'erreur à l'avenir. Un rapport d'erreur peut être déposé dans le système de tickets à https://github.com/sphinx-doc/sphinx/issues. Merci ! make[2]: [doc/html/index.html] Erreur 2 make[1]: [CMakeFiles/build_doc.dir/all] Erreur 2 make: *** [all] Erreur 2

So how to resolve this : it seems the fact that it's a sub-module with '.' PIL doesn't recognize the file. If I open /home/userproj/PROJECT/MyProject/share/doc/uml_images/classes_MyProject.MyDir1.MyModulePython1.svg the image is correct.

It's very blocking. Can you tell em how to correct this ? or how to patch the spinx-pyreverse or Pillow libraries to solve this ?

Other question less important :

You can see the SVG generated that is not accepted by PIL in joined

classes_prophyl_core mid_channel_data Converter

How to Reproduce

Minimal method (you can also paste the contents of index.rst and conf.py into this report):

$ echo "Content demonstrating the bug..." > index.rst
$ echo "" > conf.py
$ sphinx-build -M html . _build
$ # open _build/html/index and see bla bla

git clone method (this is advised against, to help the Sphinx team):

$ git clone https://github.com/.../some_project
$ cd some_project
$ pip install -r requirements.txt
$ cd docs
$ make html SPHINXOPTS="-D language=de"
$ # open _build/html/index and see bla bla

Environment Information

Pillow==9.3.0 pycodestyle==2.8.0 pylint==2.15.9 pyparsing==3.0.8 recommonmark==0.7.1 Sphinx==4.5.0 sphinx-autodoc-typehints==1.18.1 sphinx-pyreverse==0.0.17 sphinx-rtd-theme==1.0.0 sphinxcontrib-actdiag==3.0.0 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-blockdiag==3.0.0 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-nwdiag==2.0.0 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-seqdiag==3.0.0 sphinxcontrib-serializinghtml==1.1.5

Sphinx extensions

given in description

Additional context

No response

AA-Turner commented 9 months ago

Unfortunately we don't maintain sphinx-pyreverse, you would have to speak to that team.

A