Skip to content

fix(build): raise clear error if mkdocs.yml config file is missing #12378

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions readthedocs/doc_builder/backends/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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."
)
Comment on lines +104 to +108
Copy link
Member

Choose a reason for hiding this comment

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

We should follow the same approach we use for Sphinx. See an example at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/doc_builder/backends/sphinx.py#L112-L113


if self.config.mkdocs.fail_on_warning:
build_command.append("--strict")
cmd_ret = self.run(
Expand Down