[med-svn] [python-mne] 31/353: HACK: prevent proliferation of image files in documentation build

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:24:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

yoh pushed a commit to tag 0.4
in repository python-mne.

commit 1fa2b7a32c6b7fa90bf90b5091bcadb432a15ef3
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Thu Dec 22 11:24:45 2011 +0100

    HACK: prevent proliferation of image files in documentation build
---
 doc/Makefile             |  4 ----
 doc/sphinxext/gen_rst.py | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/doc/Makefile b/doc/Makefile
index 1739353..e86b3f8 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -31,10 +31,6 @@ clean:
 	-rm -rf sources/auto_examples
 
 html:
-	-rm -rf build/html/_downloads/*1.py
-	-rm -rf build/html/_downloads/*2.py
-	-rm -rf build/html/_downloads/*3.py
-	-rm -rf build/html/_downloads/*4.py
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
 	@echo
 	@echo "Build finished. The HTML pages are in build/html."
diff --git a/doc/sphinxext/gen_rst.py b/doc/sphinxext/gen_rst.py
index e928c4c..1f96275 100644
--- a/doc/sphinxext/gen_rst.py
+++ b/doc/sphinxext/gen_rst.py
@@ -201,3 +201,24 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
 def setup(app):
     app.connect('builder-inited', generate_example_rst)
     app.add_config_value('plot_gallery', True, 'html')
+
+    # Sphinx hack: sphinx copies generated images to the build directory
+    #  each time the docs are made.  If the desired image name already
+    #  exists, it appends a digit to prevent overwrites.  The problem is,
+    #  the directory is never cleared.  This means that each time you build
+    #  the docs, the number of images in the directory grows.
+    #
+    # This question has been asked on the sphinx development list, but there
+    #  was no response: http://osdir.com/ml/sphinx-dev/2011-02/msg00123.html
+    #
+    # The following is a hack that prevents this behavior by clearing the
+    #  image build directory each time the docs are built.  If sphinx
+    #  changes their layout between versions, this will not work (though
+    #  it should probably not cause a crash).  Tested successfully
+    #  on Sphinx 1.0.7
+    build_image_dir = 'build/html/_images'
+    if os.path.exists(build_image_dir):
+        shutil.rmtree(build_image_dir)
+    build_download_dir = 'build/html/_downloads'
+    if os.path.exists(build_download_dir):
+        shutil.rmtree(build_download_dir)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git



More information about the debian-med-commit mailing list