Show More
@@ -239,8 +239,6 b' class EmbeddedSphinxShell(object):' | |||
|
239 | 239 | |
|
240 | 240 | # Create config object for IPython |
|
241 | 241 | config = Config() |
|
242 | config.Global.display_banner = False | |
|
243 | config.Global.exec_lines = exec_lines | |
|
244 | 242 | config.InteractiveShell.autocall = False |
|
245 | 243 | config.InteractiveShell.autoindent = False |
|
246 | 244 | config.InteractiveShell.colors = 'NoColor' |
@@ -251,8 +249,10 b' class EmbeddedSphinxShell(object):' | |||
|
251 | 249 | pdir = os.path.join(tmp_profile_dir,profname) |
|
252 | 250 | profile = ProfileDir.create_profile_dir(pdir) |
|
253 | 251 | |
|
254 | # Create and initialize ipython, but don't start its mainloop | |
|
252 | # Create and initialize global ipython, but don't start its mainloop. | |
|
253 | # This will persist across different EmbededSphinxShell instances. | |
|
255 | 254 | IP = InteractiveShell.instance(config=config, profile_dir=profile) |
|
255 | ||
|
256 | 256 | # io.stdout redirect must be done *after* instantiating InteractiveShell |
|
257 | 257 | io.stdout = self.cout |
|
258 | 258 | io.stderr = self.cout |
@@ -278,6 +278,10 b' class EmbeddedSphinxShell(object):' | |||
|
278 | 278 | # pyplot as plt so we can make a call to the plt.gcf().savefig |
|
279 | 279 | self._pyplot_imported = False |
|
280 | 280 | |
|
281 | # Prepopulate the namespace. | |
|
282 | for line in exec_lines: | |
|
283 | self.process_input_line(line, store_history=False) | |
|
284 | ||
|
281 | 285 | def clear_cout(self): |
|
282 | 286 | self.cout.seek(0) |
|
283 | 287 | self.cout.truncate(0) |
@@ -611,12 +615,17 b' class IPythonDirective(Directive):' | |||
|
611 | 615 | promptout, mplbackend, exec_lines) = self.get_config_options() |
|
612 | 616 | |
|
613 | 617 | if self.shell is None: |
|
614 | self.shell = EmbeddedSphinxShell(exec_lines) | |
|
618 | ||
|
615 | 619 | if mplbackend: |
|
616 | # Each ipython code-block is run in a separate process. | |
|
617 | 620 | import matplotlib |
|
621 | # Repeated calls to use() will not hurt us since `mplbackend` | |
|
622 | # is the same each time. | |
|
618 | 623 | matplotlib.use(mplbackend) |
|
619 | 624 | |
|
625 | # Must be called after (potentially) importing matplotlib and | |
|
626 | # setting its backend since exec_lines might import pylab. | |
|
627 | self.shell = EmbeddedSphinxShell(exec_lines) | |
|
628 | ||
|
620 | 629 | # reset the execution count if we haven't processed this doc |
|
621 | 630 | #NOTE: this may be borked if there are multiple seen_doc tmp files |
|
622 | 631 | #check time stamp? |
General Comments 0
You need to be logged in to leave comments.
Login now