Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinx.ext.graphviz: custom node shape images are not copied to _images at building #8232

Open
Tilix4 opened this issue Sep 21, 2020 · 7 comments

Comments

@Tilix4
Copy link

Tilix4 commented Sep 21, 2020

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  • Start from autodoc

  • Unzip this archive in source: graphviz_image_copy_issue.zip

  • Build the doc: make html

  • Display the built doc in a browser

  • The graph doesn't display the declared image in the custom node.

  • Now copy the film.svg file manually into build/html/_images

  • Refresh the documentation in the browser, the custom shape displays correctly

Expected behavior
The targetted image to be copied in build/html/_images by default.

Your project
Link to your sphinx project, or attach zipped small project sample.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment info

  • OS: Mac 10.14.5
  • Python version: 3.7.7
  • Sphinx version: 3.2.1
  • Sphinx extensions: sphinx.ext.graphviz
@tk0miya
Copy link
Member

tk0miya commented Jan 26, 2021

This report contains a bug and a feature request.

The first is a bug that graphviz failed to find the image files if the image source (.dot) file is placed at sub directory. It was caused that our graphviz extension invokes dot command just under the source directory. I confirmed the bug with graphviz_output_format = 'png' (default setting).

And another one is the image files refered from the image source are not copied. It is happened when graphviz_output_format = 'svg'. The current implementation of graphviz extension only invokes graphviz to convert the graph to image. It does not copy the images referred inside graph. To support it, we need to parse and detect images referred by the image source and copy them all to the output directory.

@tk0miya tk0miya added this to the some future version milestone Jan 26, 2021
@tk0miya tk0miya added the type:enhancement enhance or introduce a new feature label Jan 26, 2021
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2021
…le is in subdir

To support images for graphviz, graphviz commands (ex. dots) should be
invoked at the directory placed the graph file.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2021
…sphinx-doc#8232)

To support images for graphviz, graphviz commands (ex. dots) should be
invoked at the directory placed the graph file.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2021
…sphinx-doc#8232)

To support images for graphviz, graphviz commands (ex. dots) should be
invoked at the directory placed the graph file.
@tk0miya
Copy link
Member

tk0miya commented Jan 26, 2021

I posted #8766 to fix the bug.

@tk0miya
Copy link
Member

tk0miya commented Jan 26, 2021

Note: I think pydot might help to parse the graph file.
https://github.com/pydot/pydot

tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 27, 2021
…sphinx-doc#8232)

To support images for graphviz, graphviz commands (ex. dots) should be
invoked at the directory placed the graph file.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 27, 2021
…sphinx-doc#8232)

To support images for graphviz, graphviz commands (ex. dots) should be
invoked at the directory placed the graph file.
tk0miya added a commit that referenced this issue Jan 27, 2021
graphviz: Image node is not rendered if graph file is in subdir (refs: #8232)
@alexander-nitsche
Copy link

Hi @tk0miya ,

i am still facing the bug in Sphinx v4.3.1 (latest).

For example for source files

  • /Documentation/WritingReST/Graphs.rst
  • /Documentation/WritingReST/typo3.png

and the minimal reST snippet:

.. graphviz::

   digraph {
      typo3 [
         image="typo3.png"
         label=""
      ]
    }

the image does not get copied to /Documentation-GENERATED-temp/Result/project/0.0.0/_images/typo3.png and thus the image url is not resolvable in /Documentation-GENERATED-temp/Result/project/0.0.0/_images/graphviz-6d1b84d1ecedd782b117d9a9791de374e2ea939e.svg:

<image xlink:href="typo3.png" width="482px" height="204px" preserveAspectRatio="xMinYMin meet" x="15.6798" y="-211.602"/>

@tk0miya
Copy link
Member

tk0miya commented Dec 18, 2021

@alexander-nitsche Thanks,
As you reported, the images referred the graph are not copied. So we need to parse the graph and find the images to copy them. How about trying to improve it?

@alexander-nitsche
Copy link

hi @tk0miya , if sphinx would be written in PHP i would do it but have to stick to provide bug report details for the moment.

@tk0miya
Copy link
Member

tk0miya commented Dec 19, 2021

Okay, don't mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants