Skip to content

Commit 762a272

Browse files
committed
Merge branch 'master' of github.com:readthedocs/readthedocs.org into humitos/build-jobs-config
2 parents 440ddc5 + 5179dc4 commit 762a272

File tree

18 files changed

+161
-68
lines changed

18 files changed

+161
-68
lines changed

.circleci/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: 2.1
22

3+
orbs:
4+
codecov: codecov/[email protected]
5+
36
jobs:
47
tests:
58
docker:
@@ -16,7 +19,8 @@ jobs:
1619
- run: git submodule sync
1720
- run: git submodule update --init
1821
- run: pip install --user tox
19-
- run: tox -e py38,codecov
22+
- run: tox -e py38
23+
- codecov/upload
2024

2125
tests-embedapi:
2226
docker:

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Version 7.4.2
2+
-------------
3+
4+
:Date: March 14, 2022
5+
6+
* `@stsewd <https://github.com/stsewd>`__: CI: fix codecov again (`#9007 <https://github.com/readthedocs/readthedocs.org/pull/9007>`__)
7+
* `@stsewd <https://github.com/stsewd>`__: CI: fix codecov (`#9006 <https://github.com/readthedocs/readthedocs.org/pull/9006>`__)
8+
* `@agjohnson <https://github.com/agjohnson>`__: Release 7.4.1 (`#9004 <https://github.com/readthedocs/readthedocs.org/pull/9004>`__)
9+
* `@pyup-bot <https://github.com/pyup-bot>`__: pyup: Scheduled weekly dependency update for week 10 (`#9003 <https://github.com/readthedocs/readthedocs.org/pull/9003>`__)
10+
* `@humitos <https://github.com/humitos>`__: Upgrade common submodule (`#9001 <https://github.com/readthedocs/readthedocs.org/pull/9001>`__)
11+
* `@humitos <https://github.com/humitos>`__: Build: `RepositoryError` message (`#8999 <https://github.com/readthedocs/readthedocs.org/pull/8999>`__)
12+
* `@stsewd <https://github.com/stsewd>`__: Search: fix integration with latest sphinx (`#8994 <https://github.com/readthedocs/readthedocs.org/pull/8994>`__)
13+
* `@humitos <https://github.com/humitos>`__: API: validate `RemoteRepository` when creating a `Project` (`#8983 <https://github.com/readthedocs/readthedocs.org/pull/8983>`__)
14+
* `@stsewd <https://github.com/stsewd>`__: Tests: fix mock.patch order (`#8909 <https://github.com/readthedocs/readthedocs.org/pull/8909>`__)
15+
* `@humitos <https://github.com/humitos>`__: Celery: remove queue priority (`#8848 <https://github.com/readthedocs/readthedocs.org/pull/8848>`__)
16+
* `@dogukanteber <https://github.com/dogukanteber>`__: Use django-storages' manifest files class instead of the overriden class (`#8781 <https://github.com/readthedocs/readthedocs.org/pull/8781>`__)
17+
* `@abravalheri <https://github.com/abravalheri>`__: Improve displayed version name when building from PR (`#8237 <https://github.com/readthedocs/readthedocs.org/pull/8237>`__)
18+
119
Version 7.4.1
220
-------------
321

docs/user/builds.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,17 @@ The *Sphinx* and *Mkdocs* builders set the following RTD-specific environment va
8080
:widths: 15, 10, 30
8181

8282
``READTHEDOCS``, Whether the build is running inside RTD, ``True``
83-
``READTHEDOCS_VERSION``, The RTD name of the version which is being built, ``latest``
83+
``READTHEDOCS_VERSION``, The RTD slug of the version which is being built, ``latest``
84+
``READTHEDOCS_VERSION_NAME``, Corresponding version name as displayed in RTD's version switch menu, ``stable``
85+
``READTHEDOCS_VERSION_TYPE``, Type of the event triggering the build, ``branch`` | ``tag`` | ``external`` (for :doc:`pull request builds </pull-requests>`) | ``unknown``
8486
``READTHEDOCS_PROJECT``, The RTD slug of the project which is being built, ``my-example-project``
8587
``READTHEDOCS_LANGUAGE``, The RTD language slug of the project which is being built, ``en``
8688

89+
.. note::
90+
91+
The term slug is used to refer to a unique string across projects/versions containing ASCII characters only.
92+
This value is used in the URLs of your documentation.
93+
8794

8895
.. tip::
8996

readthedocs/api/v2/templates/restapi/footer.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="rst-versions rst-badge" data-toggle="rst-versions">
77
<span class="rst-current-version" data-toggle="rst-current-version">
88
<span class="fa fa-book">&nbsp;</span>
9-
v: {{ current_version }}
9+
v: {{ current_version.explicit_name }}
1010
<span class="fa fa-caret-down"></span>
1111
</span>
1212
<div class="rst-other-versions">
@@ -18,7 +18,7 @@
1818
<dt>{% trans "Languages" %}</dt>
1919

2020
{# Output the main project language since it isn't included in translations list #}
21-
21+
2222
<dd {% if main_project.language == current_language %} class="rtd-current-item" {% endif %}>
2323
<a href="{{ main_project.get_docs_url }}{{ path }}">{{ main_project.language }}</a>
2424
</dd>
@@ -41,8 +41,8 @@
4141
<dl>
4242
<dt>{% trans "Versions" %}</dt>
4343
{% for version in versions %}
44-
<dd {% if version.verbose_name == current_version %} class="rtd-current-item" {% endif %}>
45-
<a href="{{ version.get_subdomain_url }}{{ path|default_if_none:"" }}">{{ version.slug }}</a>
44+
<dd {% if version == current_version %} class="rtd-current-item" {% endif %}>
45+
<a href="{{ version.get_subdomain_url }}{{ path|default_if_none:"" }}">{{ version.verbose_name }}</a>
4646
</dd>
4747
{% endfor %}
4848
</dl>

readthedocs/api/v2/views/footer_views.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Endpoint to generate footer HTML."""
22

3-
import structlog
43
import re
54
from functools import lru_cache
65

6+
import structlog
77
from django.conf import settings
88
from django.shortcuts import get_object_or_404
99
from django.template import loader as template_loader
@@ -162,18 +162,18 @@ def _get_context(self):
162162
path = page_slug + '.html'
163163

164164
context = {
165-
'project': project,
166-
'version': version,
167-
'path': path,
168-
'downloads': version.get_downloads(pretty=True),
169-
'current_version': version.verbose_name,
170-
'versions': self._get_active_versions_sorted(),
171-
'main_project': main_project,
172-
'translations': main_project.translations.all(),
173-
'current_language': project.language,
174-
'new_theme': new_theme,
175-
'settings': settings,
176-
'github_edit_url': version.get_github_url(
165+
"project": project,
166+
"version": version,
167+
"path": path,
168+
"downloads": version.get_downloads(pretty=True),
169+
"current_version": version,
170+
"versions": self._get_active_versions_sorted(),
171+
"main_project": main_project,
172+
"translations": main_project.translations.all(),
173+
"current_language": project.language,
174+
"new_theme": new_theme,
175+
"settings": settings,
176+
"github_edit_url": version.get_github_url(
177177
docroot,
178178
page_slug,
179179
source_suffix,

readthedocs/builds/models.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
from django.utils import timezone
1515
from django.utils.translation import gettext
1616
from django.utils.translation import gettext_lazy as _
17-
from django_extensions.db.fields import (
18-
CreationDateTimeField,
19-
ModificationDateTimeField,
20-
)
17+
from django_extensions.db.fields import CreationDateTimeField, ModificationDateTimeField
2118
from django_extensions.db.models import TimeStampedModel
2219
from polymorphic.models import PolymorphicModel
2320

@@ -30,9 +27,6 @@
3027
BUILD_STATUS_CHOICES,
3128
BUILD_TYPES,
3229
EXTERNAL,
33-
GENERIC_EXTERNAL_VERSION_NAME,
34-
GITHUB_EXTERNAL_VERSION_NAME,
35-
GITLAB_EXTERNAL_VERSION_NAME,
3630
INTERNAL,
3731
LATEST,
3832
NON_REPOSITORY_VERSIONS,
@@ -57,6 +51,7 @@
5751
VersionQuerySet,
5852
)
5953
from readthedocs.builds.utils import (
54+
external_version_name,
6055
get_bitbucket_username_repo,
6156
get_github_username_repo,
6257
get_gitlab_username_repo,
@@ -211,6 +206,27 @@ def is_private(self):
211206
def is_external(self):
212207
return self.type == EXTERNAL
213208

209+
@property
210+
def explicit_name(self):
211+
"""
212+
Version name that is explicit about external origins.
213+
214+
For example, if a version originates from GitHub pull request #4, then
215+
``version.explicit_name == "#4 (PR)"``.
216+
217+
On the other hand, Versions associated with regular RTD builds
218+
(e.g. new tags or branches), simply return :obj:`~.verbose_name`.
219+
This means that a regular git tag named **v4** will correspond to
220+
``version.explicit_name == "v4"``.
221+
"""
222+
if not self.is_external:
223+
return self.verbose_name
224+
225+
template = "#{name} ({abbrev})"
226+
external_origin = external_version_name(self)
227+
abbrev = "".join(word[0].upper() for word in external_origin.split())
228+
return template.format(name=self.verbose_name, abbrev=abbrev)
229+
214230
@property
215231
def ref(self):
216232
if self.slug == STABLE:
@@ -946,16 +962,7 @@ def can_rebuild(self):
946962

947963
@property
948964
def external_version_name(self):
949-
if self.is_external:
950-
if self.project.git_provider_name == GITHUB_BRAND:
951-
return GITHUB_EXTERNAL_VERSION_NAME
952-
953-
if self.project.git_provider_name == GITLAB_BRAND:
954-
return GITLAB_EXTERNAL_VERSION_NAME
955-
956-
# TODO: Add External Version Name for BitBucket.
957-
return GENERIC_EXTERNAL_VERSION_NAME
958-
return None
965+
return external_version_name(self)
959966

960967
def using_latest_config(self):
961968
if self.config:
@@ -1324,7 +1331,7 @@ def match(self, version, match_arg):
13241331
pattern=match_arg,
13251332
version_slug=version.slug,
13261333
)
1327-
except Exception as e:
1334+
except Exception:
13281335
log.exception('Error parsing regex.', exc_info=True)
13291336
return False, None
13301337

readthedocs/builds/utils.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
"""Utilities for the builds app."""
2-
from time import monotonic
3-
42
from contextlib import contextmanager
3+
from time import monotonic
54

65
from django.core.cache import cache
76

8-
from readthedocs.builds.constants import EXTERNAL
7+
from readthedocs.builds.constants import (
8+
EXTERNAL,
9+
GENERIC_EXTERNAL_VERSION_NAME,
10+
GITHUB_EXTERNAL_VERSION_NAME,
11+
GITLAB_EXTERNAL_VERSION_NAME,
12+
)
913
from readthedocs.projects.constants import (
1014
BITBUCKET_REGEXS,
15+
GITHUB_BRAND,
1116
GITHUB_PULL_REQUEST_URL,
1217
GITHUB_REGEXS,
18+
GITLAB_BRAND,
1319
GITLAB_MERGE_REQUEST_URL,
1420
GITLAB_REGEXS,
1521
)
@@ -79,6 +85,23 @@ def get_vcs_url(*, project, version_type, version_name):
7985
return project.repo.replace('git://', 'https://').replace('.git', '') + url
8086

8187

88+
def external_version_name(build_or_version):
89+
"""Returns a string identifying the external build/version's nature."""
90+
if not build_or_version.is_external:
91+
return None
92+
93+
project = build_or_version.project
94+
95+
if project.git_provider_name == GITHUB_BRAND:
96+
return GITHUB_EXTERNAL_VERSION_NAME
97+
98+
if project.git_provider_name == GITLAB_BRAND:
99+
return GITLAB_EXTERNAL_VERSION_NAME
100+
101+
# TODO: Add External Version Name for BitBucket.
102+
return GENERIC_EXTERNAL_VERSION_NAME
103+
104+
82105
@contextmanager
83106
def memcache_lock(lock_id, oid):
84107
"""

readthedocs/core/static-src/core/js/doc-embed/search.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ function attach_elastic_search_query_sphinx(data) {
5353
search_url.search = '?q=' + $.urlencode(query) + '&project=' + project +
5454
'&version=' + version + '&language=' + language;
5555

56+
/*
57+
* Compatibility function to set a text to a Node or JQuery object.
58+
*/
59+
var setText = function (node, text) {
60+
if (node.jquery) {
61+
node.text(text);
62+
} else {
63+
node.innerText = text;
64+
}
65+
};
66+
5667
search_def
5768
.then(function (data) {
5869
var results = data.results || [];
@@ -61,7 +72,7 @@ function attach_elastic_search_query_sphinx(data) {
6172
for (var i = 0; i < results.length; i += 1) {
6273
var result = results[i];
6374
var blocks = result.blocks;
64-
var list_item = $('<li style="display: none;"></li>');
75+
var list_item = $('<li>');
6576

6677
var title = result.title;
6778
// if highlighted title is present, use that.
@@ -188,10 +199,14 @@ function attach_elastic_search_query_sphinx(data) {
188199
}
189200
}
190201

191-
Search.output.append(list_item);
192-
list_item.slideDown(5);
202+
if (Search.output.jquery) {
203+
Search.output.append(list_item);
204+
} else {
205+
Search.output.appendChild(list_item.get(0));
206+
}
193207
}
194-
Search.status.text(
208+
setText(
209+
Search.status,
195210
_('Search finished, found %s page(s) matching the search query.').replace('%s', results.length)
196211
);
197212
} else {
@@ -206,8 +221,7 @@ function attach_elastic_search_query_sphinx(data) {
206221
.always(function () {
207222
$('#search-progress').empty();
208223
Search.stopPulse();
209-
Search.title.text(_('Search Results'));
210-
Search.status.fadeIn(500);
224+
setText(Search.title, _('Search Results'));
211225
});
212226

213227
$.ajax({

readthedocs/core/static/core/js/readthedocs-doc-embed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/projects/tests/test_build_tasks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def test_get_env_vars_default(self, load_yaml_config):
204204
"NO_COLOR": "1",
205205
"READTHEDOCS": "True",
206206
"READTHEDOCS_VERSION": self.version.slug,
207+
"READTHEDOCS_VERSION_TYPE": self.version.type,
208+
"READTHEDOCS_VERSION_NAME": self.version.verbose_name,
207209
"READTHEDOCS_PROJECT": self.project.slug,
208210
"READTHEDOCS_LANGUAGE": self.project.language,
209211
"BIN_PATH": os.path.join(

readthedocs/rtd_tests/tests/test_builds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ def setUp(self):
491491
self.project = get(Project)
492492
self.version = get(
493493
Version,
494-
project=self.project
494+
project=self.project,
495+
type=BRANCH,
495496
)
496497

497498
get(

readthedocs/rtd_tests/tests/test_footer.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from readthedocs.builds.constants import BRANCH, EXTERNAL, LATEST, TAG
1212
from readthedocs.builds.models import Version
1313
from readthedocs.core.middleware import ReadTheDocsSessionMiddleware
14-
from readthedocs.projects.constants import PUBLIC
14+
from readthedocs.projects.constants import GITHUB_BRAND, GITLAB_BRAND, PUBLIC
1515
from readthedocs.projects.models import Project
1616

1717

@@ -72,6 +72,29 @@ def test_footer_dont_show_version_warning(self):
7272
self.assertFalse(r.data['show_version_warning'])
7373
self.assertEqual(r.context['main_project'], self.pip)
7474

75+
def test_footer_show_explicit_name_for_external_version(self):
76+
project = Project.objects.get(slug="pip")
77+
version = project.versions.get(slug=LATEST)
78+
version.type = EXTERNAL
79+
version.verbose_name = "4"
80+
version.save()
81+
self.url = (
82+
reverse("footer_html")
83+
+ f"?project={project.slug}&version={version.slug}&page=index&docroot=/"
84+
)
85+
86+
git_provider_name = "readthedocs.projects.models.Project.git_provider_name"
87+
with mock.patch(git_provider_name, GITHUB_BRAND):
88+
r = self.render()
89+
self.assertIn("#4 (PR)", r.data["html"])
90+
self.assertNotIn("#4 (MR)", r.data["html"])
91+
self.assertNotIn("#4 (EV)", r.data["html"])
92+
with mock.patch(git_provider_name, GITLAB_BRAND):
93+
r = self.render()
94+
self.assertIn("#4 (MR)", r.data["html"])
95+
self.assertNotIn("#4 (PR)", r.data["html"])
96+
self.assertNotIn("#4 (EV)", r.data["html"])
97+
7598
def test_footer_dont_show_version_warning_for_external_versions(self):
7699
self.latest.type = EXTERNAL
77100
self.latest.save()

requirements/deploy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
psycopg2==2.9.3
66
gunicorn==20.1.0
7-
django-redis-cache==3.0.0
7+
django-redis-cache==3.0.1
88

99
#For resizing images
1010
pillow==9.0.1

0 commit comments

Comments
 (0)