Skip to content

Commit 7fab0eb

Browse files
authored
Mkdocs: default to "docs" for docs_dir (#7766)
This value has been the default since the start of the project https://github.com/mkdocs/mkdocs/blob/0.13.0/mkdocs/config/defaults.py#L44 We should respect that default value, (we should actually don't edit it at all #2483). So, instead of trying to guess the docs dir always, only try to guess it if the user doesn't have mkdocs.yaml file. This should avoid any backwards compatibility and avoid weird bugs to new users. Closes #7539
1 parent cf199fd commit 7fab0eb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

readthedocs/doc_builder/backends/mkdocs.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def load_yaml_config(self):
115115
)
116116
return {
117117
'site_name': self.version.project.name,
118+
'docs_dir': self.docs_dir(),
118119
}
119120
except yaml.YAMLError as exc:
120121
note = ''
@@ -139,14 +140,12 @@ def append_conf(self):
139140
user_config = self.load_yaml_config()
140141

141142
# Handle custom docs dirs
142-
user_docs_dir = user_config.get('docs_dir')
143-
if not isinstance(user_docs_dir, (type(None), str)):
143+
docs_dir = user_config.get('docs_dir', 'docs')
144+
if not isinstance(docs_dir, (type(None), str)):
144145
raise MkDocsYAMLParseError(
145146
MkDocsYAMLParseError.INVALID_DOCS_DIR_CONFIG,
146147
)
147148

148-
docs_dir = self.docs_dir(docs_dir=user_docs_dir)
149-
150149
self.create_index(extension='md')
151150
user_config['docs_dir'] = docs_dir
152151

readthedocs/rtd_tests/tests/test_doc_builder.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ def test_get_theme_name_with_feature_flag(self, checkout_path, run):
350350
self.assertEqual(builder.get_theme_name({}), 'readthedocs')
351351
with patch('readthedocs.doc_builder.backends.mkdocs.yaml') as mock_yaml:
352352
with patch('readthedocs.doc_builder.backends.mkdocs.MkdocsHTML.load_yaml_config') as mock_load_yaml_config:
353-
mock_load_yaml_config.return_value = {'site_name': self.project.name}
353+
mock_load_yaml_config.return_value = {
354+
'site_name': self.project.name,
355+
'docs_dir': tmpdir,
356+
}
354357
builder.append_conf()
355358

356359
mock_yaml.safe_dump.assert_called_once_with(
@@ -374,6 +377,7 @@ def test_get_theme_name_with_feature_flag(self, checkout_path, run):
374377
mock_load_yaml_config.return_value = {
375378
'site_name': self.project.name,
376379
'theme': 'customtheme',
380+
'docs_dir': tmpdir,
377381
}
378382
builder.append_conf()
379383

0 commit comments

Comments
 (0)