-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Validate docs dir before writing custom js #5569
Conversation
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 need to put the check in
similar to the other ones there
readthedocs/doc_builder/base.py
Outdated
if not os.path.exists(possible_path): | ||
raise MkDocsYAMLParseError( | ||
MkDocsYAMLParseError.INVALID_DOCS_DIR_PATH, | ||
) |
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 shouldn't put special cases in the base class, the base class should know nothing about mkdocs.
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.
Got it :)
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.
@stsewd Updated the PR
# if user puts an invalid `docs_dir` path raise an Exception | ||
if user_docs_dir: | ||
checkout_path = self.project.checkout_path(self.version.slug) | ||
possible_path = os.path.join(checkout_path, user_docs_dir) |
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 actually need to check if this path doesn't exists https://github.com/rtfd/readthedocs.org/blob/4fea14e86fe0aabffd73352402ddf8dbba39ff40/readthedocs/doc_builder/backends/mkdocs.py#L159-L162
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.
Oh! you meant docs_path
I thought you meant the docs_dir
which user adds in the yaml. okay I'll Update the PR.
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.
Just to be clear, it is the one the users put in the mkdocs.yml file
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.
But the docs dir is relative to the mkdocs.yml file, which can be located in other places not jus in the root
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.
@stsewd Thanks for the explanation. 👍
) | ||
with self.assertRaises(MkDocsYAMLParseError): | ||
self.searchbuilder.append_conf() | ||
generate_rtd_data.assert_called_with( |
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.
I guess we don't need this assert
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.
@stsewd then how should we check if invalid docs_path
raises an error or not?
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.
Yes, we only need that check. The second assert wouldn't happen anyway.
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.
yes that's True. 👍 updated the PR.
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.
Looks good to me, I left to someone else the review of the copy
closes #5568