From bdb9c75235cad1d81a866f6f41f7b1ccdb27c537 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Wed, 6 Mar 2019 12:08:15 -0500 Subject: [PATCH 1/2] Share doctree between builders We are reducing build time with this. And also saving a little of space in the builders. According to sphinx, we are safe doing this: > the doctrees can be shared between all builders http://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-d Closes #4363 --- readthedocs/doc_builder/backends/sphinx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index c5a664835fa..1a867039574 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -217,7 +217,7 @@ def build(self): '-b', self.sphinx_builder, '-d', - '_build/doctrees-{format}'.format(format=self.sphinx_builder), + '_build/doctrees', '-D', 'language={lang}'.format(lang=project.language), '.', From b0f2ccdc6424eddc865ac4c553425bda7ac01611 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 11 Mar 2019 13:11:28 -0500 Subject: [PATCH 2/2] Use feature flag --- readthedocs/doc_builder/backends/sphinx.py | 5 +++- readthedocs/projects/models.py | 33 ++++++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index 1a867039574..99592139433 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -213,11 +213,14 @@ def build(self): build_command.append('-E') if self.config.sphinx.fail_on_warning: build_command.append('-W') + doctree_path = f'_build/doctrees-{self.sphinx_builder}' + if self.project.has_feature(Feature.SHARE_SPHINX_DOCTREE): + doctree_path = '_build/doctrees' build_command.extend([ '-b', self.sphinx_builder, '-d', - '_build/doctrees', + doctree_path, '-D', 'language={lang}'.format(lang=project.language), '.', diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 5991a41bb14..94f154861e1 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1313,31 +1313,40 @@ def add_features(sender, **kwargs): API_LARGE_DATA = 'api_large_data' DONT_SHALLOW_CLONE = 'dont_shallow_clone' USE_TESTING_BUILD_IMAGE = 'use_testing_build_image' + SHARE_SPHINX_DOCTREE = 'share_sphinx_doctree' FEATURES = ( (USE_SPHINX_LATEST, _('Use latest version of Sphinx')), (USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')), (ALLOW_DEPRECATED_WEBHOOKS, _('Allow deprecated webhook views')), (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')), - (SKIP_SUBMODULES, _('Skip git submodule checkout')), ( + (SKIP_SUBMODULES, _('Skip git submodule checkout')), + ( DONT_OVERWRITE_SPHINX_CONTEXT, _( 'Do not overwrite context vars in conf.py with Read the Docs context', ), - ), ( + ), + ( MKDOCS_THEME_RTD, - _('Use Read the Docs theme for MkDocs as default theme') - ), ( + _('Use Read the Docs theme for MkDocs as default theme'), + ), + ( DONT_SHALLOW_CLONE, - _( - 'Do not shallow clone when cloning git repos', - ), - ), ( + _('Do not shallow clone when cloning git repos'), + ), + ( USE_TESTING_BUILD_IMAGE, - _( - 'Use Docker image labelled as `testing` to build the docs', - ), - ), (API_LARGE_DATA, _('Try alternative method of posting large data')) + _('Use Docker image labelled as `testing` to build the docs'), + ), + ( + API_LARGE_DATA, + _('Try alternative method of posting large data'), + ), + ( + SHARE_SPHINX_DOCTREE, + _('Use shared directory for doctrees'), + ), ) projects = models.ManyToManyField(