diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 36f2e1e5d6f..52183e40c63 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -5,17 +5,18 @@ """ import os - import structlog -import yaml from django.conf import settings from readthedocs.core.utils.filesystem import safe_open from readthedocs.doc_builder.base import BaseBuilder +from readthedocs.doc_builder.exceptions import BuildUserError from readthedocs.projects.constants import MKDOCS from readthedocs.projects.constants import MKDOCS_HTML + + log = structlog.get_logger(__name__) @@ -99,6 +100,13 @@ def build(self): "--config-file", os.path.relpath(self.yaml_file, self.project_path), ] + + if not os.path.exists(self.yaml_file): + raise BuildUserError( + f"MkDocs configuration file is missing — we could not find a 'mkdocs.yml' file at {self.yaml_file}. " + "Please make sure your repository includes one and try again." + ) + if self.config.mkdocs.fail_on_warning: build_command.append("--strict") cmd_ret = self.run(