Skip to content

Commit 8294bf1

Browse files
authored
Merge pull request #255 from openedx/edx.rtd-links
feat!: Make help-tokens work with docs.openedx.org
2 parents 3a32606 + aecd46f commit 8294bf1

File tree

8 files changed

+24
-15
lines changed

8 files changed

+24
-15
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Change Log
1111

1212
.. There should always be an "Unreleased" section for changes pending release.
1313
14+
[3.0.0] - 2025-03-14
15+
====================
16+
17+
* Dropped support for edx.readthedocs.io URLs in
18+
favor of docs.openedx.org URLs.
19+
20+
See https://github.com/openedx/edx-documentation/issues/2319
21+
22+
1423
[2.4.0] - 2024-03-29
1524
====================
1625

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ Help-tokens reads these Django settings to create URLs:
4242
* HELP_TOKENS_BOOKS: a dictionary mapping book slugs to URLs. For example::
4343

4444
HELP_TOKENS_BOOKS = {
45-
'learner': 'http://edx.readthedocs.io/projects/learner-guide',
46-
'course_author': 'http://edx.readthedocs.io/projects/running-a-course',
45+
'learner': 'https://docs.openedx.org/en/latest/learners',
46+
'course_author': 'https://docs.openedx.org/en/latest/educators',
4747
}
4848

4949
* HELP_TOKENS_VERSION: a string used as part of the final URL, to choose the

help_tokens/__init__.py

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

55
from .context_processor import context_processor
66

7-
__version__ = '2.4.0'
7+
__version__ = '3.0.0'

help_tokens/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def url_for_token(self, token):
7070
lang = getattr(settings, "HELP_TOKENS_LANGUAGE_CODE", None)
7171
if lang is not None:
7272
lang = self.get_config_value("locales", lang)
73-
url += "/" + lang
73+
url = url.replace("/en", "/" + lang)
7474

7575
version = getattr(settings, "HELP_TOKENS_VERSION", None)
7676
if version is not None:
77-
url += "/" + version
77+
url = url.replace("/latest", "/" + version)
7878

7979
url += "/" + url_tail
8080
return url

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def book_settings(settings):
1919
"""Set some HELP_TOKENS settings."""
2020
settings.HELP_TOKENS_INI_FILE = "tests/sample.ini"
2121
settings.HELP_TOKENS_BOOKS = {
22-
'learner': 'http://edx.readthedocs.io/projects/learner-guide',
23-
'course_author': 'http://edx.readthedocs.io/projects/running-a-course',
22+
'learner': 'https://docs.openedx.org/en/latest/learners',
23+
'course_author': 'https://docs.openedx.org/en/latest/educators',
2424
}
25-
settings.HELP_TOKENS_VERSION = "ver"
25+
settings.HELP_TOKENS_VERSION = "latest"
2626
settings.HELP_TOKENS_LANGUAGE_CODE = "en"
2727
return settings

tests/test_context_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
def test_context_processor(book_settings):
1212
context = context_processor(None)
1313
actual = context['get_online_help_info']('instructor')['doc_url']
14-
expected = "http://edx.readthedocs.io/projects/learner-guide/en/ver/SFD_instructor_dash_help.html"
14+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
1515
assert actual == expected

tests/test_core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ def test_no_token(sample_expert):
2727

2828

2929
def test_url_for_token(sample_expert, book_settings):
30-
expected = "http://edx.readthedocs.io/projects/learner-guide/en/ver/SFD_instructor_dash_help.html"
30+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
3131
assert sample_expert.url_for_token("instructor") == expected
3232

3333

3434
def test_no_version(sample_expert, book_settings):
3535
book_settings.HELP_TOKENS_VERSION = None
36-
expected = "http://edx.readthedocs.io/projects/learner-guide/en/SFD_instructor_dash_help.html"
36+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
3737
assert sample_expert.url_for_token("instructor") == expected
3838

3939

4040
def test_language_code(sample_expert, book_settings):
4141
book_settings.HELP_TOKENS_LANGUAGE_CODE = "fr_CA"
42-
expected = "http://edx.readthedocs.io/projects/learner-guide/fr/ver/SFD_instructor_dash_help.html"
42+
expected = "https://docs.openedx.org/fr/latest/learners/SFD_instructor_dash_help.html"
4343
assert sample_expert.url_for_token("instructor") == expected
4444

4545

4646
def test_unknown_language_code(sample_expert, book_settings):
4747
book_settings.HELP_TOKENS_LANGUAGE_CODE = "xx"
48-
expected = "http://edx.readthedocs.io/projects/learner-guide/en/ver/SFD_instructor_dash_help.html"
48+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
4949
assert sample_expert.url_for_token("instructor") == expected
5050

5151

5252
def test_no_language_code(sample_expert, book_settings):
5353
book_settings.HELP_TOKENS_LANGUAGE_CODE = None
54-
expected = "http://edx.readthedocs.io/projects/learner-guide/ver/SFD_instructor_dash_help.html"
54+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
5555
assert sample_expert.url_for_token("instructor") == expected

tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
def test_redirect(client, book_settings):
1010
response = client.get("/instructor")
1111
assert response.status_code == 302
12-
expected = "http://edx.readthedocs.io/projects/learner-guide/en/ver/SFD_instructor_dash_help.html"
12+
expected = "https://docs.openedx.org/en/latest/learners/SFD_instructor_dash_help.html"
1313
assert response['location'] == expected

0 commit comments

Comments
 (0)