Skip to content

Commit 8d834fd

Browse files
DOC: update ipython_directive with changes from ipython to restart prompt number at 1 each page
1 parent 998e636 commit 8d834fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/sphinxext/ipython_directive.py

+8
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ class IpythonDirective(Directive):
621621

622622
shell = EmbeddedSphinxShell()
623623

624+
seen_docs = set()
625+
624626
def get_config_options(self):
625627
# contains sphinx configuration variables
626628
config = self.state.document.settings.env.config
@@ -644,6 +646,12 @@ def get_config_options(self):
644646
return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout
645647

646648
def setup(self):
649+
650+
if not self.state.document.current_source in self.seen_docs:
651+
self.shell.IP.history_manager.reset()
652+
self.shell.IP.execution_count = 1
653+
self.seen_docs.add(self.state.document.current_source)
654+
647655
# get config values
648656
(savefig_dir, source_dir, rgxin,
649657
rgxout, promptin, promptout) = self.get_config_options()

0 commit comments

Comments
 (0)