summaryrefslogtreecommitdiff
path: root/sphinx/ext/graphviz.py
diff options
context:
space:
mode:
authorMichael Goerz <goerz@stanford.edu>2018-04-21 00:59:27 -0400
committerMichael Goerz <goerz@stanford.edu>2018-04-21 00:59:27 -0400
commit4a2b22737660ad1a933a7da5149725b3918e8c57 (patch)
tree8251dcd9716198a307abca93de095d35aa729dcb /sphinx/ext/graphviz.py
parentb689fb1c12252984a3fa0ed90e7b0276919cf22b (diff)
downloadsphinx-git-4a2b22737660ad1a933a7da5149725b3918e8c57.tar.gz
Allow imgcls as class for SVG Graphviz <object>
For consistency, the `<object>` tag for the SVG output of a inheritance-diagram should have the same `class="inheritance"` attribute that the corresponding `<img>` tag for the PNG format has. This allows to define the CSS attribute object.inheritance { max-width: 100%; } which for SVG (unlike PNG) actually works and makes sense. Added a test for inheritance-diagrams in SVG.
Diffstat (limited to 'sphinx/ext/graphviz.py')
-rw-r--r--sphinx/ext/graphviz.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py
index f0b321378..127146f94 100644
--- a/sphinx/ext/graphviz.py
+++ b/sphinx/ext/graphviz.py
@@ -290,9 +290,11 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
self.body.append('<div align="%s" class="align-%s">' %
(node['align'], node['align']))
if format == 'svg':
- svgtag = '''<div class="graphviz"><object data="%s" type="image/svg+xml">
- <p class="warning">%s</p></object></div>\n''' % (fname, alt)
- self.body.append(svgtag)
+ self.body.append('<div class="graphviz">')
+ self.body.append('<object data="%s" type="image/svg+xml" %s>\n' %
+ (fname, imgcss))
+ self.body.append('<p class="warning">%s</p>' % alt)
+ self.body.append('</object></div>\n')
else:
with codecs.open(outfn + '.map', 'r', encoding='utf-8') as mapfile: # type: ignore
imgmap = ClickableMapDefinition(outfn + '.map', mapfile.read(), dot=code)