mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
`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:
@@ -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
|
||||
|
||||
@@ -5,3 +5,9 @@ graphviz
|
||||
:caption: caption of graph
|
||||
|
||||
bar -> baz
|
||||
|
||||
.. |graph| digraph:: bar
|
||||
|
||||
bar -> baz
|
||||
|
||||
Hello |graph| graphviz world
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user