Show More
@@ -496,6 +496,12 class EmbeddedSphinxShell(object): | |||||
496 | else: # still on a multiline |
|
496 | else: # still on a multiline | |
497 | modified = u'%s %s' % (continuation, line) |
|
497 | modified = u'%s %s' % (continuation, line) | |
498 | output.append(modified) |
|
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 | try: |
|
505 | try: | |
500 | mod = ast.parse( |
|
506 | mod = ast.parse( | |
501 | '\n'.join(content[multiline_start:lineno+1])) |
|
507 | '\n'.join(content[multiline_start:lineno+1])) | |
@@ -532,6 +538,8 class IpythonDirective(Directive): | |||||
532 |
|
538 | |||
533 | shell = EmbeddedSphinxShell() |
|
539 | shell = EmbeddedSphinxShell() | |
534 |
|
540 | |||
|
541 | seen_docs = set() | |||
|
542 | ||||
535 | def get_config_options(self): |
|
543 | def get_config_options(self): | |
536 | # contains sphinx configuration variables |
|
544 | # contains sphinx configuration variables | |
537 | config = self.state.document.settings.env.config |
|
545 | config = self.state.document.settings.env.config | |
@@ -558,16 +566,13 class IpythonDirective(Directive): | |||||
558 | # reset the execution count if we haven't processed this doc |
|
566 | # 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 |
|
567 | #NOTE: this may be borked if there are multiple seen_doc tmp files | |
560 | #check time stamp? |
|
568 | #check time stamp? | |
561 | seen_docs = [i for i in os.listdir(tempfile.tempdir) |
|
569 | ||
562 | if i.startswith('seen_doc')] |
|
570 | ||
563 | if seen_docs: |
|
571 | 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() |
|
572 | self.shell.IP.history_manager.reset() | |
568 | self.shell.IP.execution_count = 1 |
|
573 | self.shell.IP.execution_count = 1 | |
569 | else: # haven't processed any docs yet |
|
574 | self.seen_docs.add(self.state.document.current_source) | |
570 | docs = [] |
|
575 | ||
571 |
|
576 | |||
572 |
|
577 | |||
573 | # get config values |
|
578 | # get config values | |
@@ -588,13 +593,6 class IpythonDirective(Directive): | |||||
588 | store_history=False) |
|
593 | store_history=False) | |
589 | self.shell.clear_cout() |
|
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 | return rgxin, rgxout, promptin, promptout |
|
596 | return rgxin, rgxout, promptin, promptout | |
599 |
|
597 | |||
600 |
|
598 |
General Comments 0
You need to be logged in to leave comments.
Login now