# more flexible handling of graphviz

sienkiew 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

Any chance of getting this into the release?

1. Not sure yet how to handle this, but will look for 1.1.

• removed version

Removing version: 0.6.4 (automated comment)