sphinx.ext.graphviz with SVG output instead of PNG?

99 views
Skip to first unread message

Jason S

unread,
Nov 11, 2009, 12:41:43 PM11/11/09
to sphinx-dev
Is there a way to configure sphinx's graphviz extension so it renders
in SVG rather than PNG? The PNG renderer does an awful job with text,
it depeditates (look it up) the letters.

Henrique Bastos

unread,
Nov 30, 2009, 12:16:14 AM11/30/09
to sphinx-dev
Jason,

On Nov 11, 3:41 pm, Jason S <jmsa...@gmail.com> wrote:
> Is there a way to configure sphinx's graphviz extension so it renders
> inSVGrather than PNG? The PNG renderer does an awful job with text,
> it depeditates (look it up) the letters.

I've modified sphinx.ext.graphviz to support SVG. It's explained on
this blog post: http://henriquebastos.net/2009/11/30/adding-svg-support-to-sphinxs-graphviz-extension/

You can get the source code from Gist at http://gist.github.com/245237

All the best,
--
Henrique Bastos
henr...@bastos.net
http://henriquebastos.net

Jason S

unread,
Dec 4, 2009, 10:46:54 AM12/4/09
to sphinx-dev
On Nov 30, 12:16 am, Henrique Bastos <henri...@bastos.net> wrote:
> I've modified sphinx.ext.graphviz to support SVG. It's explained on
> this blog post:http://henriquebastos.net/2009/11/30/adding-svg-support-to-sphinxs-gr...

hey, that seems to work nicely. Thanks!

A few comments; some of the blog post isn't very clear

> 1. Create an _ext subdirectory on your Sphinx project;
> 2. Download the modified extension from Gist and save it to _ext;

It's not quite clear what this means. I can think of two options. (1)
creating an _ext subdirectory on the individual documentation project.
This would work but doesn't seem to make much sense... why would I do
this for each documentation project I have? (2) creating an _ext
subdirectory on the sphinx install directory -- which on my computer
is C:\appl\python\2.6.2\Lib\site-packages\Sphinx-0.6.3-py2.6.egg\sphinx
\ -- this didn't work, I just took the graphviz_svg.py file and put it
in the ext directory there.

> 3. Edit your config.py and make sure it contains the below lines;
> sys.path.append(os.path.abspath('_ext'))
> extensions = ['graphviz_svg']
> graphviz_output_format = 'svg'

"Edit your config.py": I figured out you mean the "conf.py" file in
the same directory as my .rst source file.
This didn't work either, I did this instead, after putting
graphviz_svg.py into the sphinx install ext directory
extensions = ['sphinx.ext.graphviz_svg']

Also if there are other extensions they need to be included as usual,
so I replaced

extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath',
'sphinx.ext.graphviz']

with

extensions = ['sphinx.ext.todo',
'sphinx.ext.pngmath','sphinx.ext.graphviz_svg']

and it works fine on Firefox / Safari / Opera on Windows. (IE just
loses. :p )

Jason S

unread,
Dec 4, 2009, 10:48:30 AM12/4/09
to sphinx-dev
On Nov 30, 12:16 am, Henrique Bastos <henri...@bastos.net> wrote:

> I've modified sphinx.ext.graphviz to support SVG. It's explained on
> this blog post:http://henriquebastos.net/2009/11/30/adding-svg-support-to-sphinxs-gr...

sphinx admins: could you perhaps review Henrique's solution and fold
it into the sphinx.ext.graphviz extension? Give us end users the
choice between PNG and SVG!

Georg Brandl

unread,
Jan 1, 2010, 6:35:06 PM1/1/10
to sphin...@googlegroups.com

Why not... I've created issue #309 to remember it.

Georg

signature.asc
Reply all
Reply to author
Forward
0 new messages