##// END OF EJS Templates
Merge pull request #3298 from abakan/master...
Min RK -
r10952:51078a2f merge
parent child Browse files
Show More
@@ -496,6 +496,12 class EmbeddedSphinxShell(object):
496 496 else: # still on a multiline
497 497 modified = u'%s %s' % (continuation, line)
498 498 output.append(modified)
499
500 # if the next line is indented, it should be part of multiline
501 if len(content) > lineno + 1:
502 nextline = content[lineno + 1]
503 if len(nextline) - len(nextline.lstrip()) > 3:
504 continue
499 505 try:
500 506 mod = ast.parse(
501 507 '\n'.join(content[multiline_start:lineno+1]))
@@ -532,6 +538,8 class IpythonDirective(Directive):
532 538
533 539 shell = EmbeddedSphinxShell()
534 540
541 seen_docs = set()
542
535 543 def get_config_options(self):
536 544 # contains sphinx configuration variables
537 545 config = self.state.document.settings.env.config
@@ -558,16 +566,13 class IpythonDirective(Directive):
558 566 # reset the execution count if we haven't processed this doc
559 567 #NOTE: this may be borked if there are multiple seen_doc tmp files
560 568 #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:
569
570
571 if not self.state.document.current_source in self.seen_docs:
567 572 self.shell.IP.history_manager.reset()
568 573 self.shell.IP.execution_count = 1
569 else: # haven't processed any docs yet
570 docs = []
574 self.seen_docs.add(self.state.document.current_source)
575
571 576
572 577
573 578 # get config values
@@ -588,13 +593,6 class IpythonDirective(Directive):
588 593 store_history=False)
589 594 self.shell.clear_cout()
590 595
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 596 return rgxin, rgxout, promptin, promptout
599 597
600 598
General Comments 0
You need to be logged in to leave comments. Login now