| 1044 | |
| 1045 | # Enable as a proper Sphinx directive |
| 1046 | def setup(app): |
| 1047 | setup.app = app |
| 1048 | |
| 1049 | app.add_directive('ipython', IPythonDirective) |
| 1050 | app.add_config_value('ipython_savefig_dir', 'savefig', 'env') |
| 1051 | app.add_config_value('ipython_warning_is_error', True, 'env') |
| 1052 | app.add_config_value('ipython_rgxin', |
| 1053 | re.compile(r'In \[(\d+)\]:\s?(.*)\s*'), 'env') |
| 1054 | app.add_config_value('ipython_rgxout', |
| 1055 | re.compile(r'Out\[(\d+)\]:\s?(.*)\s*'), 'env') |
| 1056 | app.add_config_value('ipython_promptin', 'In [%d]:', 'env') |
| 1057 | app.add_config_value('ipython_promptout', 'Out[%d]:', 'env') |
| 1058 | |
| 1059 | # We could just let matplotlib pick whatever is specified as the default |
| 1060 | # backend in the matplotlibrc file, but this would cause issues if the |
| 1061 | # backend didn't work in headless environments. For this reason, 'agg' |
| 1062 | # is a good default backend choice. |
| 1063 | app.add_config_value('ipython_mplbackend', 'agg', 'env') |
| 1064 | |
| 1065 | # If the user sets this config value to `None`, then EmbeddedSphinxShell's |
| 1066 | # __init__ method will treat it as []. |
| 1067 | execlines = ['import numpy as np'] |
| 1068 | if use_matplotlib: |
| 1069 | execlines.append('import matplotlib.pyplot as plt') |
| 1070 | app.add_config_value('ipython_execlines', execlines, 'env') |
| 1071 | |
| 1072 | app.add_config_value('ipython_holdcount', True, 'env') |
| 1073 | |
| 1074 | metadata = {'parallel_read_safe': True, 'parallel_write_safe': True} |
| 1075 | return metadata |
| 1076 | |
| 1077 | # Simple smoke test, needs to be converted to a proper automatic test. |
| 1078 | def test(): |