fix layout option & check sourcefile exists
This commit is contained in:
parent
2143498418
commit
c89985ec09
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ from docutils.parsers.rst import Directive, directives
|
|||
from sphinx.util.docutils import SphinxDirective
|
||||
|
||||
from shutil import which
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
@ -24,12 +25,16 @@ class D2langDirective(SphinxDirective):
|
|||
output_fname = self.options.get('filename')
|
||||
else:
|
||||
output_fname = 'test.svg'
|
||||
if 'layout':
|
||||
if 'layout' in self.options:
|
||||
layout = self.options.get('layout')
|
||||
else:
|
||||
layout = 'dagre'
|
||||
if self.arguments:
|
||||
path = Path(srcdir + self.arguments[0])
|
||||
if path.is_file():
|
||||
build_svg(self.arguments[0], srcdir, output_fname, layout)
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
with tempfile.NamedTemporaryFile() as fp:
|
||||
for line in self.content.data:
|
||||
|
|
Loading…
Reference in a new issue