##// END OF EJS Templates
don't instantiate IPython shell as class attr...
MinRK -
Show More
@@ -524,7 +524,7 b' class EmbeddedSphinxShell(object):'
524
524
525 return output
525 return output
526
526
527 class IpythonDirective(Directive):
527 class IPythonDirective(Directive):
528
528
529 has_content = True
529 has_content = True
530 required_arguments = 0
530 required_arguments = 0
@@ -536,7 +536,7 b' class IpythonDirective(Directive):'
536 'doctest' : directives.flag,
536 'doctest' : directives.flag,
537 }
537 }
538
538
539 shell = EmbeddedSphinxShell()
539 shell = None
540
540
541 seen_docs = set()
541 seen_docs = set()
542
542
@@ -563,11 +563,12 b' class IpythonDirective(Directive):'
563 return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout
563 return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout
564
564
565 def setup(self):
565 def setup(self):
566 if self.shell is None:
567 self.shell = EmbeddedSphinxShell()
566 # reset the execution count if we haven't processed this doc
568 # reset the execution count if we haven't processed this doc
567 #NOTE: this may be borked if there are multiple seen_doc tmp files
569 #NOTE: this may be borked if there are multiple seen_doc tmp files
568 #check time stamp?
570 #check time stamp?
569
571
570
571 if not self.state.document.current_source in self.seen_docs:
572 if not self.state.document.current_source in self.seen_docs:
572 self.shell.IP.history_manager.reset()
573 self.shell.IP.history_manager.reset()
573 self.shell.IP.execution_count = 1
574 self.shell.IP.execution_count = 1
@@ -668,7 +669,7 b' class IpythonDirective(Directive):'
668 def setup(app):
669 def setup(app):
669 setup.app = app
670 setup.app = app
670
671
671 app.add_directive('ipython', IpythonDirective)
672 app.add_directive('ipython', IPythonDirective)
672 app.add_config_value('ipython_savefig_dir', None, True)
673 app.add_config_value('ipython_savefig_dir', None, True)
673 app.add_config_value('ipython_rgxin',
674 app.add_config_value('ipython_rgxin',
674 re.compile('In \[(\d+)\]:\s?(.*)\s*'), True)
675 re.compile('In \[(\d+)\]:\s?(.*)\s*'), True)
@@ -814,7 +815,7 b' In [153]: grid(True)'
814 options = dict()
815 options = dict()
815 for example in examples:
816 for example in examples:
816 content = example.split('\n')
817 content = example.split('\n')
817 ipython_directive('debug', arguments=None, options=options,
818 IPythonDirective('debug', arguments=None, options=options,
818 content=content, lineno=0,
819 content=content, lineno=0,
819 content_offset=None, block_text=None,
820 content_offset=None, block_text=None,
820 state=None, state_machine=None,
821 state=None, state_machine=None,
General Comments 0
You need to be logged in to leave comments. Login now