Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't instantiate IPython shell as class attr #4413

Merged
merged 1 commit into from
Oct 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions IPython/sphinxext/ipython_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def process_pure_python(self, content):

return output

class IpythonDirective(Directive):
class IPythonDirective(Directive):

has_content = True
required_arguments = 0
Expand All @@ -536,7 +536,7 @@ class IpythonDirective(Directive):
'doctest' : directives.flag,
}

shell = EmbeddedSphinxShell()
shell = None

seen_docs = set()

Expand All @@ -563,11 +563,12 @@ def get_config_options(self):
return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout

def setup(self):
if self.shell is None:
self.shell = EmbeddedSphinxShell()
# reset the execution count if we haven't processed this doc
#NOTE: this may be borked if there are multiple seen_doc tmp files
#check time stamp?


if not self.state.document.current_source in self.seen_docs:
self.shell.IP.history_manager.reset()
self.shell.IP.execution_count = 1
Expand Down Expand Up @@ -668,7 +669,7 @@ def run(self):
def setup(app):
setup.app = app

app.add_directive('ipython', IpythonDirective)
app.add_directive('ipython', IPythonDirective)
app.add_config_value('ipython_savefig_dir', None, True)
app.add_config_value('ipython_rgxin',
re.compile('In \[(\d+)\]:\s?(.*)\s*'), True)
Expand Down Expand Up @@ -814,7 +815,7 @@ def test():
options = dict()
for example in examples:
content = example.split('\n')
ipython_directive('debug', arguments=None, options=options,
IPythonDirective('debug', arguments=None, options=options,
content=content, lineno=0,
content_offset=None, block_text=None,
state=None, state_machine=None,
Expand Down