`sphinx.ext.graphviz`: show graph image in inline by default

To support subsutituion syntax, make graphviz node inline (ref: #1149).
Now graphviz directive behaves like ``image`` directive when no captions.
If specified, it generates ``figure`` node and ``caption`` node like
``figure`` directive.
This commit is contained in:
Takeshi KOMIYA
2016-01-17 19:23:55 +09:00
parent 492f60c371
commit 14f58e6619
5 changed files with 56 additions and 17 deletions
+8
View File
@@ -2,4 +2,12 @@
extensions = ['sphinx.ext.graphviz']
master_doc = 'index'
<<<<<<< 492f60c37185dccee1e42c01fb5d87ed42f45608
exclude_patterns = ['_build']
=======
latex_documents = [
(master_doc, 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl', 'manual'),
]
>>>>>>> ``sphinx.ext.graphviz``: show graph image in inline by default
+6
View File
@@ -5,3 +5,9 @@ graphviz
:caption: caption of graph
bar -> baz
.. |graph| digraph:: bar
bar -> baz
Hello |graph| graphviz world
+22 -3
View File
@@ -15,12 +15,31 @@ from util import with_app, SkipTest
@with_app('html', testroot='ext-graphviz')
def test_graphviz(app, status, warning):
def test_graphviz_html(app, status, warning):
app.builder.build_all()
if "dot command 'dot' cannot be run" in warning.getvalue():
raise SkipTest('graphviz "dot" is not available')
content = (app.outdir / 'index.html').text()
html = ('<p class="graphviz">\s*<img .*?/>\s*</p>\s*'
'<p class="caption"><span class="caption-text">caption of graph</span>')
html = ('<div class="figure" .*?>\s*<img .*?/>\s*<p class="caption">'
'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
assert re.search(html, content, re.S)
html = 'Hello <img .*?/>\n graphviz world'
assert re.search(html, content, re.S)
@with_app('latex', testroot='ext-graphviz')
def test_graphviz_latex(app, status, warning):
app.builder.build_all()
if "dot command 'dot' cannot be run" in warning.getvalue():
raise SkipTest('graphviz "dot" is not available')
content = (app.outdir / 'SphinxTests.tex').text()
macro = ('\\\\begin{figure}\[htbp\]\n\\\\centering\n\\\\capstart\n\n'
'\\\\includegraphics{graphviz-\w+.pdf}\n'
'\\\\caption{caption of graph}\\\\end{figure}')
assert re.search(macro, content, re.S)
macro = 'Hello \\\\includegraphics{graphviz-\w+.pdf} graphviz world'
assert re.search(macro, content, re.S)