Skip to content

Refactor sitemap sort order #5475

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions readthedocs/projects/version_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def comparable_version(version_string):
"""
Can be used as ``key`` argument to ``sorted``.

The ``LATEST`` version shall always beat other versions in comparison.
``STABLE`` should be listed second. If we cannot figure out the version
The ``STABLE`` version shall always beat other versions in comparison.
``LATEST`` should be listed second. If we cannot figure out the version
number then we sort it to the bottom of the list.

:param version_string: version as string object (e.g. '3.10.1' or 'latest')
Expand All @@ -56,9 +56,9 @@ def comparable_version(version_string):
"""
comparable = parse_version_failsafe(version_string)
if not comparable:
if version_string == LATEST_VERBOSE_NAME:
if version_string == STABLE_VERBOSE_NAME:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we should do it like this because -

https://github.com/rtfd/readthedocs.org/blob/93bd03b4a8ed42c3a0b3633f114f21a0eac9ea11/readthedocs/projects/templatetags/projects_tags.py#L13-L20

is using comparable_version and changing this means that the order in which versions are rendered everywhere will get disturbed. #5157.

comparable = Version('99999.0')
elif version_string == STABLE_VERBOSE_NAME:
elif version_string == LATEST_VERBOSE_NAME:
comparable = Version('9999.0')
else:
comparable = Version('0.01')
Expand All @@ -72,7 +72,7 @@ def sort_versions(version_list):
:param version_list: list of Version models
:type version_list: list(readthedocs.builds.models.Version)

:returns: sorted list in descending order (latest version first) of versions
:returns: sorted list in descending order (stable version first) of versions

:rtype: list(tupe(readthedocs.builds.models.Version,
packaging.version.Version))
Expand Down