Skip to content
Permalink
Browse files

fixes #171, modify the script to run in runpython sphinx directive

  • Loading branch information...
sdpython committed Aug 18, 2018
1 parent f068065 commit 09f98708e023a622a91f4ec808835ae726009107
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/pyquickhelper/sphinxext/sphinx_runpython_extension.py
@@ -385,7 +385,7 @@ def run(self):
else:
content = ["def {0}():".format(name)]
content.append(' ## __WD__ ##')

for line in self.content:
content.append(" " + line)
if not p['process']:
@@ -426,6 +426,7 @@ def run(self):
cs_source = docname

# Add __WD__.
script = self.modify_script_before_running(script)
script = script.replace('## __WD__ ##', "__WD__ = '{0}'".format(
os.path.dirname(cs_source)).replace("\\", "/"))

@@ -568,6 +569,16 @@ def add_indent(content, nbind):
ns = [node]
return ns

def modify_script_before_running(self, script):
"""
Takes the script as a string
and returns another string before it is run.
It does not modify what is displayed.
The function can be overwritten by any class
based on this one.
"""
return script


def visit_runpython_node(self, node):
"""

0 comments on commit 09f9870

Please sign in to comment.
You can’t perform that action at this time.