Skip to content

Commit

Permalink
Remove dead code from old footer (#11854)
Browse files Browse the repository at this point in the history
Ref #11836
  • Loading branch information
stsewd authored Dec 17, 2024
1 parent e9316be commit 15c9baa
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 394 deletions.
118 changes: 0 additions & 118 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@
from readthedocs.notifications.models import Notification
from readthedocs.projects.constants import (
BITBUCKET_COMMIT_URL,
BITBUCKET_URL,
DOCTYPE_CHOICES,
GITHUB_COMMIT_URL,
GITHUB_PULL_REQUEST_COMMIT_URL,
GITHUB_URL,
GITLAB_COMMIT_URL,
GITLAB_MERGE_REQUEST_COMMIT_URL,
GITLAB_URL,
MEDIA_TYPES,
MKDOCS,
MKDOCS_HTML,
Expand Down Expand Up @@ -550,121 +547,6 @@ def get_storage_paths(self):

return paths

def get_github_url(
self,
docroot,
filename,
source_suffix=".rst",
action="view",
):
"""
Return a GitHub URL for a given filename.
:param docroot: Location of documentation in repository
:param filename: Name of file
:param source_suffix: File suffix of documentation format
:param action: `view` (default) or `edit`
"""
repo_url = self.project.repo
if "github" not in repo_url:
return ""

if not docroot:
return ""

# Normalize /docroot/
docroot = "/" + docroot.strip("/") + "/"

if action == "view":
action_string = "blob"
elif action == "edit":
action_string = "edit"

user, repo = get_github_username_repo(repo_url)
if not user and not repo:
return ""

if not filename:
# If there isn't a filename, we don't need a suffix
source_suffix = ""

return GITHUB_URL.format(
user=user,
repo=repo,
version=self.commit_name,
docroot=docroot,
path=filename,
source_suffix=source_suffix,
action=action_string,
)

def get_gitlab_url(
self,
docroot,
filename,
source_suffix=".rst",
action="view",
):
repo_url = self.project.repo
if "gitlab" not in repo_url:
return ""

if not docroot:
return ""

# Normalize /docroot/
docroot = "/" + docroot.strip("/") + "/"

if action == "view":
action_string = "blob"
elif action == "edit":
action_string = "edit"

user, repo = get_gitlab_username_repo(repo_url)
if not user and not repo:
return ""

if not filename:
# If there isn't a filename, we don't need a suffix
source_suffix = ""

return GITLAB_URL.format(
user=user,
repo=repo,
version=self.commit_name,
docroot=docroot,
path=filename,
source_suffix=source_suffix,
action=action_string,
)

def get_bitbucket_url(self, docroot, filename, source_suffix=".rst"):
repo_url = self.project.repo
if "bitbucket" not in repo_url:
return ""
if not docroot:
return ""

# Normalize /docroot/
docroot = "/" + docroot.strip("/") + "/"

user, repo = get_bitbucket_username_repo(repo_url)
if not user and not repo:
return ""

if not filename:
# If there isn't a filename, we don't need a suffix
source_suffix = ""

return BITBUCKET_URL.format(
user=user,
repo=repo,
version=self.commit_name,
docroot=docroot,
path=filename,
source_suffix=source_suffix,
)


class APIVersion(Version):

Expand Down
11 changes: 0 additions & 11 deletions readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,23 +371,12 @@
re.compile(r"gitlab.com/(.+)/(.+)"),
re.compile(r"gitlab.com:(.+)/(.+)\.git$"),
]
GITHUB_URL = (
"https://github.com/{user}/{repo}/"
"{action}/{version}{docroot}{path}{source_suffix}"
)
GITHUB_COMMIT_URL = "https://github.com/{user}/{repo}/commit/{commit}"
GITHUB_PULL_REQUEST_URL = "https://github.com/{user}/{repo}/pull/{number}"
GITHUB_PULL_REQUEST_COMMIT_URL = (
"https://github.com/{user}/{repo}/pull/{number}/commits/{commit}"
)
BITBUCKET_URL = (
"https://bitbucket.org/{user}/{repo}/src/{version}{docroot}{path}{source_suffix}"
)
BITBUCKET_COMMIT_URL = "https://bitbucket.org/{user}/{repo}/commits/{commit}"
GITLAB_URL = (
"https://gitlab.com/{user}/{repo}/"
"{action}/{version}{docroot}{path}{source_suffix}"
)
GITLAB_COMMIT_URL = "https://gitlab.com/{user}/{repo}/commit/{commit}"
GITLAB_MERGE_REQUEST_COMMIT_URL = (
"https://gitlab.com/{user}/{repo}/commit/{commit}?merge_request_iid={number}"
Expand Down
39 changes: 0 additions & 39 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.db.models import Prefetch
from django.urls import reverse
from django.utils import timezone
from django.utils.crypto import get_random_string
Expand Down Expand Up @@ -47,7 +46,6 @@
ProjectQuerySet,
RelatedProjectQuerySet,
)
from readthedocs.projects.templatetags.projects_tags import sort_version_aware
from readthedocs.projects.validators import (
validate_build_config_file,
validate_custom_prefix,
Expand Down Expand Up @@ -1079,43 +1077,6 @@ def active_versions(self):
active=True, uploaded=True
)

def ordered_active_versions(self, **kwargs):
"""
Get all active versions, sorted.
:param kwargs: All kwargs are passed down to the
`Version.internal.public` queryset.
"""
from readthedocs.builds.models import Version

kwargs.update(
{
"project": self,
"only_active": True,
"only_built": True,
},
)
versions = (
Version.internal.public(**kwargs)
.select_related(
"project",
"project__main_language_project",
)
.prefetch_related(
Prefetch(
"project__superprojects",
ProjectRelationship.objects.all().select_related("parent"),
to_attr="_superprojects",
),
Prefetch(
"project__domains",
Domain.objects.filter(canonical=True),
to_attr="_canonical_domains",
),
)
)
return sort_version_aware(versions)

def all_active_versions(self):
"""
Get queryset with all active versions.
Expand Down
12 changes: 0 additions & 12 deletions readthedocs/projects/version_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,6 @@ def sort_versions(version_list):
return versions


def highest_version(version_list):
"""
Return the highest version for a given ``version_list``.
:rtype: tupe(readthedocs.builds.models.Version, packaging.version.Version)
"""
versions = sort_versions(version_list)
if versions:
return versions[0]
return (None, None)


def determine_stable_version(version_list):
"""
Determine a stable version for version list.
Expand Down
3 changes: 0 additions & 3 deletions readthedocs/rtd_tests/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ def test_get_storage_path_for_external_versions(self):
"external/htmlzip/pip/99/pip.zip",
)

def test_ordered_active_versions_excludes_external_versions(self):
self.assertNotIn(self.external_version, self.pip.ordered_active_versions())

def test_active_versions_excludes_external_versions(self):
self.assertNotIn(self.external_version, self.pip.active_versions())

Expand Down
Loading

0 comments on commit 15c9baa

Please sign in to comment.