Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix #18930 -- Wipe Sphinx build dir between builds.

This requires serving the docs from another repository, and syncing
the build dir to the serve dir after the build is finished.
  • Loading branch information...
commit d51819ecaab91f2d5b91cdc5d01c22b5aeb3f231 1 parent 1af4480
@aaugustin aaugustin authored
Showing with 19 additions and 9 deletions.
  1. +18 −8 docs/management/commands/update_docs.py
  2. +1 −1  docs/utils.py
View
26 docs/management/commands/update_docs.py
@@ -8,6 +8,7 @@
import json
import haystack
import optparse
+import shutil
import subprocess
import zipfile
import sphinx.cmdline
@@ -66,11 +67,11 @@ def handle_noargs(self, **kwargs):
source_dir = destdir
for builder in ('json', 'html'):
- # Make the directory for the built files - sphinx-build doesn't
- # do it for us, apparently.
+ # Wipe and re-create the build directory. See #18930.
build_dir = destdir.child('_build', builder)
- if not build_dir.exists():
- build_dir.mkdir(parents=True)
+ if build_dir.exists():
+ shutil.rmtree(build_dir)
+ build_dir.mkdir(parents=True)
# "Shell out" (not exactly, but basically) to sphinx-build.
if verbosity >= 2:
@@ -102,6 +103,15 @@ def zipfile_inclusion_filter(f):
zf.write(f, html_build_dir.rel_path_to(f))
#
+ # Copy the build results to the directory used for serving
+ # the documentation in the least disruptive way possible.
+ #
+ build_dir = destdir.child('_build')
+ built_dir = destdir.child('_built')
+ subprocess.check_call(['rsync', '--archive', '--delete',
+ '--link-dest=' + build_dir, build_dir + '/', built_dir])
+
+ #
# Rebuild the imported document list and search index.
#
if not kwargs['reindex']:
@@ -123,14 +133,14 @@ def zipfile_inclusion_filter(f):
# We have to be a bit careful to reverse-engineer the correct
# relative path component, especially for "index" documents,
# otherwise the search results will be incorrect.
- json_build_dir = destdir.child('_build', 'json')
- for built_doc in json_build_dir.walk():
+ json_built_dir = destdir.child('_built', 'json')
+ for built_doc in json_built_dir.walk():
if built_doc.isfile() and built_doc.ext == '.fjson':
# Convert the built_doc path which is now an absolute
- # path (i.e. "/home/docs/en/1.2/_build/ref/models.json")
+ # path (i.e. "/home/docs/en/1.2/_built/ref/models.json")
# into a path component (i.e. "ref/models").
- path = json_build_dir.rel_path_to(built_doc)
+ path = json_built_dir.rel_path_to(built_doc)
if path.stem == 'index':
path = path.parent
path = str(path.parent.child(path.stem))
View
2  docs/utils.py
@@ -3,7 +3,7 @@
from unipath import FSPath as Path
def get_doc_root(lang, version):
- return Path(settings.DOCS_BUILD_ROOT).child(lang, version, "_build", "json")
+ return Path(settings.DOCS_BUILD_ROOT).child(lang, version, "_built", "json")
def get_doc_root_or_404(lang, version):
docroot = get_doc_root(lang, version)
Please sign in to comment.
Something went wrong with that request. Please try again.