##// END OF EJS Templates
Keep track of seen documents to reset line counts across pages
Skipper Seabold -
Show More
@@ -560,6 +560,21 b' class IpythonDirective(Directive):'
560 560 return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout
561 561
562 562 def setup(self):
563 # reset the execution count if we haven't processed this doc
564 #NOTE: this may be borked if there are multiple seen_doc tmp files
565 #check time stamp?
566 seen_docs = [i for i in os.listdir(tempfile.tempdir)
567 if i.startswith('seen_doc')]
568 if seen_docs:
569 fname = os.path.join(tempfile.tempdir, seen_docs[0])
570 docs = open(fname).read().split('\n')
571 if not self.state.document.current_source in docs:
572 self.shell.IP.history_manager.reset()
573 self.shell.IP.execution_count = 1
574 else: # haven't processed any docs yet
575 docs = []
576
577
563 578 # get config values
564 579 (savefig_dir, source_dir, rgxin,
565 580 rgxout, promptin, promptout) = self.get_config_options()
@@ -578,6 +593,13 b' class IpythonDirective(Directive):'
578 593 store_history=False)
579 594 self.shell.clear_cout()
580 595
596 # write the filename to a tempfile because it's been "seen" now
597 if not self.state.document.current_source in docs:
598 fd, fname = tempfile.mkstemp(prefix="seen_doc", text=True)
599 fout = open(fname, 'a')
600 fout.write(self.state.document.current_source+'\n')
601 fout.close()
602
581 603 return rgxin, rgxout, promptin, promptout
582 604
583 605
General Comments 0
You need to be logged in to leave comments. Login now