diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index c5a664835fa..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-{format}'.format(format=self.sphinx_builder), + 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(