Skip to content

Commit bf4c8ab

Browse files
committed
feat: Improve error message for missing mkdocs.yml
1 parent acaf4e0 commit bf4c8ab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from readthedocs.doc_builder.base import BaseBuilder
1515
from readthedocs.projects.constants import MKDOCS
1616
from readthedocs.projects.constants import MKDOCS_HTML
17+
from readthedocs.projects.exceptions import UserFileNotFound
1718

1819

1920
log = structlog.get_logger(__name__)
@@ -52,7 +53,12 @@ def get_final_doctype(self):
5253
5354
https://www.mkdocs.org/user-guide/configuration/#use_directory_urls
5455
"""
55-
56+
# Check if the mkdocs.yml file exists before trying to open it.
57+
if not os.path.exists(self.yaml_file):
58+
raise UserFileNotFound(
59+
"MkDocs configuration file is missing. "
60+
"A configuration file named `mkdocs.yml` was not found in your repository."
61+
)
5662
# TODO: we should eventually remove this method completely and stop
5763
# relying on "loading the `mkdocs.yml` file in a safe way just to know
5864
# if it's a MKDOCS or MKDOCS_HTML documentation type".

0 commit comments

Comments
 (0)