Skip to content

Commit c8b4d9d

Browse files
committed
Don't link from language name, move repo link as contrib link fallback
1 parent a0fb70a commit c8b4d9d

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

contribute.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Literal
2-
31
pulling_from_transifex = ('zh-cn', 'pt-br', 'ja', 'uk', 'pl')
42

53
custom_contributing_links = {
@@ -13,13 +11,23 @@
1311
}
1412

1513

16-
def get_contrib_link(language: str) -> str | Literal[False]:
17-
return custom_contributing_links.get(language) or (
18-
language in pulling_from_transifex
19-
and 'https://explore.transifex.com/python-doc/python-newest/'
14+
def get_contrib_link(language: str, repo: str | None) -> str | None:
15+
return (
16+
custom_contributing_links.get(language)
17+
or (
18+
language in pulling_from_transifex
19+
and 'https://explore.transifex.com/python-doc/python-newest/'
20+
)
21+
or (repo and f'https://github.com/{repo}')
2022
)
2123

2224

2325
if __name__ == '__main__':
24-
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
25-
print(f'{code}: {get_contrib_link(code)}')
26+
for code, repo in (
27+
('en', None),
28+
('pl', None),
29+
('ar', 'python/python-docs-ar'),
30+
('zh-cn', None),
31+
('id', None),
32+
):
33+
print(f'{code}: {get_contrib_link(code, repo)}')

generate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_completion_progress() -> (
4040
bool,
4141
bool | None,
4242
bool,
43-
str | Literal[False],
43+
str | None,
4444
]
4545
]
4646
):
@@ -68,7 +68,7 @@ def get_completion_progress() -> (
6868
built = lang in languages_built
6969
in_switcher = languages_built.get(lang)
7070
tx = lang in contribute.pulling_from_transifex
71-
contrib_link = contribute.get_contrib_link(lang)
71+
contrib_link = contribute.get_contrib_link(lang, repo)
7272
if not repo:
7373
yield (
7474
lang,
@@ -81,7 +81,7 @@ def get_completion_progress() -> (
8181
built,
8282
in_switcher,
8383
False,
84-
False,
84+
None,
8585
)
8686
continue
8787
completion, translators, translators_link = get_completion(clones_dir, repo)

template.html.jinja

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@
1919
<tbody>
2020
{% for language, language_name, repo, completion, translators, translators_link, visitors, build, in_switcher, on_platform, contrib_link in completion_progress | sort(attribute='2,3') | reverse %}
2121
<tr>
22-
{% if repo %}
23-
<td data-label="language">
24-
<a href="https://github.com/{{ repo }}" target="_blank">
25-
{{ language_name }} ({{ language }})
26-
</a>
27-
</td>
28-
{% else %}
29-
<td data-label="language">{{ language }}</td>
30-
{% endif %}
31-
<td data-label="contribute">
22+
<td data-label="language">{{ language_name }} ({{ language }})</td>
23+
<td data-label="contribute">
3224
{% if contrib_link %}<a href="{{ contrib_link }}" target="_blank">{% endif %}
3325
{% if on_platform %}platform{% else %}repository{% endif %}
3426
{% if contrib_link %}</a>{% endif %}

0 commit comments

Comments
 (0)