Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions _unittests/ut_loghelper/test_pypi_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
"this file should not be imported in that location: " +
os.path.abspath(__file__))

from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import enumerate_pypi_versions_date
from pyquickhelper.pycode import ExtTestCase, skipif_circleci, skipif_appveyor
from pyquickhelper.loghelper import fLOG, enumerate_pypi_versions_date


class TestPypiHelper(unittest.TestCase):

@skipif_circleci("connectivity issue")
@skipif_appveyor("connectivity issue")
def test_clone_repo(self):
fLOG(
__file__,
Expand Down
19 changes: 19 additions & 0 deletions _unittests/ut_sphinxext/test_gdot_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ def test_gdot3_svg(self):
self.assertIn("document.getElementById('gdot-", content)
self.assertIn('foo {\\n \\"bar\\" -> \\"baz\\";\\n}");', content)

def test_gdot3_svg_process(self):
content = """
before

.. gdot::
:format: svg
:process:

digraph foo {
"bar" -> "baz";
}

after
""".replace(" ", "")

content = rst2html(content, writer="html", keep_warnings=True)
self.assertIn("document.getElementById('gdot-", content)
self.assertIn('foo {\\n \\"bar\\" -> \\"baz\\";\\n}");', content)

def test_gdot4_png(self):
content = """
before
Expand Down
9 changes: 7 additions & 2 deletions src/pyquickhelper/sphinxext/sphinx_gdot_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class GDotDirective(Directive):
* *script*: boolean or a string to indicate than the standard output
should only be considered after this substring
* *url*: url to :epkg:`viz.js`, only if format *SVG* is selected
* *process*: run the script in an another process

Example::

Expand All @@ -54,7 +55,8 @@ class GDotDirective(Directive):
The directive also accepts scripts producing
dot graphs on the standard output. Option *script*
must be specified. This extension loads
`sphinx.ext.graphviz <https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html>`_
`sphinx.ext.graphviz <https://www.sphinx-doc.org/
en/master/usage/extensions/graphviz.html>`_
if not added to the list of extensions:

Example::
Expand Down Expand Up @@ -82,6 +84,7 @@ class GDotDirective(Directive):
'format': directives.unchanged,
'script': directives.unchanged,
'url': directives.unchanged,
'process': directives.unchanged,
}

_default_url = "http://www.xavierdupre.fr/js/vizjs/viz.js"
Expand All @@ -96,6 +99,8 @@ def run(self):
else:
format = '?'
url = self.options.get('url', 'local')
bool_set_ = (True, 1, "True", "1", "true", '')
process = 'process' in self.options and self.options['process'] in bool_set_
if url == 'local':
try:
import jyquickhelper
Expand Down Expand Up @@ -139,7 +144,7 @@ def run(self):
# executes script if any
content = "\n".join(self.content)
if script or script == '':
stdout, stderr, _ = run_python_script(content)
stdout, stderr, _ = run_python_script(content, process=process)
if stderr:
raise RuntimeError(
"A graph cannot be draw due to {}".format(stderr))
Expand Down