-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
base: main
Are you sure you want to change the base?
fix(build): raise clear error if mkdocs.yml config file is missing #12378
Conversation
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." | ||
) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. sorry for being so late.
Sorry for being so late.
Documentation build overview
Show files changed (9 files in total): 📝 9 modified | ➕ 0 added | ➖ 0 deleted
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going in a good direction. We just need to create a specific message for MkDocs.
added MKDOCS_NOT_FOUND constant to ProjectConfigurationError
added MkDocs notification for missing mkdocs.yml
raise MKDOCS_NOT_FOUND when mkdocs.yml is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moving in the right direction! 💪🏼
I left some comments about how to follow the pattern we already have for Sphinx.
if not os.path.exists(self.yaml_file): | ||
raise ProjectConfigurationError(ProjectConfigurationError.MKDOCS_NOT_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this here.
|
||
if not os.path.exists(self.yaml_file): | ||
raise ProjectConfigurationError(ProjectConfigurationError.NOT_FOUND) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, move this code to show_config
following the same pattern we are using for Sphinx. Take a look at its code at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/doc_builder/backends/sphinx.py#L110-L124
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
Removed the unneeded block
All requested changes added
Small error in the import fix
small fix
typos and stuff sorry
tests: add missing mkdocs config files Created required mkdocs.yml files in tests to fix failures caused by new file validation in show_conf() method.
Fixing test failures by creating actual mkdocs.yml files in tests that mock MkDocs configurations. The new file existence validation in show_conf() requires these files to exist for builds to proceed.
Ready for a review |
fixing to adhere to pre-commit checks
Pre-commit adherence
precommit fixes
pre-commit adherence
pre-commit fixes
pre-commit fixes
I don't follow the new changes you've done. It touches a few files that we haven't discussed and I don't understand why. The PR was pretty close, so I went ahead and opened a new one with the missing changes at #12521 |
I'm sorry. It wasn't passing the tests so I ended up getting carried away trying to fix it. |
When the MkDocs configuration file is missing, the build currently fails with an "Unknown error" message. This change raises a clearer and more helpful
BuildUserError
if themkdocs.yml
file is not found, similar to how Sphinx errors are handled.Closes #11937