mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fit graphviz images to page.
Use \sphinxincludegraphics, that's what the core image directives use and it handles fitting properly.
This commit is contained in:
parent
e505cbb3be
commit
4a913e5cee
@ -341,7 +341,7 @@ def render_dot_latex(self, node, code, options, prefix='graphviz'):
|
|||||||
post = r'\hspace*{\fill}}'
|
post = r'\hspace*{\fill}}'
|
||||||
self.body.append('\n%s' % pre)
|
self.body.append('\n%s' % pre)
|
||||||
|
|
||||||
self.body.append(r'\includegraphics{%s}' % fname)
|
self.body.append(r'\sphinxincludegraphics[]{%s}' % fname)
|
||||||
|
|
||||||
if not is_inline:
|
if not is_inline:
|
||||||
self.body.append('%s\n' % post)
|
self.body.append('%s\n' % post)
|
||||||
|
@ -91,20 +91,20 @@ def test_graphviz_latex(app, status, warning):
|
|||||||
|
|
||||||
content = (app.outdir / 'SphinxTests.tex').text()
|
content = (app.outdir / 'SphinxTests.tex').text()
|
||||||
macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
|
macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
|
||||||
'\\\\includegraphics{graphviz-\\w+.pdf}\n'
|
'\\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf}\n'
|
||||||
'\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}')
|
'\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}')
|
||||||
assert re.search(macro, content, re.S)
|
assert re.search(macro, content, re.S)
|
||||||
|
|
||||||
macro = 'Hello \\\\includegraphics{graphviz-\\w+.pdf} graphviz world'
|
macro = 'Hello \\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf} graphviz world'
|
||||||
assert re.search(macro, content, re.S)
|
assert re.search(macro, content, re.S)
|
||||||
|
|
||||||
macro = ('\\\\begin{wrapfigure}{r}{0pt}\n\\\\centering\n'
|
macro = ('\\\\begin{wrapfigure}{r}{0pt}\n\\\\centering\n'
|
||||||
'\\\\includegraphics{graphviz-\\w+.pdf}\n'
|
'\\\\sphinxincludegraphics\\[\\]{graphviz-\\w+.pdf}\n'
|
||||||
'\\\\caption{on right}\\\\label{.*}\\\\end{wrapfigure}')
|
'\\\\caption{on right}\\\\label{.*}\\\\end{wrapfigure}')
|
||||||
assert re.search(macro, content, re.S)
|
assert re.search(macro, content, re.S)
|
||||||
|
|
||||||
macro = (r'\{\\hfill'
|
macro = (r'\{\\hfill'
|
||||||
r'\\includegraphics{graphviz-.*}'
|
r'\\sphinxincludegraphics\[\]{graphviz-.*}'
|
||||||
r'\\hspace\*{\\fill}}')
|
r'\\hspace\*{\\fill}}')
|
||||||
assert re.search(macro, content, re.S)
|
assert re.search(macro, content, re.S)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ def test_inheritance_diagram_latex(app, status, warning):
|
|||||||
content = (app.outdir / 'Python.tex').text()
|
content = (app.outdir / 'Python.tex').text()
|
||||||
|
|
||||||
pattern = ('\\\\begin{figure}\\[htbp]\n\\\\centering\n\\\\capstart\n\n'
|
pattern = ('\\\\begin{figure}\\[htbp]\n\\\\centering\n\\\\capstart\n\n'
|
||||||
'\\\\includegraphics{inheritance-\\w+.pdf}\n'
|
'\\\\sphinxincludegraphics\\[\\]{inheritance-\\w+.pdf}\n'
|
||||||
'\\\\caption{Test Foo!}\\\\label{\\\\detokenize{index:id1}}\\\\end{figure}')
|
'\\\\caption{Test Foo!}\\\\label{\\\\detokenize{index:id1}}\\\\end{figure}')
|
||||||
assert re.search(pattern, content, re.M)
|
assert re.search(pattern, content, re.M)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user