Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 8ca47a4

Browse files
authored
Add option process to gdot sphinx extension
Add option process to gdot sphinx extension
2 parents c016cdb + 8696568 commit 8ca47a4

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

_unittests/ut_loghelper/test_pypi_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
"this file should not be imported in that location: " +
1313
os.path.abspath(__file__))
1414

15-
from pyquickhelper.loghelper import fLOG
16-
from pyquickhelper.loghelper import enumerate_pypi_versions_date
15+
from pyquickhelper.pycode import ExtTestCase, skipif_circleci, skipif_appveyor
16+
from pyquickhelper.loghelper import fLOG, enumerate_pypi_versions_date
1717

1818

1919
class TestPypiHelper(unittest.TestCase):
2020

21+
@skipif_circleci("connectivity issue")
22+
@skipif_appveyor("connectivity issue")
2123
def test_clone_repo(self):
2224
fLOG(
2325
__file__,

_unittests/ut_sphinxext/test_gdot_extension.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ def test_gdot3_svg(self):
8585
self.assertIn("document.getElementById('gdot-", content)
8686
self.assertIn('foo {\\n \\"bar\\" -> \\"baz\\";\\n}");', content)
8787

88+
def test_gdot3_svg_process(self):
89+
content = """
90+
before
91+
92+
.. gdot::
93+
:format: svg
94+
:process:
95+
96+
digraph foo {
97+
"bar" -> "baz";
98+
}
99+
100+
after
101+
""".replace(" ", "")
102+
103+
content = rst2html(content, writer="html", keep_warnings=True)
104+
self.assertIn("document.getElementById('gdot-", content)
105+
self.assertIn('foo {\\n \\"bar\\" -> \\"baz\\";\\n}");', content)
106+
88107
def test_gdot4_png(self):
89108
content = """
90109
before

src/pyquickhelper/sphinxext/sphinx_gdot_extension.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class GDotDirective(Directive):
3434
* *script*: boolean or a string to indicate than the standard output
3535
should only be considered after this substring
3636
* *url*: url to :epkg:`viz.js`, only if format *SVG* is selected
37+
* *process*: run the script in an another process
3738
3839
Example::
3940
@@ -54,7 +55,8 @@ class GDotDirective(Directive):
5455
The directive also accepts scripts producing
5556
dot graphs on the standard output. Option *script*
5657
must be specified. This extension loads
57-
`sphinx.ext.graphviz <https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html>`_
58+
`sphinx.ext.graphviz <https://www.sphinx-doc.org/
59+
en/master/usage/extensions/graphviz.html>`_
5860
if not added to the list of extensions:
5961
6062
Example::
@@ -82,6 +84,7 @@ class GDotDirective(Directive):
8284
'format': directives.unchanged,
8385
'script': directives.unchanged,
8486
'url': directives.unchanged,
87+
'process': directives.unchanged,
8588
}
8689

8790
_default_url = "http://www.xavierdupre.fr/js/vizjs/viz.js"
@@ -96,6 +99,8 @@ def run(self):
9699
else:
97100
format = '?'
98101
url = self.options.get('url', 'local')
102+
bool_set_ = (True, 1, "True", "1", "true", '')
103+
process = 'process' in self.options and self.options['process'] in bool_set_
99104
if url == 'local':
100105
try:
101106
import jyquickhelper
@@ -139,7 +144,7 @@ def run(self):
139144
# executes script if any
140145
content = "\n".join(self.content)
141146
if script or script == '':
142-
stdout, stderr, _ = run_python_script(content)
147+
stdout, stderr, _ = run_python_script(content, process=process)
143148
if stderr:
144149
raise RuntimeError(
145150
"A graph cannot be draw due to {}".format(stderr))

0 commit comments

Comments
 (0)