-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Versions are sorted by ASCII rather than version or commit date #6010
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
Comments
Hi @davidism! We are aware of this already. We do sort the version using PEP440 (https://docs.readthedocs.io/en/stable/versions.html#how-we-envision-versions-working). Although, if the version does not follow this schema, it's ASCII sorted --as you found. In your case This issue was already reported at #5291 and there is an idea to track the commit date at #5649 I think that sorting by commit date won't work either, because your I'm not sure what's the best path to follow here. Naming docs versions with |
Hmm, I see what you mean with commit date. The way I handle sorting in the theme is a small wrapper that strips off a configured suffix first, so that they are valid sortable versions again. |
Maybe we can fallback to numerical sorting if the version does not follow the PEP440 scheme with one of these proposal solution: https://stackoverflow.com/questions/2574080/sorting-a-list-of-dot-separated-numbers-like-software-versions --what do you think? |
|
@humitos Are you proposing ripping out readthedocs.org/readthedocs/projects/version_handling.py Lines 15 to 39 in 4b38e82
natsort ? We could definitely test that. Alternatively, this does seem common enough where we could replace .x and call parse_version_failsafe again.
|
@davidfischer No. I'm "thinking aloud without looking at the code" that we could fallback to |
I put one possible solution into #6012. |
This is now shipped, let me know if it's resolved 👍 |
I checked https://jinja.palletsprojects.com/. 2.10.x sorts above 2.9.x, but now master sorts last. Looking at the PR, I'm not sure why, and when I was looking at the code initially I thought there was a special case for master, so I'm not sure what happened. |
@davidism you need to activate the master version that says "latest" |
Any chance since "latest" points to "master" that they both can sort higher? I've been deliberately using master so all docs versions would match branches, and it was sorting as expected before. #4672 is somewhat related to this choice, latest was fixed so that it wasn't reactivated on commits to master. |
Internally rtd creates a version named latest that points to master (that's how it gets sorted). You are using the plane version of master.
My guess, like the other branches (2.x), master was failing too, so it was being sorted by the ascii value I haven't tried this, but I think maybe you can still have master as latest. Can you try going to advanced settings and select master in |
Nope, that doesn't work. We should treat master and trunk (whatever master is in other VCS) like we do with latest, or show the real version name in the selector, not the slug |
Changing the slug to the real name is a big chance, I'm making a patch for the first option |
PR at #6049 |
@davidism master should be sorted first now |
Awesome, thanks! |
Details
Expected Result
During the build and in the rendered docs popup, versions are sorted in version order, newest to oldest. Baring that, since slugs might not be valid versions (2.10.1 vs 2.10.x), version slugs should be sorted by commit date.
Actual Result
Versions are ASCII sorted, so 2.9.x ends up greater than 2.10.x.
When building Jinja's docs, Pallets-Sphinx-Themes examines
html_context["versions"]
andhtml_context["current_version"]
, injected by RTD, to show a banner at the top of the page. This worked fine for our previous projects, like Flask, which had versions 1.0.x and 1.1.x. However, Jinja has 2.9.x and 2.10.x, and it became apparent that RTD was sorting these in ASCII order, which becomes inconsistent across ones and tens digits. This is problematic because we were relying on RTD to report versions in a consistent newest to oldest order.This shows up in
html_context["versions"]
:And in the versions popup:
Compare to Flask's version popup:
The order is not consistent with version or commit date ordering.
The text was updated successfully, but these errors were encountered: