more flexible handling of graphviz

sienkiew avatarsienkiew created an issue

I had to install graphviz to get the inheritance graphs that my users want. I had several problems, though no single machine had all of them:

- "dot -Tpng" said that png is not a recognized format

- "dot -Tpdf" said that pdf is not a recognized format. (At least one machine suggested a list of recognized formats that _included_ pdf!)

- unable to build Python language bindings when installing graphviz (happens everywhere - seems to be a bug in graphviz autoconfig)

My solution was a patch that allows sphinx more flexibility in how it interacts with 'dot'. The attached patch adds features to the conf.py so that you can select:

- image formats other than png when generating html

- 'dot -Tps2' followed by ps2pdf, rather than 'dot -Tpdf' -- works when dot doesn't know how to make pdf directly.

- 'dot -Tfig' followed by fig2dev to convert the fig file to latex sources. This doesn't work because latex gives an error on a \color directive; I don't know how to fix that, but it gives me the impression that someone proficient with latex could fix it easily, so I didn't remove it before making the patch.

I tested the web images with png, gif, jpg, and an invalid choice.

I tested the latex images with pdf (of course, dot -Tpdf doesn't work for me, but it gave the expected error), ps converted to pdf, and fig converted to latex (also doesn't work, but gives errors as described above). I tested with an invalid choice.

When generating html, configuring a bad image format causes the error from 'dot' about the unrecognized format.

When generating latex, configuring a bad mode raises an exception.

One deficiency of this patch is that it uses os.system() to run the external programs. It may be that the Popen code in ext/graphviz.py should be generalized into a library, where it could be used again to run things like ps2pdf. I really have to get on to working on other things, though, so I thought I would send in this patch as-is.

1 attachment: patch - relative to release 0.6.4

Comments (3)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.