Skip to content

Commit

Permalink
Build: remove support for MkDocs <= 0.17.3 (#10584)
Browse files Browse the repository at this point in the history
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 #9779
  • Loading branch information
humitos authored Sep 26, 2023
1 parent 3c55931 commit 7bc5c76
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 82 deletions.
8 changes: 1 addition & 7 deletions readthedocs/doc_builder/backends/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 1 addition & 7 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down
5 changes: 0 additions & 5 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"),
Expand Down
63 changes: 0 additions & 63 deletions readthedocs/rtd_tests/tests/test_doc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7bc5c76

Please sign in to comment.