From 1c5b771feb55ef2a5eb67690e7c40c7e83be6006 Mon Sep 17 00:00:00 2001 From: Abhijeet More Date: Mon, 4 Aug 2025 21:49:55 +0530 Subject: [PATCH 1/2] fix(build): raise clear error if mkdocs.yml config file is missing --- readthedocs/doc_builder/backends/mkdocs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 36f2e1e5d6f..2a7212ca71c 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -14,6 +14,8 @@ from readthedocs.doc_builder.base import BaseBuilder from readthedocs.projects.constants import MKDOCS from readthedocs.projects.constants import MKDOCS_HTML +from readthedocs.doc_builder.exceptions import BuildUserError + log = structlog.get_logger(__name__) @@ -99,6 +101,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( From 364220e18877fd21b0a5555d759d3ffdea9026eb Mon Sep 17 00:00:00 2001 From: RabbitAlbatross <143070183+RabbitAlbatross@users.noreply.github.com> Date: Tue, 5 Aug 2025 12:19:29 +0530 Subject: [PATCH 2/2] fix import order to satisfy Ruff --- readthedocs/doc_builder/backends/mkdocs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 2a7212ca71c..52183e40c63 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -5,16 +5,15 @@ """ 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 -from readthedocs.doc_builder.exceptions import BuildUserError +