Skip to content

Commit 241599b

Browse files
committed
DOC: Add information about removing output cells for Git
Some of this is taken from #118.
1 parent 7192d9c commit 241599b

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

doc/pre-executed.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"# Pre-Executing Notebooks\n",
1717
"\n",
1818
"Automatically executing notebooks during the Sphinx build process is an important feature of `nbsphinx`.\n",
19-
"However, there are a few use cases where pre-executing a notebook and storing the outputs might be preferable."
19+
"However, there are a few use cases where pre-executing a notebook and storing the outputs might be preferable.\n",
20+
"Storing any output will, by default, stop ``nbsphinx`` from executing the notebook."
2021
]
2122
},
2223
{

doc/usage.ipynb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
"Subsequent builds will be faster, because only those source files which have changed will be re-built.\n",
7979
"To force re-building all source files, use the `-E` option.\n",
8080
"\n",
81+
"<div class=\"alert alert-info\">\n",
82+
"\n",
83+
"**Note:**\n",
84+
"\n",
85+
"By default, notebooks will be executed during the Sphinx build process only if they do not have any output cells stored.\n",
86+
"See [Controlling Notebook Execution](executing-notebooks.ipynb).\n",
87+
"\n",
88+
"</div>\n",
89+
"\n",
8190
"To create LaTeX output, use:\n",
8291
"\n",
8392
" python3 -m sphinx <source-dir> <build-dir> -b latex\n",
@@ -318,6 +327,38 @@
318327
"\n",
319328
"If you know of another Sphinx theme that should be included here, please open an [issue on Github](https://github.com/spatialaudio/nbsphinx/issues)."
320329
]
330+
},
331+
{
332+
"cell_type": "markdown",
333+
"metadata": {},
334+
"source": [
335+
"## Using Notebooks with Git\n",
336+
"\n",
337+
"[Git](https://git-scm.com/) is extremely useful for managing source code and it can and should also be used for managing Jupyter notebooks.\n",
338+
"There is one caveat, however:\n",
339+
"Notebooks can contain output cells with rich media like images, plots, sounds, HTML, JavaScript and many other types of bulky machine-created content.\n",
340+
"This can make it hard to work with Git efficiently, because changes in those bulky contents can completely obscure the more interesting changes in text and source code.\n",
341+
"Working with multiple collaborators on a notebook can become very tedious because of this.\n",
342+
"\n",
343+
"It is therefore highly recommended that you remove all outputs from your notebooks before committing changes to a Git repository (except for the reasons mentioned in [Pre-Executing Notebooks](pre-executed.ipynb)).\n",
344+
"\n",
345+
"If there are no output cells in a notebook, `nbsphinx` will by default execute the notebook and the pages generated by Sphinx will therefore contain all the output cells.\n",
346+
"See [Controlling Notebook Execution](executing-notebooks.ipynb) for how this behavior can be customized.\n",
347+
"\n",
348+
"In the Jupyter Notebook application, you can manually clear all outputs by selecting\n",
349+
"\"Cell\" $\\to$ \"All Output\" $\\to$ \"Clear\" from the menu.\n",
350+
"\n",
351+
"There are several tools available to remove outputs from multiple files at once without having to open them separately.\n",
352+
"You can even include such a tool as \"clean/smudge filters\" into your Git workflow, which will strip the output cells automatically whenever a Git command is executed.\n",
353+
"For details, have a look at those links:\n",
354+
"\n",
355+
"* https://github.com/kynan/nbstripout\n",
356+
"* https://github.com/toobaz/ipynb_output_filter\n",
357+
"* http://tillahoffmann.github.io/2017/04/17/versioning-jupyter-notebooks-with-git.html\n",
358+
"* http://timstaley.co.uk/posts/making-git-and-jupyter-notebooks-play-nice/\n",
359+
"* http://pascalbugnion.net/blog/ipython-notebooks-and-git.html\n",
360+
"\n"
361+
]
321362
}
322363
],
323364
"metadata": {

0 commit comments

Comments
 (0)