Skip to content

Implement mkdocs key from v2 config #4486

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

Merged
merged 16 commits into from
Sep 27, 2018
Merged
10 changes: 7 additions & 3 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,16 @@ def validate_final_doc_type(self):
should support per version doctype, but we need to
adapt the rtd code for that.
"""
if self.doctype != self.defaults.get('doctype', 'sphinx'):
dashboard_doctype = self.defaults.get('doctype', 'sphinx')
if self.doctype != dashboard_doctype:
key = 'mkdocs' if self.doctype == 'mkdocs' else 'sphinx'
self.error(
key,
'Your documentation type should match '
'the one from the admin panel of your project.',
'Your project is configured as "{doctype}" in your admin '
Copy link
Contributor

Choose a reason for hiding this comment

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

doctype here is the interpolation that could be displayed as sphinx_htmldir. key in this string can only be sphinx or mkdocs.

'dashboard, but there was a "{key}" key specified.'.format(
Copy link
Contributor

Choose a reason for hiding this comment

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

One last nitpick. The error is sort of inverted i feel -- we don't actually tell the user the they need a "sphinx" key, just that they can't have a "mkdocs" key. I feel we need to be clearer here, ie:

Your project is configured as "Sphinx" in your project admin dashboard, but there is no "sphinx" key specified.

Also, for some of the odd documentation types, it looks like we're putting the slug in there, so:

Your project is configured as "sphinx_htmldir" ...

I feel like we want the verbose name instead. This shouldn't be a huge change, just using the model field to resolve the verbose name, but if it is a large change, it's not horribly important. This piece is temporary and it's probably close enough for most users.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmm, I'm not sure about accessing the db from the config module (we don't do that there). I'm changing the error message.

doctype=dashboard_doctype,
key=key,
),
code=INVALID_KEYS_COMBINATION,
)

Expand Down
3 changes: 2 additions & 1 deletion readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,8 @@ def test_sphinx_builder_default(self):
build.validate()
build.sphinx.builder == 'sphinx'

@pytest.mark.skip
@pytest.mark.skip(
'This test is not compatible with the new validation around doctype.')
def test_sphinx_builder_ignores_default(self):
build = self.get_build_config(
{},
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/rtd_tests/tests/test_config_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ def test_sphinx_builder(

get_builder_class.assert_called_with(result)

@pytest.mark.skip
@pytest.mark.skip(
'This test is not compatible with the new validation around doctype.')
@patch('readthedocs.projects.tasks.get_builder_class')
def test_sphinx_builder_default(
self, get_builder_class, checkout_path, tmpdir):
Expand Down