diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 16276a9dcd2..2cc81ef396a 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -77,16 +77,8 @@ def get_yaml_config(self): mkdocs_path, ) - def append_conf(self): - """ - Call `cat mkdocs.yaml` only. - - This behavior has changed. We used to parse the YAML file and append - some configs automatically, but we have been removing that magic from - our builders as much as we can. - - This method will eventually removed completely. - """ + def show_conf(self): + """Show the current ``mkdocs.yaml`` being used.""" # Write the mkdocs.yml to the build logs self.run( "cat", diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index ebe49867c6e..174c40a6d5b 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -10,24 +10,14 @@ from pathlib import Path import structlog -from django.conf import settings -from django.template import loader as template_loader -from django.urls import reverse -from requests.exceptions import ConnectionError - -from readthedocs.builds import utils as version_utils -from readthedocs.builds.models import APIVersion -from readthedocs.core.utils.filesystem import safe_open -from readthedocs.projects.constants import OLD_LANGUAGES_CODE_MAPPING, PUBLIC + +from readthedocs.projects.constants import OLD_LANGUAGES_CODE_MAPPING from readthedocs.projects.exceptions import ProjectConfigurationError, UserFileNotFound -from readthedocs.projects.models import Feature -from readthedocs.projects.templatetags.projects_tags import sort_version_aware from ..base import BaseBuilder from ..constants import PDF_RE from ..environments import BuildCommand, DockerBuildCommand from ..exceptions import BuildUserError -from ..signals import finalize_sphinx_context_data log = structlog.get_logger(__name__) @@ -115,142 +105,8 @@ def get_language(self, project): language = project.language return OLD_LANGUAGES_CODE_MAPPING.get(language, language) - def get_config_params(self): - """Get configuration parameters to be rendered into the conf file.""" - # TODO this should be handled better in the theme - conf_py_path = os.path.join( - os.path.sep, - os.path.dirname( - os.path.relpath( - self.config_file, - self.project_path, - ), - ), - "", - ) - remote_version = self.version.commit_name - - github_user, github_repo = version_utils.get_github_username_repo( - url=self.project.repo, - ) - github_version_is_editable = self.version.type == "branch" - display_github = github_user is not None - - ( - bitbucket_user, - bitbucket_repo, - ) = version_utils.get_bitbucket_username_repo( # noqa - url=self.project.repo, - ) - bitbucket_version_is_editable = self.version.type == "branch" - display_bitbucket = bitbucket_user is not None - - gitlab_user, gitlab_repo = version_utils.get_gitlab_username_repo( - url=self.project.repo, - ) - gitlab_version_is_editable = self.version.type == "branch" - display_gitlab = gitlab_user is not None - - versions = [] - downloads = [] - subproject_urls = [] - try: - active_versions_data = self.api_client.project( - self.project.pk - ).active_versions.get()["versions"] - versions = sort_version_aware( - [APIVersion(**version_data) for version_data in active_versions_data] - ) - if not self.project.has_feature(Feature.ALL_VERSIONS_IN_HTML_CONTEXT): - versions = [v for v in versions if v.privacy_level == PUBLIC] - downloads = self.api_client.version(self.version.pk).get()["downloads"] - subproject_urls = [ - (project["slug"], project["canonical_url"]) - for project in self.api_client.project(self.project.pk) - .subprojects() - .get()["subprojects"] - ] - except ConnectionError: - log.exception( - "Timeout while fetching versions/downloads/subproject_urls for Sphinx context.", - project_slug=self.project.slug, - version_slug=self.version.slug, - ) - - build_id = self.build_env.build.get("id") - build_url = None - if build_id: - build_url = reverse( - "builds_detail", - kwargs={ - "project_slug": self.project.slug, - "build_pk": build_id, - }, - ) - protocol = "http" if settings.DEBUG else "https" - build_url = f"{protocol}://{settings.PRODUCTION_DOMAIN}{build_url}" - - vcs_url = None - if self.version.is_external: - vcs_url = self.version.vcs_url - - commit = self.project.vcs_repo( - version=self.version.slug, - environment=self.build_env, - ).commit - - data = { - "current_version": self.version.verbose_name, - "project": self.project, - "version": self.version, - "settings": settings, - "conf_py_path": conf_py_path, - "api_host": settings.PUBLIC_API_URL, - "commit": commit, - "versions": versions, - "downloads": downloads, - "subproject_urls": subproject_urls, - "build_url": build_url, - "vcs_url": vcs_url, - "proxied_static_path": self.project.proxied_static_path, - # GitHub - "github_user": github_user, - "github_repo": github_repo, - "github_version": remote_version, - "github_version_is_editable": github_version_is_editable, - "display_github": display_github, - # Bitbucket - "bitbucket_user": bitbucket_user, - "bitbucket_repo": bitbucket_repo, - "bitbucket_version": remote_version, - "bitbucket_version_is_editable": bitbucket_version_is_editable, - "display_bitbucket": display_bitbucket, - # GitLab - "gitlab_user": gitlab_user, - "gitlab_repo": gitlab_repo, - "gitlab_version": remote_version, - "gitlab_version_is_editable": gitlab_version_is_editable, - "display_gitlab": display_gitlab, - # Features - "docsearch_disabled": self.project.has_feature( - Feature.DISABLE_SERVER_SIDE_SEARCH - ), - } - - finalize_sphinx_context_data.send( - sender=self.__class__, - build_env=self.build_env, - data=data, - ) - - return data - - def append_conf(self): - """ - Find a ``conf.py`` and appends default content. - - The default content is rendered from ``doc_builder/conf.py.tmpl``. - """ + def show_conf(self): + """Show the current ``conf.py`` being used.""" if self.config_file is None: raise ProjectConfigurationError(ProjectConfigurationError.NOT_FOUND) @@ -264,22 +120,6 @@ def append_conf(self): }, ) - if not self.project.has_feature(Feature.DISABLE_SPHINX_MANIPULATION): - # Allow symlinks, but only the ones that resolve inside the base directory. - # NOTE: if something goes wrong, - # `safe_open` raises an exception that's clearly communicated to the user. - outfile = safe_open( - self.config_file, "a", allow_symlinks=True, base_path=self.project_path - ) - - # Append config to project conf file - tmpl = template_loader.get_template("doc_builder/conf.py.tmpl") - rendered = tmpl.render(self.get_config_params()) - - with outfile: - outfile.write("\n") - outfile.write(rendered) - # Print the contents of conf.py in order to make the rendered # configfile visible in the build logs self.run( @@ -357,18 +197,9 @@ def __init__(self, *args, **kwargs): class LocalMediaBuilder(BaseSphinx): - sphinx_builder = "readthedocssinglehtmllocalmedia" + sphinx_builder = "singlehtml" relative_output_dir = "htmlzip" - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - # The builder `readthedocssinglehtmllocalmedia` is defined by our - # `readthedocs-sphinx-ext` extension that we are not installing - # anymore; so we want to use the default Sphinx `singlehtml` builder - if self.project.has_feature(Feature.DISABLE_SPHINX_MANIPULATION): - self.sphinx_builder = "singlehtml" - def _post_build(self): """Internal post build to create the ZIP file from the HTML output.""" target_file = os.path.join( diff --git a/readthedocs/doc_builder/base.py b/readthedocs/doc_builder/base.py index bbf9fc2158a..8a3f11bca0a 100644 --- a/readthedocs/doc_builder/base.py +++ b/readthedocs/doc_builder/base.py @@ -40,8 +40,8 @@ def get_final_doctype(self): """Some builders may have a different doctype at build time.""" return self.config.doctype - def append_conf(self): - """Set custom configurations for this builder.""" + def show_conf(self): + """Show the configuration used for this builder.""" def build(self): """Do the actual building of the documentation.""" diff --git a/readthedocs/doc_builder/director.py b/readthedocs/doc_builder/director.py index 02a9b806757..5917b0441ae 100644 --- a/readthedocs/doc_builder/director.py +++ b/readthedocs/doc_builder/director.py @@ -25,7 +25,6 @@ from readthedocs.doc_builder.python_environments import Conda, Virtualenv from readthedocs.projects.constants import BUILD_COMMANDS_OUTPUT_PATH_HTML from readthedocs.projects.exceptions import RepositoryError -from readthedocs.projects.models import Feature from readthedocs.projects.signals import after_build, before_build, before_vcs from readthedocs.storage import build_tools_storage @@ -196,9 +195,8 @@ def build(self): self.run_build_job("post_build") self.store_readthedocs_build_yaml() - if self.data.project.has_feature(Feature.DISABLE_SPHINX_MANIPULATION): - # Mark this version to inject the new js client when serving it via El Proxito - self.data.version.addons = True + # Mark this version to inject the new js client when serving it via El Proxito. + self.data.version.addons = True after_build.send( sender=self.data.version, @@ -647,7 +645,7 @@ def build_docs_class(self, builder_class): ) if builder_class == self.data.config.doctype: - builder.append_conf() + builder.show_conf() self.data.version.documentation_type = builder.get_final_doctype() success = builder.build() diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index c5a6bb56d28..06d1b59f82e 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -176,10 +176,6 @@ def _install_latest_requirements(self, pip_install_cmd): else: requirements.append("sphinx") - # Install ``readthedocs-sphinx-ext`` only on old projects - if not self.project.has_feature(Feature.DISABLE_SPHINX_MANIPULATION): - requirements.append("readthedocs-sphinx-ext") - cmd = copy.copy(pip_install_cmd) cmd.extend(requirements) self.build_env.run( @@ -356,9 +352,6 @@ def _get_core_requirements(self): if self.config.doctype == "mkdocs": pip_requirements.append("mkdocs") else: - if not self.project.has_feature(Feature.DISABLE_SPHINX_MANIPULATION): - pip_requirements.append("readthedocs-sphinx-ext") - conda_requirements.extend(["sphinx"]) return pip_requirements, conda_requirements diff --git a/readthedocs/doc_builder/signals.py b/readthedocs/doc_builder/signals.py deleted file mode 100644 index 8a8af78ce9e..00000000000 --- a/readthedocs/doc_builder/signals.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Signals for adding custom context data.""" - -import django.dispatch - -finalize_sphinx_context_data = django.dispatch.Signal() diff --git a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl b/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl deleted file mode 100644 index a3a4f0f946d..00000000000 --- a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl +++ /dev/null @@ -1,174 +0,0 @@ -{% load projects_tags %} - - -########################################################################### -# auto-created readthedocs.org specific configuration # -########################################################################### - - -# -# The following code was added during an automated build on readthedocs.org -# It is auto created and injected for every build. The result is based on the -# conf.py.tmpl file found in the readthedocs.org codebase: -# https://github.com/rtfd/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl -# -# Note: this file shouldn't rely on extra dependencies. - -import importlib -import sys -import os.path - -# Borrowed from six. -PY3 = sys.version_info[0] == 3 -string_types = str if PY3 else basestring - -from sphinx import version_info - -# Get suffix for proper linking to GitHub -# This is deprecated in Sphinx 1.3+, -# as each page can have its own suffix -if globals().get('source_suffix', False): - if isinstance(source_suffix, string_types): - SUFFIX = source_suffix - elif isinstance(source_suffix, (list, tuple)): - # Sphinx >= 1.3 supports list/tuple to define multiple suffixes - SUFFIX = source_suffix[0] - elif isinstance(source_suffix, dict): - # Sphinx >= 1.8 supports a mapping dictionary for multiple suffixes - SUFFIX = list(source_suffix.keys())[0] # make a ``list()`` for py2/py3 compatibility - else: - # default to .rst - SUFFIX = '.rst' -else: - SUFFIX = '.rst' - -# Add RTD Static Path. Add to the end because it overwrites previous files. -if not 'html_static_path' in globals(): - html_static_path = [] -if os.path.exists('_static'): - html_static_path.append('_static') - -# Define this variable in case it's not defined by the user. -# It defaults to `alabaster` which is the default from Sphinx. -# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_theme -html_theme = globals().get('html_theme', 'alabaster') - -#Add project information to the template context. -context = { - 'html_theme': html_theme, - 'current_version': "{{ version.verbose_name }}", - 'version_slug': "{{ version.slug }}", - 'MEDIA_URL': "{{ settings.MEDIA_URL }}", - 'STATIC_URL': "{{ settings.STATIC_URL }}", - 'PRODUCTION_DOMAIN': "{{ settings.PRODUCTION_DOMAIN }}", - 'proxied_static_path': "{{ proxied_static_path }}", - 'versions': [{% for version in versions %} - ("{{ version.slug }}", "/{{ version.project.language }}/{{ version.slug}}/"),{% endfor %} - ], - 'downloads': [ {% for key, val in downloads.items %} - ("{{ key }}", "{{ val }}"),{% endfor %} - ], - 'subprojects': [ {% for slug, url in subproject_urls %} - ("{{ slug }}", "{{ url }}"),{% endfor %} - ], - 'slug': '{{ project.slug }}', - 'name': u'{{ project.name }}', - 'rtd_language': u'{{ project.language }}', - 'programming_language': u'{{ project.programming_language }}', - 'canonical_url': '{{ project.get_canonical_url }}', - 'analytics_code': '{{ project.analytics_code }}', - 'single_version': {{ project.is_single_version }}, - 'conf_py_path': '{{ conf_py_path }}', - 'api_host': '{{ api_host }}', - 'github_user': '{{ github_user }}', - 'proxied_api_host': '{{ project.proxied_api_host }}', - 'github_repo': '{{ github_repo }}', - 'github_version': '{{ github_version }}', - 'display_github': {{ display_github }}, - 'bitbucket_user': '{{ bitbucket_user }}', - 'bitbucket_repo': '{{ bitbucket_repo }}', - 'bitbucket_version': '{{ bitbucket_version }}', - 'display_bitbucket': {{ display_bitbucket }}, - 'gitlab_user': '{{ gitlab_user }}', - 'gitlab_repo': '{{ gitlab_repo }}', - 'gitlab_version': '{{ gitlab_version }}', - 'display_gitlab': {{ display_gitlab }}, - 'READTHEDOCS': True, - 'using_theme': (html_theme == "default"), - 'new_theme': (html_theme == "sphinx_rtd_theme"), - 'source_suffix': SUFFIX, - 'ad_free': {% if project.show_advertising %}False{% else %}True{% endif %}, - 'docsearch_disabled': {{ docsearch_disabled }}, - 'user_analytics_code': '{{ project.analytics_code|default_if_none:'' }}', - 'global_analytics_code': {% if project.analytics_disabled %}None{% else %}'{{ settings.GLOBAL_ANALYTICS_CODE }}'{% endif %}, - 'commit': {% if project.repo_type == 'git' %}'{{ commit|slice:"8" }}'{% else %}'{{ commit }}'{% endif %}, -} - -# For sphinx >=1.8 we can use html_baseurl to set the canonical URL. -# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl -if version_info >= (1, 8): - if not globals().get('html_baseurl'): - html_baseurl = context['canonical_url'] - context['canonical_url'] = None - - -{# Provide block for extending context data from child template #} -{% block extra_context %}{% endblock %} - -if 'html_context' in globals(): - for key in context: - if key not in html_context: - html_context[key] = context[key] -else: - html_context = context - -# Add custom RTD extension -if 'extensions' in globals(): - # Insert at the beginning because it can interfere - # with other extensions. - # See https://github.com/rtfd/readthedocs.org/pull/4054 - extensions.insert(0, "readthedocs_ext.readthedocs") -else: - extensions = ["readthedocs_ext.readthedocs"] - -# Add External version warning banner to the external version documentation -if '{{ version.type }}' == 'external': - extensions.insert(1, "readthedocs_ext.external_version_warning") - readthedocs_vcs_url = '{{ vcs_url }}' - readthedocs_build_url = '{{ build_url }}' - -project_language = '{{ project.language }}' - -# User's Sphinx configurations -language_user = globals().get('language', None) -latex_engine_user = globals().get('latex_engine', None) -latex_elements_user = globals().get('latex_elements', None) - -# Remove this once xindy gets installed in Docker image and XINDYOPS -# env variable is supported -# https://github.com/rtfd/readthedocs-docker-images/pull/98 -latex_use_xindy = False - -chinese = any([ - language_user in ('zh_CN', 'zh_TW'), - project_language in ('zh_CN', 'zh_TW'), -]) - -japanese = any([ - language_user == 'ja', - project_language == 'ja', -]) - -if chinese: - latex_engine = latex_engine_user or 'xelatex' - - latex_elements_rtd = { - 'preamble': '\\usepackage[UTF8]{ctex}\n', - } - latex_elements = latex_elements_user or latex_elements_rtd -elif japanese: - latex_engine = latex_engine_user or 'platex' - -# Make sure our build directory is always excluded -exclude_patterns = globals().get('exclude_patterns', []) -exclude_patterns.extend(['_build']) diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index c62e5149a6e..cce8140a539 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1918,7 +1918,6 @@ def add_features(sender, **kwargs): # may be added by other packages API_LARGE_DATA = "api_large_data" CONDA_APPEND_CORE_REQUIREMENTS = "conda_append_core_requirements" - ALL_VERSIONS_IN_HTML_CONTEXT = "all_versions_in_html_context" RECORD_404_PAGE_VIEWS = "record_404_page_views" DISABLE_PAGEVIEWS = "disable_pageviews" RESOLVE_PROJECT_FROM_HEADER = "resolve_project_from_header" @@ -1936,10 +1935,8 @@ def add_features(sender, **kwargs): DONT_INSTALL_LATEST_PIP = "dont_install_latest_pip" USE_SPHINX_RTD_EXT_LATEST = "rtd_sphinx_ext_latest" INSTALL_LATEST_CORE_REQUIREMENTS = "install_latest_core_requirements" - DISABLE_SPHINX_MANIPULATION = "disable_sphinx_manipulation" # Search related features - DISABLE_SERVER_SIDE_SEARCH = "disable_server_side_search" ENABLE_MKDOCS_SERVER_SIDE_SEARCH = "enable_mkdocs_server_side_search" DEFAULT_TO_FUZZY_SEARCH = "default_to_fuzzy_search" @@ -1955,13 +1952,6 @@ def add_features(sender, **kwargs): CONDA_APPEND_CORE_REQUIREMENTS, _("Conda: Append Read the Docs core requirements to environment.yml file"), ), - ( - ALL_VERSIONS_IN_HTML_CONTEXT, - _( - "Sphinx: Pass all versions (including private) into the html context " - "when building with Sphinx" - ), - ), ( RECORD_404_PAGE_VIEWS, _("Proxito: Record 404s page views."), @@ -2014,17 +2004,7 @@ def add_features(sender, **kwargs): "Build: Install all the latest versions of Read the Docs core requirements" ), ), - ( - DISABLE_SPHINX_MANIPULATION, - _( - "Sphinx: Don't append `conf.py` and don't install ``readthedocs-sphinx-ext``" - ), - ), # Search related features. - ( - DISABLE_SERVER_SIDE_SEARCH, - _("Search: Disable server side search"), - ), ( ENABLE_MKDOCS_SERVER_SIDE_SEARCH, _("Search: Enable server side search for MkDocs projects"), diff --git a/readthedocs/projects/tests/mockers.py b/readthedocs/projects/tests/mockers.py index 4241a726793..f2b9604fc05 100644 --- a/readthedocs/projects/tests/mockers.py +++ b/readthedocs/projects/tests/mockers.py @@ -93,10 +93,7 @@ def _mock_artifact_builders(self): # TODO: find a way to not mock this one and mock `open()` used inside # it instead to make the mock more granularly and be able to execute - # the `append_conf` normally. - self.patches["builder.html.mkdocs.MkdocsHTML.append_conf"] = mock.patch( - "readthedocs.doc_builder.backends.mkdocs.MkdocsHTML.append_conf", - ) + # `get_final_doctype` normally. self.patches["builder.html.mkdocs.MkdocsHTML.get_final_doctype"] = mock.patch( "readthedocs.doc_builder.backends.mkdocs.MkdocsHTML.get_final_doctype", return_value=MKDOCS, @@ -104,15 +101,10 @@ def _mock_artifact_builders(self): # NOTE: another approach would be to make these files are in the tmpdir # used for testing (see ``apply_fs`` util function) - self.patches["builder.html.sphinx.HtmlBuilder.append_conf"] = mock.patch( - "readthedocs.doc_builder.backends.sphinx.HtmlBuilder.append_conf", + self.patches["builder.html.sphinx.HtmlBuilder.show_conf"] = mock.patch( + "readthedocs.doc_builder.backends.sphinx.HtmlBuilder.show_conf", ) - # self.patches['builder.html.mkdocs.open'] = mock.patch( - # 'readthedocs.doc_builder.backends.mkdocs.builtins.open', - # mock.mock_open(read_data='file content'), - # ) - def _mock_git_repository(self): self.patches["git.Backend.run"] = mock.patch( "readthedocs.vcs_support.backends.git.Backend.run", diff --git a/readthedocs/projects/tests/test_build_tasks.py b/readthedocs/projects/tests/test_build_tasks.py index 5fa64b6673b..7e5639224a3 100644 --- a/readthedocs/projects/tests/test_build_tasks.py +++ b/readthedocs/projects/tests/test_build_tasks.py @@ -159,13 +159,13 @@ class TestBuildTask(BuildEnvironmentBase): "formats,builders", ( (["pdf"], ["latex"]), - (["htmlzip"], ["readthedocssinglehtmllocalmedia"]), + (["htmlzip"], ["singlehtml"]), (["epub"], ["epub"]), ( ["pdf", "htmlzip", "epub"], - ["latex", "readthedocssinglehtmllocalmedia", "epub"], + ["latex", "singlehtml", "epub"], ), - ("all", ["latex", "readthedocssinglehtmllocalmedia", "nepub"]), + ("all", ["latex", "singlehtml", "epub"]), ), ) @mock.patch("readthedocs.doc_builder.director.load_yaml_config") @@ -304,7 +304,7 @@ def test_build_updates_documentation_type(self, load_yaml_config): assert self.requests_mock.request_history[8]._request.method == "PATCH" assert self.requests_mock.request_history[8].path == "/api/v2/version/1/" assert self.requests_mock.request_history[8].json() == { - "addons": False, + "addons": True, "build_data": None, "built": True, "documentation_type": "mkdocs", @@ -630,7 +630,7 @@ def test_successful_build( assert self.requests_mock.request_history[8]._request.method == "PATCH" assert self.requests_mock.request_history[8].path == "/api/v2/version/1/" assert self.requests_mock.request_history[8].json() == { - "addons": False, + "addons": True, "build_data": None, "built": True, "documentation_type": "sphinx", @@ -912,7 +912,6 @@ def test_build_commands_executed( "--upgrade", "--no-cache-dir", "sphinx", - "readthedocs-sphinx-ext", bin_path=mock.ANY, cwd=mock.ANY, ), @@ -947,7 +946,7 @@ def test_build_commands_executed( "sphinx", "-T", "-b", - "readthedocssinglehtmllocalmedia", + "singlehtml", "-d", "_build/doctrees", "-D", @@ -1567,7 +1566,6 @@ def test_conda_config_calls_conda_command(self, load_yaml_config): "install", "-U", "--no-cache-dir", - "readthedocs-sphinx-ext", cwd=mock.ANY, bin_path=mock.ANY, ), @@ -1664,7 +1662,6 @@ def test_python_mamba_commands(self, load_yaml_config): "install", "-U", "--no-cache-dir", - "readthedocs-sphinx-ext", bin_path=mock.ANY, cwd=mock.ANY, ), diff --git a/readthedocs/rtd_tests/tests/test_doc_builder.py b/readthedocs/rtd_tests/tests/test_doc_builder.py index d21d72be8eb..e510de3a45a 100644 --- a/readthedocs/rtd_tests/tests/test_doc_builder.py +++ b/readthedocs/rtd_tests/tests/test_doc_builder.py @@ -1,4 +1,3 @@ -import os import tempfile from unittest import mock from unittest.mock import patch @@ -36,41 +35,6 @@ def setUp(self): BaseSphinx.relative_output_dir = "_readthedocs/" @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.docs_dir") - @patch("readthedocs.projects.models.Project.checkout_path") - @patch("readthedocs.doc_builder.python_environments.load_yaml_config") - def test_conf_py_path(self, load_yaml_config, checkout_path, docs_dir): - """ - Test the conf_py_path that is added to the conf.py file. - - This value is used from the theme and footer - to build the ``View`` and ``Edit`` on link. - """ - tmp_dir = tempfile.mkdtemp() - checkout_path.return_value = tmp_dir - docs_dir.return_value = tmp_dir - python_env = Virtualenv( - version=self.version, - build_env=self.build_env, - config=get_build_config({}, validate=True), - ) - base_sphinx = BaseSphinx( - build_env=self.build_env, - python_env=python_env, - ) - - for value, expected in (("conf.py", "/"), ("docs/conf.py", "/docs/")): - base_sphinx.config_file = os.path.join( - tmp_dir, - value, - ) - params = base_sphinx.get_config_params() - self.assertEqual( - params["conf_py_path"], - expected, - ) - - @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.docs_dir") - @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.get_config_params") @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.run") @patch("readthedocs.builds.models.Version.get_conf_py_path") @patch("readthedocs.projects.models.Project.checkout_path") @@ -81,7 +45,6 @@ def test_project_without_conf_py( checkout_path, get_conf_py_path, _, - get_config_params, docs_dir, ): """ @@ -93,7 +56,6 @@ def test_project_without_conf_py( tmp_dir = tempfile.mkdtemp() checkout_path.return_value = tmp_dir docs_dir.return_value = tmp_dir - get_config_params.return_value = {} get_conf_py_path.side_effect = ProjectConfigurationError python_env = Virtualenv( version=self.version, @@ -105,7 +67,7 @@ def test_project_without_conf_py( python_env=python_env, ) with self.assertRaises(ProjectConfigurationError) as e: - base_sphinx.append_conf() + base_sphinx.show_conf() self.assertEqual( e.exception.message_id, @@ -113,7 +75,6 @@ def test_project_without_conf_py( ) @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.docs_dir") - @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.get_config_params") @patch("readthedocs.doc_builder.backends.sphinx.BaseSphinx.run") @patch("readthedocs.builds.models.Version.get_conf_py_path") @patch("readthedocs.projects.models.Project.checkout_path") @@ -124,7 +85,6 @@ def test_multiple_conf_py( checkout_path, get_conf_py_path, _, - get_config_params, docs_dir, ): """ @@ -139,7 +99,6 @@ def test_multiple_conf_py( tmp_docs_dir.join("test").mkdir().join("conf.py").write("") docs_dir.return_value = str(tmp_docs_dir) checkout_path.return_value = str(tmp_docs_dir) - get_config_params.return_value = {} get_conf_py_path.side_effect = ProjectConfigurationError python_env = Virtualenv( version=self.version, @@ -152,4 +111,4 @@ def test_multiple_conf_py( ) with pytest.raises(ProjectConfigurationError): with override_settings(DOCROOT=tmp_docs_dir): - base_sphinx.append_conf() + base_sphinx.show_conf()