Show More
@@ -126,6 +126,7 b' Authors' | |||
|
126 | 126 | |
|
127 | 127 | # Stdlib |
|
128 | 128 | import atexit |
|
129 | import errno | |
|
129 | 130 | import os |
|
130 | 131 | import re |
|
131 | 132 | import sys |
@@ -358,9 +359,9 b' class EmbeddedSphinxShell(object):' | |||
|
358 | 359 | source_dir = self.source_dir |
|
359 | 360 | saveargs = decorator.split(' ') |
|
360 | 361 | filename = saveargs[1] |
|
361 | # insert relative path to image file in source | |
|
362 | outfile = os.path.relpath(os.path.join(savefig_dir,filename), | |
|
363 | source_dir) | |
|
362 | # insert relative path to image file in source (as absolute path for Sphinx) | |
|
363 | outfile = '/' + os.path.relpath(os.path.join(savefig_dir,filename), | |
|
364 | source_dir) | |
|
364 | 365 | |
|
365 | 366 | imagerows = ['.. image:: %s'%outfile] |
|
366 | 367 | |
@@ -842,14 +843,9 b' class IPythonDirective(Directive):' | |||
|
842 | 843 | config = self.state.document.settings.env.config |
|
843 | 844 | |
|
844 | 845 | # get config variables to set figure output directory |
|
845 | outdir = self.state.document.settings.env.app.outdir | |
|
846 | 846 | savefig_dir = config.ipython_savefig_dir |
|
847 |
source_dir = |
|
|
848 | if savefig_dir is None: | |
|
849 | savefig_dir = config.html_static_path or '_static' | |
|
850 | if isinstance(savefig_dir, list): | |
|
851 | savefig_dir = os.path.join(*savefig_dir) | |
|
852 | savefig_dir = os.path.join(outdir, savefig_dir) | |
|
847 | source_dir = self.state.document.settings.env.srcdir | |
|
848 | savefig_dir = os.path.join(source_dir, savefig_dir) | |
|
853 | 849 | |
|
854 | 850 | # get regex and prompt stuff |
|
855 | 851 | rgxin = config.ipython_rgxin |
@@ -868,6 +864,12 b' class IPythonDirective(Directive):' | |||
|
868 | 864 | (savefig_dir, source_dir, rgxin, rgxout, promptin, promptout, |
|
869 | 865 | mplbackend, exec_lines, hold_count) = self.get_config_options() |
|
870 | 866 | |
|
867 | try: | |
|
868 | os.makedirs(savefig_dir) | |
|
869 | except OSError as e: | |
|
870 | if e.errno != errno.EEXIST: | |
|
871 | raise | |
|
872 | ||
|
871 | 873 | if self.shell is None: |
|
872 | 874 | # We will be here many times. However, when the |
|
873 | 875 | # EmbeddedSphinxShell is created, its interactive shell member |
@@ -976,7 +978,7 b' def setup(app):' | |||
|
976 | 978 | setup.app = app |
|
977 | 979 | |
|
978 | 980 | app.add_directive('ipython', IPythonDirective) |
|
979 |
app.add_config_value('ipython_savefig_dir', |
|
|
981 | app.add_config_value('ipython_savefig_dir', 'savefig', 'env') | |
|
980 | 982 | app.add_config_value('ipython_rgxin', |
|
981 | 983 | re.compile('In \[(\d+)\]:\s?(.*)\s*'), 'env') |
|
982 | 984 | app.add_config_value('ipython_rgxout', |
General Comments 0
You need to be logged in to leave comments.
Login now