##// END OF EJS Templates
Remove explicit passing state arg in favor of self.directive.state
y-p -
Show More
@@ -246,15 +246,13 b' def block_parser(part, rgxin, rgxout, fmtin, fmtout):'
246 246 class EmbeddedSphinxShell(object):
247 247 """An embedded IPython instance to run inside Sphinx"""
248 248
249 def __init__(self, exec_lines=None, state=None):
249 def __init__(self, exec_lines=None):
250 250
251 251 self.cout = StringIO()
252 252
253 253 if exec_lines is None:
254 254 exec_lines = []
255 255
256 self.state = state
257
258 256 # Create config object for IPython
259 257 config = Config()
260 258 config.InteractiveShell.autocall = False
@@ -293,6 +291,10 b' class EmbeddedSphinxShell(object):'
293 291 self.is_suppress = False
294 292
295 293 # Optionally, provide more detailed information to shell.
294 # this is assigned by the SetUp method of IPythonDirective
295 # to point at itself.
296 #
297 # So, you can access handy things at self.directive.state
296 298 self.directive = None
297 299
298 300 # on the first call to the savefig decorator, we'll import
@@ -431,9 +433,9 b' class EmbeddedSphinxShell(object):'
431 433 # context information
432 434 filename = "Unknown"
433 435 lineno = 0
434 if self.state:
435 filename = self.state.document.current_source
436 lineno = self.state.document.current_line
436 if self.directive.state:
437 filename = self.directive.state.document.current_source
438 lineno = self.directive.state.document.current_line
437 439
438 440 # output any exceptions raised during execution to stdout
439 441 # unless :okexcept: has been specified.
@@ -752,7 +754,7 b' class IPythonDirective(Directive):'
752 754
753 755 # Must be called after (potentially) importing matplotlib and
754 756 # setting its backend since exec_lines might import pylab.
755 self.shell = EmbeddedSphinxShell(exec_lines, self.state)
757 self.shell = EmbeddedSphinxShell(exec_lines)
756 758
757 759 # Store IPython directive to enable better error messages
758 760 self.shell.directive = self
General Comments 0
You need to be logged in to leave comments. Login now