-
-
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
Improve displayed version name when building from PR #8237
Improve displayed version name when building from PR #8237
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.
Hi, thanks for the PR, we depend on the verbose_name being the identifier in a few places, changing this means we need to change a couple of other places that depend on this.
This can be a bit confusing, specially for new projects, because the PR numbers will be in the same range as possibly existing versions.
Do you have examples of projects that use just a number for versions? I think most projects use semver 1.x
instead of just 1
.
Where do you find showing the number confusing? I think we always put the number close to the text "Pull request #xxx".
Thank you very much for the review @stsewd . Could you point me out which other places the verbose_name is being used to identify the PR so I can also have a look and maybe improve? Of course if it is very complicated, please feel free to close this PR, in the end it is a matter of minor experience improvement. Unfortunately the whole setup for developing, specially when involving PRs was quite cumbersome for me, so I ended up just relying on the test suite. The place I found it confusing was the version switch menu. The version shows up as a number (let's say After some thought we can figure it out due to the sequence continuity, but I think making it more explicit would be a nice improvement. |
I see, then I think we should implement that logic in our footer to make it more explicit that the version is the PR/MR identifier. Maybe something like |
That makes a lot of sense to me. Is this string used in the footer the same as the one being set to Personally, I used the Maybe if you point me in the right direction I could try to contribute with that? This was me first interaction with the code base, so not very sure on how to tackle this. |
That env var is the slug of the version, not the name to be displayed, so we can't change that to include other text. readthedocs.org/readthedocs/projects/tasks.py Lines 326 to 334 in a91bd99
I think we can add a new env var like The footer can be changed here readthedocs.org/readthedocs/api/v2/templates/restapi/footer.html Lines 41 to 46 in a91bd99
There you would need to check if the version is external readthedocs.org/readthedocs/builds/models.py Lines 900 to 906 in a91bd99
and add the prefix/suffix. If you want to check your changes locally, you can check our docs at https://docs.readthedocs.io/en/stable/development/install.html |
f228147
to
afc75f7
Compare
Thank you very much for the tips @stsewd. I have rewritten the PR to reflect the discussion in the comments. |
afc75f7
to
4f7d853
Compare
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.
Thanks for working on this!
4f7d853
to
a9ecaa7
Compare
Thank you very much for the review and suggestions @stsewd, I submitted a new commit rebasing the new state of the master an adopting the changes you have described. Regarding I suppose the layouts for the RTD theme and the floating menu for the other themes handle well long version names, right? For example this PR would have a name |
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.
Thanks! Looks good for me! /cc @readthedocs/core
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 seems like a good change, but I'm a bit worried about the extension of the build context -- we are trying to move more away from using that data without it being a nicer UX. Why was that necessary for this PR?
<dd {% if version.verbose_name == current_version %} class="rtd-current-item" {% endif %}> | ||
<a href="{{ version.get_subdomain_url }}{{ path|default_if_none:"" }}">{{ version.slug }}</a> | ||
<dd {% if version == current_version %} class="rtd-current-item" {% endif %}> | ||
<a href="{{ version.get_subdomain_url }}{{ path|default_if_none:"" }}">{{ version.explicit_name }}</a> |
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 don't think this is needed -- we will never show a PR build in this list. The slug is what will be shown in the URL, so I think we want the slug?
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 were showhing the name for the current version, and the slug for the other versions, I think it makes sense showing the verbose name as this is how versions are originally named.
readthedocs/builds/models.py
Outdated
""" | ||
external_origin = external_version_name(self) | ||
|
||
if not external_origin: |
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 check for if not self.type == EXTERNAL
here or similar -- it's cleaner than depending on the side effects of another function.
a9ecaa7
to
967776a
Compare
Thank you very much for the review @ericholscher. I rebased the PR to master and added some changes to address some parts of your comments. Regarding your comment:
I am not exactly sure if I understand it. What would it be the build context? Also not sure what it would mean to have "data without it being a nicer UX"... Sorry for that (it seems that you guys are used to some terms when talking about the project, but for me as an external contributor it is a bit difficult to understand). |
Any update on this? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@ericholscher can you take another look at this PR? It looks like a good addition but you have made some comments regarding the environment variable and build context. After a quick read of the comments, I think I'm fine adding the environment variable but not into the HTML context. |
docs/webhooks.rst
Outdated
and mark **Branch or tag creation**, **Branch or tag deletion** and **Pushes** events. | ||
If you want to use Read the Docs to :doc:`preview documentation changes from pull | ||
requests </pull-requests>`, also mark **Pull requests** events. |
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.
and mark **Branch or tag creation**, **Branch or tag deletion** and **Pushes** events. | |
If you want to use Read the Docs to :doc:`preview documentation changes from pull | |
requests </pull-requests>`, also mark **Pull requests** events. | |
and mark **Branch or tag creation**, **Branch or tag deletion**, **Pushes** and **Pull requests** events. |
I think it's better to just mark those without too many explanations. Otherwise, people will need to modify the webhook if they want that feature later.
Agreed. I think ENV vars are fine, but in some ways we're just changing around where the data is coming from. I don't want to keep adding things there without a bit of thought either on namespacing at least. I'm 👍 on exposing this data though if there isn't a good way to get it currently. |
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 re-review this PR and I think it's good to be merged. I left just small improvements that should be easy to adjust.
@abravalheri do you have the time to update this PR so we can merge it?
docs/builds.rst
Outdated
- If ``READTHEDOCS_VERSION_TYPE`` is ``external``, | ||
it means that the version was built from pull request. See :doc:`/pull-requests`. |
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'd say to move this text to the description of the variable itself instead of in a note. After that, we remove the bullets and keep just the initial paragraph of the note which is great.
The version switch menu in RTD currently uses `version.slug` to display the name of the versions. For external versions coming from PRs that corresponds to a simple integer number. For example, let's consider a project have 3 existing "regular versions": v0.1, v1 and v2. In the 3rd PR submitted to GitHub, a version with slug '3' would be created, which would result in the version switch menu containing something like: v0.1, v1, v2, 3. This can be slightly confusing, since it is trick to differentiate between regular branches/tags used for versions and PR numbers, specially when the project is starting. This commit adds `explicit_external_name` and `explicit_name` to the version model and uses them in the footer template to try to make a more clear differentiation between regular builds and builds triggered by PRs.
These variables make it easy for configuration scripts to differentiate between regular builds and builds triggered by PRs. Moreover, they are quite handy to setting up `html_title` in a way that matches the version being displayed in the RTD's version switch menu.
967776a
to
483182c
Compare
Hi @humitos, thank you very much for the latest reviews. I can see that the I can add another commit adding the automatic changes suggested by |
Yeah, this is unfortunate because we are in the process of "blackify" the whole codebase starting only with the files touched by each PR. I just checked running The PR is already reviewed and I'd say it's ready to be merged. In any case, we can skip that particular commit if we want to re-re-re-view it again 😄 --but I don't think it will be needed. I'm sorry for all the time and work this took to you and thanks for it. |
Perfect, I just submitted 2eab243 with the changes automatically generated by pre-commit. I got the configuration file from https://github.com/readthedocs/common/blob/main/pre-commit-config.yaml Hopefully that will be enough to fix the problems in the CI and not cause any unrelated error 😅 🤞. |
Pass `READTHEDOCS_VERSION_TYPE` and `READTHEDOCS_VERSION_NAME` that were missed because a merge conflict. These variables were added in #8237
It looks like at least part of this functionality was (inadvertently?) reverted when #9002 was merged. Was that intentional? I'll open up a separate issue for this, but wanted to mention this on the PR where this functionality was introduced. |
This should now be fixed, please let me know if it isn't. |
Hello RTD maintainers and thank you very much for the tool, it is really amazing.
This PR is actually an improvement suggestion:
Currently, the displayed version in the case of builds originated from pull requests is simply a plain integer corresponding to the PR number in GitHub/GitLab. This can be a bit confusing, specially for new projects, because the PR numbers will be in the same range as possibly existing versions.
Therefore the idea is to make it more explicit when building from PRs by adding a
PR-
prefix to the PR number (orMR-
in the case of GitLab).A few notes:
pre-commit
when I tried to rungit commit
. These format changes are not part of the original idea and not necessary to it. To facilitate distinguishing between the actual suggestion and the automatic changes I tried to split them into 2 separated commits (the second commit in this PR being the one corresponding to the changes created bypre-commit
). There is one exception though regarding statements starting withif all([
, which I had to manually tweak after the automatic code formatter, because the result was too weird and increased the number of errors/warnings returned by the linter.tox -e lint
there are a few error messages corresponding to pre-existent codetox
, there are a few failing tests that seem to be uncorrelated to the introduced changes. In fact, by checking other open PRs I can see that the same tests are failing elsewhere (for example here). They seem to be related to a change in API urls (or at least to the way they are being tested):~PR-#2
or~MR-#2
(with the prefix being"~PR-#"
/"~MR-#"
;~
is an invalid branch name character). However, since I don't know how the remaining of the RTD system would deal with these unconventional characters (maybe it is validated somewhere), I decided do simply leave it as"PR-"
/"MR-"
. Please let me know if the original idea is safe and you would prefer it that way.