-
-
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
Show proper error to user when conf.py is not found #3326
Conversation
c488a9f
to
6ba42b3
Compare
I added a couple of tests for old behaviour and also to catch this PR behaviour. Besides, I added the exception message as a class attribute. Please, re-review this PR when you have some time. (the last commit is styling, so you can skip it from the logic review) |
readthedocs/projects/exceptions.py
Outdated
"There are more than one conf.py file and none of them say doc " | ||
"in their path, we don't know which one use. Please, select " | ||
"the correct one under the Advanced settings tab in the " | ||
"project's Admin." |
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 probably provide a link here.
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.
Do we support HTML content on the message exception? I think no.
For example, we are not using | safe
filter at https://github.com/rtfd/readthedocs.org/blob/bb7bb4d6751ecce67ba274a32100406b951f9b90/readthedocs/templates/builds/build_detail.html#L156
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.
Would make for a better UX, perhaps as an idea in the future. We could also add it as a "build tip"
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.
Following with your idea, I'd say that the error is OK but this could be mixed with what you have done for setup.py install
and other cases.
I think we should create a "Build tip" concept that checks for this type of errors and show a user friendly-shiny message with links and more.
So, in this particular case, for example, I'd rewrite the exception message to something like:
There are more than one conf.py file and we don't know which one use.
Then, a "Build tip" saying:
Please, select the correct one under the Advanced Settings (link) tab in the project's Admin or re-structure your project to have a
docs
folder with theconf.py
inside 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.
I like that idea. I think we need to firm up our usage around build tips and not do the logic in the template though.
raise ProjectConfigurationError( | ||
ProjectConfigurationError.MULTIPLE_CONF_FILES | ||
) | ||
|
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 feel like we keep changing build logic that breaks people's build. Is there a reason we are wanting to fail builds on this, instead of warning users? I think we probably want to warn them in this case, because changing this logic could easily break hundreds of project's builds for no real reason.
We did this with the setup.py install
failures, and I don't think it's a good pattern to follow.
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 didn't change the logic here. I just added a better message.
Before this PR, it said "Conf.py not found" but there were more than one conf.py
file. Now, it will fail as it was failing before but saying "Hey, too many conf.py files. We don't know which one to pick"
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.
hmm, interesting.
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 great! 👍 on more tests here.
I noted a copy change, but this looks good otherwise. Let's keep thinking about how to best surface build suggestions, as I think this is a good pattern so far. I'll open a separate ticket to start discussing how to better implement the build changes, as I think too much logic is being hidden in templates currently.
readthedocs/projects/exceptions.py
Outdated
'There are more than one conf.py file and none of them say doc ' | ||
"in their path, we don't know which one use. Please, select " | ||
'the correct one under the Advanced settings tab in the ' | ||
"project's Admin." |
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.
A few notes on copy here:
- More clarity around why this is a problem is good -- that is: "We found more than one conf.py and are not sure which one to use." instead of mentioning
docs/
- "Please, select the correct one" -> "Please specify the correct file"
readthedocs/projects/exceptions.py
Outdated
"There are more than one conf.py file and none of them say doc " | ||
"in their path, we don't know which one use. Please, select " | ||
"the correct one under the Advanced settings tab in the " | ||
"project's Admin." |
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 like that idea. I think we need to firm up our usage around build tips and not do the logic in the template though.
ee1bbde
to
30b908e
Compare
This PR should be ready to merge. The linting error is unrelated.
I didn't find why it's failing yet. |
@@ -171,8 +172,8 @@ class Project(models.Model): | |||
|
|||
# Other model data. | |||
path = models.CharField(_('Path'), max_length=255, editable=False, |
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.
In some parts the function call is in this way
func(arg1,
arg2)
and other parts like this
func(
arg1,
arg2)
Which style is the correct?
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.
The second one, but with a trailing comma and the ´)´ in the folowing line is closer to what we want. Like this
func(
arg1,
arg2,
)
but we use this only when it doesn't fit in 80 columns.
We have a style guide for this: http://docs.readthedocs.io/en/latest/contribute.html?highlight=contributing#contributing-to-development
We are using pre-commit
command that runs a couple of scripts to apply the proper style to the code.
The linting error on this PR is solved in #3408 |
30b908e
to
21d63bb
Compare
I think this PR is read to merge. Can you review it again, please? |
I'm using BuildEnvironmentError for now, but we should use
ProjectConfigurationError once the PR got merged: #3310
Closes #2963