Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mkdocs: default to "docs" for docs_dir #7766

Merged
merged 2 commits into from Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions readthedocs/doc_builder/backends/mkdocs.py
Expand Up @@ -115,6 +115,7 @@ def load_yaml_config(self):
)
return {
'site_name': self.version.project.name,
'docs_dir': self.docs_dir(),
}
except yaml.YAMLError as exc:
note = ''
Expand All @@ -139,14 +140,12 @@ def append_conf(self):
user_config = self.load_yaml_config()

# Handle custom docs dirs
user_docs_dir = user_config.get('docs_dir')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we were respecting the users docs_dir setting here, weren't we? This PR just changes it to default to docs for users who didn't define one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we still respect the value set by the user

if not isinstance(user_docs_dir, (type(None), str)):
docs_dir = user_config.get('docs_dir', 'docs')
if not isinstance(docs_dir, (type(None), str)):
raise MkDocsYAMLParseError(
MkDocsYAMLParseError.INVALID_DOCS_DIR_CONFIG,
)

docs_dir = self.docs_dir(docs_dir=user_docs_dir)

self.create_index(extension='md')
user_config['docs_dir'] = docs_dir

Expand Down
6 changes: 5 additions & 1 deletion readthedocs/rtd_tests/tests/test_doc_builder.py
Expand Up @@ -350,7 +350,10 @@ def test_get_theme_name_with_feature_flag(self, checkout_path, run):
self.assertEqual(builder.get_theme_name({}), 'readthedocs')
with patch('readthedocs.doc_builder.backends.mkdocs.yaml') as mock_yaml:
with patch('readthedocs.doc_builder.backends.mkdocs.MkdocsHTML.load_yaml_config') as mock_load_yaml_config:
mock_load_yaml_config.return_value = {'site_name': self.project.name}
mock_load_yaml_config.return_value = {
'site_name': self.project.name,
'docs_dir': tmpdir,
}
builder.append_conf()

mock_yaml.safe_dump.assert_called_once_with(
Expand All @@ -374,6 +377,7 @@ def test_get_theme_name_with_feature_flag(self, checkout_path, run):
mock_load_yaml_config.return_value = {
'site_name': self.project.name,
'theme': 'customtheme',
'docs_dir': tmpdir,
}
builder.append_conf()

Expand Down