Skip to content

Commit 2de26da

Browse files
committed
Clarify ipython_kernel_config.py usage, require traitlets>=5
1 parent 8f6343a commit 2de26da

File tree

5 files changed

+28
-45
lines changed

5 files changed

+28
-45
lines changed

doc/code-cells.ipynb

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,22 @@
310310
"source": [
311311
"### Plots\n",
312312
"\n",
313-
"The output formats for Matplotlib plots can be customized.\n",
314-
"You'll need separate settings for the Jupyter Notebook application and for `nbsphinx`.\n",
313+
"The output formats for Matplotlib plots can be customized\n",
314+
"via the IPython configuration file `ipython_kernel_config.py`.\n",
315+
"This file can be either\n",
316+
"in the directory where your notebook is located\n",
317+
"(see the [ipython_kernel_config.py](ipython_kernel_config.py) in this directory),\n",
318+
"or in your profile directory\n",
319+
"(typically `~/.ipython/profile_default/ipython_kernel_config.py`).\n",
320+
"To find out your IPython profile directory, use this command:\n",
321+
"\n",
322+
" python3 -m IPython profile locate\n",
323+
"\n",
324+
"A local `ipython_kernel_config.py` in the notebook directory\n",
325+
"also works on https://mybinder.org/.\n",
326+
"Alternatively, you can create a file with those settings in a file named\n",
327+
"`.ipython/profile_default/ipython_kernel_config.py` in your repository.\n",
328+
"\n",
315329
"\n",
316330
"If you want to use SVG images for Matplotlib plots,\n",
317331
"add this line to your IPython configuration file:\n",
@@ -342,22 +356,10 @@
342356
"For more details on these and other settings, have a look at\n",
343357
"[Default Values for Matplotlib's \"inline\" Backend](https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb).\n",
344358
"\n",
345-
"The configuration file `ipython_kernel_config.py` can be either\n",
346-
"in the directory where your notebook is located\n",
347-
"(see the [ipython_kernel_config.py](ipython_kernel_config.py) in this directory),\n",
348-
"or in your profile directory\n",
349-
"(typically `~/.ipython/profile_default/ipython_kernel_config.py`).\n",
350-
"To find out your IPython profile directory, use this command:\n",
351-
"\n",
352-
" python3 -m IPython profile locate\n",
353-
"\n",
354-
"A local `ipython_kernel_config.py` in the notebook directory\n",
355-
"also works on https://mybinder.org/.\n",
356-
"Alternatively, you can create a file with those settings in a file named\n",
357-
"`.ipython/profile_default/ipython_kernel_config.py` in your repository.\n",
358-
"\n",
359-
"To get SVG and PDF plots for `nbsphinx`,\n",
360-
"use something like this in your `conf.py` file:\n",
359+
"If you for some reason can't use a `ipython_kernel_config.py` file,\n",
360+
"you can also change these settings with\n",
361+
"[nbsphinx_execute_arguments](usage.ipynb#nbsphinx_execute_arguments)\n",
362+
"in your `conf.py` file:\n",
361363
"\n",
362364
"```python\n",
363365
"nbsphinx_execute_arguments = [\n",
@@ -679,6 +681,8 @@
679681
]
680682
},
681683
{
684+
"cell_type": "markdown",
685+
"metadata": {},
682686
"source": [
683687
"#### Troubleshooting\n",
684688
"\n",
@@ -708,9 +712,7 @@
708712
"\n",
709713
"- If the widgets are **not displayed**, see [#519](https://github.com/spatialaudio/nbsphinx/issues/519).\n",
710714
"- If the widgets are **displayed multiple times**, see [#378](https://github.com/spatialaudio/nbsphinx/issues/378)."
711-
],
712-
"cell_type": "markdown",
713-
"metadata": {}
715+
]
714716
},
715717
{
716718
"cell_type": "markdown",
@@ -868,7 +870,7 @@
868870
"name": "python",
869871
"nbconvert_exporter": "python",
870872
"pygments_lexer": "ipython3",
871-
"version": "3.7.5"
873+
"version": "3.9.9"
872874
}
873875
},
874876
"nbformat": 4,

doc/conf.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
# Use sphinx-quickstart to create your own conf.py file!
3+
# You can use sphinx-quickstart to create your own conf.py file!
44
# After that, you have to edit a few things. See below.
55

66
# Select nbsphinx and, if needed, other Sphinx extensions:
@@ -26,12 +26,6 @@
2626
# Don't add .txt suffix to source files:
2727
html_sourcelink_suffix = ''
2828

29-
# List of arguments to be passed to the kernel that executes the notebooks:
30-
nbsphinx_execute_arguments = [
31-
"--InlineBackend.figure_formats={'svg', 'pdf'}",
32-
"--InlineBackend.rc=figure.dpi=96",
33-
]
34-
3529
# Environment variables to be passed to the kernel:
3630
os.environ['MY_DUMMY_VARIABLE'] = 'Hello from conf.py!'
3731

doc/ipython_kernel_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
c.InlineBackend.figure_formats = {'svg'}
1+
c.InlineBackend.figure_formats = {'svg', 'pdf'}
22
c.InlineBackend.rc = {'figure.dpi': 96}

doc/usage.ipynb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,6 @@
297297
"\n",
298298
"Kernel arguments used when executing notebooks.\n",
299299
"\n",
300-
"If you [use Matplotlib for plots](code-cells.ipynb#Plots),\n",
301-
"this setting is recommended:\n",
302-
"\n",
303-
"```python\n",
304-
"nbsphinx_execute_arguments = [\n",
305-
" \"--InlineBackend.figure_formats={'svg', 'pdf'}\",\n",
306-
" \"--InlineBackend.rc=figure.dpi=96\",\n",
307-
"]\n",
308-
"```\n",
309-
"\n",
310-
"If you don't use LaTeX/PDF output,\n",
311-
"you can drop the `'pdf'` figure format.\n",
312-
"\n",
313300
"See [Configuring the Kernels](configuring-kernels.ipynb#Kernel-Arguments)."
314301
]
315302
},
@@ -935,7 +922,7 @@
935922
"name": "python",
936923
"nbconvert_exporter": "python",
937924
"pygments_lexer": "ipython3",
938-
"version": "3.9.2"
925+
"version": "3.9.9"
939926
}
940927
},
941928
"nbformat": 4,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'docutils',
1818
'jinja2',
1919
'nbconvert!=5.4',
20-
'traitlets',
20+
'traitlets>=5',
2121
'nbformat',
2222
'sphinx>=1.8',
2323
],

0 commit comments

Comments
 (0)