Show More
@@ -42,15 +42,15 b' ipython_promptout:' | |||||
42 | in the prompt. |
|
42 | in the prompt. | |
43 | ipython_mplbackend: |
|
43 | ipython_mplbackend: | |
44 | The string which specifies if the embedded Sphinx shell should import |
|
44 | The string which specifies if the embedded Sphinx shell should import | |
45 | Matplotlib and set the backend for each code-block. If `None`, or equal |
|
45 | Matplotlib and set the backend. The value specifies a backend that is | |
46 | to '' or 'None', then `matplotlib` will not be automatically imported. If |
|
46 | passed to `matplotlib.use()`. If specified in conf.py as `None` or not | |
47 | not `None`, then the value should specify a backend that is passed to |
|
47 | specified in conf.py at all, then the default value of 'agg' is used. | |
48 | `matplotlib.use()`. The default value is 'agg'. |
|
|||
49 | ipython_execlines: |
|
48 | ipython_execlines: | |
50 |
A list of strings to be exec'd for e |
|
49 | A list of strings to be exec'd for the embedded Sphinx shell. Typical | |
51 |
usage is to make certain packages always available. |
|
50 | usage is to make certain packages always available. Set this to an empty | |
52 | `['import numpy as np', 'from pylab import *']` is used. Set this to an |
|
51 | list if you wish to have no imports always available. If specified in | |
53 | empty list if you wish to have no imports always available. |
|
52 | conf.py as `None` or not specified in conf.py at all, then the default | |
|
53 | value of ['import numpy as np', 'from pylab import *'] is used. | |||
54 |
|
54 | |||
55 | As an example, to use the IPython directive when `matplotlib` is not available, |
|
55 | As an example, to use the IPython directive when `matplotlib` is not available, | |
56 | one sets the backend to `None`:: |
|
56 | one sets the backend to `None`:: | |
@@ -256,7 +256,7 b' class EmbeddedSphinxShell(object):' | |||||
256 | self.cout = StringIO() |
|
256 | self.cout = StringIO() | |
257 |
|
257 | |||
258 | if exec_lines is None: |
|
258 | if exec_lines is None: | |
259 | exec_lines = ['import numpy as np', 'from pylab import *'] |
|
259 | exec_lines = [] | |
260 |
|
260 | |||
261 | # Create config object for IPython |
|
261 | # Create config object for IPython | |
262 | config = Config() |
|
262 | config = Config() | |
@@ -679,6 +679,14 b' class IPythonDirective(Directive):' | |||||
679 | mplbackend = config.ipython_mplbackend |
|
679 | mplbackend = config.ipython_mplbackend | |
680 | exec_lines = config.ipython_execlines |
|
680 | exec_lines = config.ipython_execlines | |
681 |
|
681 | |||
|
682 | # Handle None uniformly, whether specified in conf.py as `None` or | |||
|
683 | # omitted entirely from conf.py. | |||
|
684 | ||||
|
685 | if mplbackend is None: | |||
|
686 | mplbackend = 'agg' | |||
|
687 | if exec_lines is None: | |||
|
688 | exec_lines = ['import numpy as np', 'from pylab import *'] | |||
|
689 | ||||
682 | return (savefig_dir, source_dir, rgxin, rgxout, |
|
690 | return (savefig_dir, source_dir, rgxin, rgxout, | |
683 | promptin, promptout, mplbackend, exec_lines) |
|
691 | promptin, promptout, mplbackend, exec_lines) | |
684 |
|
692 | |||
@@ -689,7 +697,7 b' class IPythonDirective(Directive):' | |||||
689 |
|
697 | |||
690 | if self.shell is None: |
|
698 | if self.shell is None: | |
691 |
|
699 | |||
692 | if mplbackend: |
|
700 | if mplbackend and mplbackend is not 'none': | |
693 | import matplotlib |
|
701 | import matplotlib | |
694 | # Repeated calls to use() will not hurt us since `mplbackend` |
|
702 | # Repeated calls to use() will not hurt us since `mplbackend` | |
695 | # is the same each time. |
|
703 | # is the same each time. | |
@@ -791,7 +799,7 b' def setup(app):' | |||||
791 | re.compile('Out\[(\d+)\]:\s?(.*)\s*'), 'env') |
|
799 | re.compile('Out\[(\d+)\]:\s?(.*)\s*'), 'env') | |
792 | app.add_config_value('ipython_promptin', 'In [%d]:', 'env') |
|
800 | app.add_config_value('ipython_promptin', 'In [%d]:', 'env') | |
793 | app.add_config_value('ipython_promptout', 'Out[%d]:', 'env') |
|
801 | app.add_config_value('ipython_promptout', 'Out[%d]:', 'env') | |
794 |
app.add_config_value('ipython_mplbackend', |
|
802 | app.add_config_value('ipython_mplbackend', None, 'env') | |
795 | app.add_config_value('ipython_execlines', None, 'env') |
|
803 | app.add_config_value('ipython_execlines', None, 'env') | |
796 |
|
804 | |||
797 | # Simple smoke test, needs to be converted to a proper automatic test. |
|
805 | # Simple smoke test, needs to be converted to a proper automatic test. |
General Comments 0
You need to be logged in to leave comments.
Login now