update tmp path

This commit is contained in:
Michaël Ricart 2025-03-04 17:27:34 +01:00
parent 2e0d474d90
commit c067d5fa43
3 changed files with 9 additions and 4 deletions

View file

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "sphinxcontrib-d2lang"
version = "0.0.1"
version = "0.0.3"
authors = [
{ name="Milka64", email="michael.ricart@0w.tf" },
]

View file

@ -14,7 +14,7 @@ with open('README.md', 'r', encoding='utf8') as file:
setup(
name='sphinxcontrib-d2lang',
version='0.0.1',
version='0.0.3',
author='Milka64',
author_email='michael.ricart@0w.tf',
url='https://git.0w.tf/Milka64/sphinx-d2lang/',

View file

@ -42,7 +42,7 @@ class D2langDirective(SphinxDirective):
else:
raise
else:
with tempfile.NamedTemporaryFile() as fp:
with tempfile.NamedTemporaryFile(dir="./") as fp:
for line in self.content.data:
fp.write(bytes(line,'utf-8'))
fp.write(bytes('\n','utf-8'))
@ -53,7 +53,12 @@ class D2langDirective(SphinxDirective):
def build_svg(diag_src, out_dir, filename, layout):
d2_bin = which('d2')
cmd_line = '%s -l %s %s %s' % (d2_bin, layout, diag_src, out_dir + "/" + filename)
cmd_line = '{bin} -l {layout} {src} {out}'.format(
bin=d2_bin,
layout=layout,
src=diag_src,
out=out_dir + "/" + filename
)
args = shlex.split(cmd_line)
subprocess.run(args)
return True