diff --git a/doc/Makefile b/doc/Makefile
index 1da6042002fa775ca6dbd688a65a8d6bfdf95b4f..1bdce83437737749dadea3aa5f4f9823b365e68a 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -129,6 +129,9 @@ doctest:
 %.pdf: %.svg
 	inkscape --export-pdf=$@ $<
 
+#### Tutorial and figure script generation machinery ####
+# See source/code/README for an explanation.
+
 # Make tutorial scripts by extracting the (complete!) context of the "patches".
 # We make sure not to use 'wiggle' here.
 .SECONDARY:
diff --git a/doc/source/code/README b/doc/source/code/README
new file mode 100644
index 0000000000000000000000000000000000000000..896e658aca4cc6ec6d2d757dab099beca7bea2d1
--- /dev/null
+++ b/doc/source/code/README
@@ -0,0 +1,42 @@
+This directory contains the code examples from the documentation.
+Most scripts are present in three related but different versions that
+correspond to three different usages.
+
+* Subdirectory 'figure': scripts used for figure generation.  Figures
+  are not displayed but saved to disk.
+
+* Subdirectory 'include': scripts that display figures on screen.
+  They contain commented marks for including snippets in the
+  documentation.
+
+* Subdirectory 'download': complete scripts to be offered for download
+  by readers.  Like 'include' but with the include marks removed.
+
+Most scripts are extracted from corresponding '*.py.diff' files inside
+'figure/'.  These are patches from the 'include' version to the
+'figure' version.  The patches include complete context and as such
+can be used to recreate both files.  It's these patches that are kept
+under version control.
+
+running 'make html' or 'make latex' inside '/doc' will automatically
+update all these scripts according to the following scheme:
+
+            ---->------------->------
+           /                         \
+          /         download/x.py     \
+figure/x.py.diff         ^             \
+     ^           \       |              \
+     |            -> include/x.py ---(patch)---> figure/x.py
+     |                   |                          |
+     |                   |                          |
+      \                  v                         /
+       ----<----------(diff)--------------<--------
+
+Thus, it is possible to update figure/x.py.diff, include/x.py or
+figure/x.py and any changes will be propagated automatically when
+'make' is run.  (Only download/x.py is a dead end.)  The user will be
+informed about any conflicts.  The makefile will only update files
+that are older than their sources and is careful to propagate time
+stamps in order to avoid infinite loops.
+
+Editing only figure/x.py.diff is a sure way to avoid any conflicts.