From 7bc5c763f49f7e4f1bbd34501675052f465cb428 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 26 Sep 2023 18:48:21 +0200 Subject: [PATCH] Build: remove support for MkDocs <= 0.17.3 (#10584) We want to keep deprecating old feature flags we don't want to support forever. In particular, those that keep our users using pretty old versions of doctools and freeze them in a status that's hard to maintain. This PR removes the `DEFATUL_TO_MKDOCS_0_17_3` feature flag and always install the latest `mkdocs` version. Note this feature flag has `default_true=True` for those projects created _before 2019-04-03_. I did a small DB query and found: ```python >>> Project.objects.filter(pub_date__lt=timezone.datetime(2019, 4, 3), documentation_type='mkdocs').count() 7529 ``` However, note we don't know if these projects are pinning a version of MkDocs, so we don't exactly know how many of those are using this feature. However, it gives us a maximum number at least. On the other hand, taking a look at Metabase, using the build data from the past 6 months I found that we only have 293 projects: https://ethicalads.metabaseapp.com/question/218-projects-using-mkdocs-group-by-version Related https://github.com/readthedocs/readthedocs.org/issues/9779 --- readthedocs/doc_builder/backends/mkdocs.py | 8 +-- .../doc_builder/python_environments.py | 8 +-- readthedocs/projects/models.py | 5 -- .../rtd_tests/tests/test_doc_builder.py | 63 ------------------- 4 files changed, 2 insertions(+), 82 deletions(-) diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 08bb8e7d349..7f36b49eafd 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -145,13 +145,7 @@ def append_conf(self): ) user_config['docs_dir'] = docs_dir - - # MkDocs <=0.17.x doesn't support absolute paths, - # it needs one with a full domain. - if self.project.has_feature(Feature.DEFAULT_TO_MKDOCS_0_17_3): - static_url = get_absolute_static_url() - else: - static_url = self.project.proxied_static_path + static_url = self.project.proxied_static_path # Set mkdocs config values. extra_assets = { diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 2d6a60f4ac9..114c9c155e9 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -256,13 +256,7 @@ def _install_old_requirements(self, pip_install_cmd): ) if self.config.doctype == 'mkdocs': - requirements.append( - self.project.get_feature_value( - Feature.DEFAULT_TO_MKDOCS_0_17_3, - positive='mkdocs==0.17.3', - negative="mkdocs", - ) - ) + requirements.append("mkdocs") else: requirements.extend( [ diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 50945e58fb4..0e9817d59e2 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1892,7 +1892,6 @@ def add_features(sender, **kwargs): USE_NEW_PIP_RESOLVER = 'use_new_pip_resolver' DONT_INSTALL_LATEST_PIP = 'dont_install_latest_pip' USE_SPHINX_LATEST = 'use_sphinx_latest' - DEFAULT_TO_MKDOCS_0_17_3 = 'default_to_mkdocs_0_17_3' USE_SPHINX_RTD_EXT_LATEST = 'rtd_sphinx_ext_latest' INSTALL_LATEST_CORE_REQUIREMENTS = "install_latest_core_requirements" @@ -1999,10 +1998,6 @@ def add_features(sender, **kwargs): _("Build: Don't install the latest version of pip"), ), (USE_SPHINX_LATEST, _("Sphinx: Use latest version of Sphinx")), - ( - DEFAULT_TO_MKDOCS_0_17_3, - _("MkDOcs: Install mkdocs 0.17.3 by default"), - ), ( USE_SPHINX_RTD_EXT_LATEST, _("Sphinx: Use latest version of the Read the Docs Sphinx extension"), diff --git a/readthedocs/rtd_tests/tests/test_doc_builder.py b/readthedocs/rtd_tests/tests/test_doc_builder.py index 2c6d87f36ae..ede87072177 100644 --- a/readthedocs/rtd_tests/tests/test_doc_builder.py +++ b/readthedocs/rtd_tests/tests/test_doc_builder.py @@ -367,69 +367,6 @@ def test_append_conf_existing_yaml_on_root(self, checkout_path, run): "mkdocs", ) - @patch("readthedocs.doc_builder.base.BaseBuilder.run") - @patch("readthedocs.projects.models.Project.checkout_path") - def test_append_conf_mkdocs_07x(self, checkout_path, run): - get( - Feature, - feature_id=Feature.DEFAULT_TO_MKDOCS_0_17_3, - projects=[self.project], - ) - tmpdir = tempfile.mkdtemp() - os.mkdir(os.path.join(tmpdir, "docs")) - yaml_file = os.path.join(tmpdir, "mkdocs.yml") - yaml.safe_dump( - { - "site_name": "mkdocs", - "google_analytics": ["UA-1234-5", "mkdocs.org"], - "docs_dir": "docs", - }, - open(yaml_file, "w"), - ) - checkout_path.return_value = tmpdir - - python_env = Virtualenv( - version=self.version, - build_env=self.build_env, - config=None, - ) - builder = MkdocsHTML( - build_env=self.build_env, - python_env=python_env, - ) - with override_settings(DOCROOT=tmpdir): - builder.append_conf() - - run.assert_called_with('cat', 'mkdocs.yml', cwd=mock.ANY) - - config = yaml_load_safely(open(yaml_file)) - self.assertEqual( - config['docs_dir'], - 'docs', - ) - self.assertEqual( - config['extra_css'], - [ - 'http://readthedocs.org/static/css/badge_only.css', - 'http://readthedocs.org/static/css/readthedocs-doc-embed.css', - ], - ) - self.assertEqual( - config['extra_javascript'], - [ - 'readthedocs-data.js', - 'http://readthedocs.org/static/core/js/readthedocs-doc-embed.js', - 'http://readthedocs.org/static/javascript/readthedocs-analytics.js', - ], - ) - self.assertIsNone( - config['google_analytics'], - ) - self.assertEqual( - config['site_name'], - 'mkdocs', - ) - @patch('readthedocs.doc_builder.base.BaseBuilder.run') @patch('readthedocs.projects.models.Project.checkout_path') def test_append_conf_existing_yaml_on_root_with_invalid_setting(self, checkout_path, run):