diff --git a/sphinx_d2lang/d2lang.py b/sphinx_d2lang/d2lang.py index 5b02c40..fb3060e 100644 --- a/sphinx_d2lang/d2lang.py +++ b/sphinx_d2lang/d2lang.py @@ -9,10 +9,12 @@ import subprocess class D2langDirective(Directive): has_content = True def run(self): + # TODO : add tempfile for diag_source + outdir = self.state.document.settings.env.app.builder.outdir diag_source = self.content d2_bin = which('d2') - cmd_line = "echo %s | %s - %s" % (diag_source, d2_bin, "/tmp/test.svg") + cmd_line = "echo %s | %s - %s" % (diag_source, d2_bin, outdir + "/test.svg") args = shlex.split(cmd_line) subprocess.run(args) - paragraph_node = nodes.paragraph(text="""BobBobAliceAlicehello""") - return [paragraph_node] + image_node = nodes.image(uri=outdir + "/test.svg") + return [image_node]