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