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