Show More
@@ -77,7 +77,7 from docutils.parsers.rst import directives | |||
|
77 | 77 | from docutils import nodes |
|
78 | 78 | from sphinx.util.compat import Directive |
|
79 | 79 | |
|
80 | matplotlib.use('Agg') | |
|
80 | #matplotlib.use('Agg') | |
|
81 | 81 | |
|
82 | 82 | # Our own |
|
83 | 83 | from IPython import Config, InteractiveShell |
@@ -532,6 +532,8 class IpythonDirective(Directive): | |||
|
532 | 532 | |
|
533 | 533 | shell = EmbeddedSphinxShell() |
|
534 | 534 | |
|
535 | seen_docs = set() | |
|
536 | ||
|
535 | 537 | def get_config_options(self): |
|
536 | 538 | # contains sphinx configuration variables |
|
537 | 539 | config = self.state.document.settings.env.config |
@@ -558,16 +560,13 class IpythonDirective(Directive): | |||
|
558 | 560 | # reset the execution count if we haven't processed this doc |
|
559 | 561 | #NOTE: this may be borked if there are multiple seen_doc tmp files |
|
560 | 562 | #check time stamp? |
|
561 | seen_docs = [i for i in os.listdir(tempfile.tempdir) | |
|
562 | if i.startswith('seen_doc')] | |
|
563 | if seen_docs: | |
|
564 | fname = os.path.join(tempfile.tempdir, seen_docs[0]) | |
|
565 | docs = open(fname).read().split('\n') | |
|
566 | if not self.state.document.current_source in docs: | |
|
563 | ||
|
564 | ||
|
565 | if not self.state.document.current_source in self.seen_docs: | |
|
567 | 566 | self.shell.IP.history_manager.reset() |
|
568 | 567 | self.shell.IP.execution_count = 1 |
|
569 | else: # haven't processed any docs yet | |
|
570 | docs = [] | |
|
568 | self.seen_docs.add(self.state.document.current_source) | |
|
569 | ||
|
571 | 570 | |
|
572 | 571 | |
|
573 | 572 | # get config values |
@@ -588,13 +587,6 class IpythonDirective(Directive): | |||
|
588 | 587 | store_history=False) |
|
589 | 588 | self.shell.clear_cout() |
|
590 | 589 | |
|
591 | # write the filename to a tempfile because it's been "seen" now | |
|
592 | if not self.state.document.current_source in docs: | |
|
593 | fd, fname = tempfile.mkstemp(prefix="seen_doc", text=True) | |
|
594 | fout = open(fname, 'a') | |
|
595 | fout.write(self.state.document.current_source+'\n') | |
|
596 | fout.close() | |
|
597 | ||
|
598 | 590 | return rgxin, rgxout, promptin, promptout |
|
599 | 591 | |
|
600 | 592 |
General Comments 0
You need to be logged in to leave comments.
Login now