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