Skip to content

Commit c63bbe5

Browse files
committed
Build status
1 parent 2e752d9 commit c63bbe5

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

generate.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
subprocess.run(
4242
['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True
4343
)
44-
switcher_languages = list(switcher.get_languages())
44+
switcher_languages = {
45+
language: switcher for language, switcher in build_status.get_languages()
46+
}
4547
for language, repo in repositories.get_languages_and_repos(devguide_dir):
4648
if repo:
4749
completion_number, translators_number = get_completion(clones_dir, repo)
@@ -56,6 +58,7 @@
5658
translators_number,
5759
visitors_number,
5860
language in switcher_languages,
61+
switcher_languages.get(language),
5962
)
6063
)
6164
print(completion_progress[-1])
@@ -80,7 +83,7 @@
8083
</tr>
8184
</thead>
8285
<tbody>
83-
{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
86+
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
8487
<tr>
8588
{% if repo %}
8689
<td data-label="language">
@@ -92,8 +95,8 @@
9295
<td data-label="language">{{ language }}</td>
9396
{% endif %}
9497
<td data-label="build">
95-
{% if in_switcher %}
96-
<a href="https://docs.python.org/{{ language }}/">in switcher</a>
98+
{% if build %}
99+
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓{% if in_switcher %}in switcher{% endif %}</a>
97100
{% else %}
98101
99102
{% endif %}

switcher.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
"""
2-
Fetch languages in the https://docs.python.org language switcher.
2+
Fetch build status of languages in the https://docs.python.org.
33
4-
Return a defaultdict mapping language codes to a Boolean indicating
4+
Yield a tuple of language code and a Boolean indicating
55
whether it is in the language switcher.
66
"""
77

88
import tomllib
9-
from typing import Generator
9+
from collections.abc import Generator
1010

1111
import requests
1212

1313

14-
def get_languages() -> Generator[str, None, None]:
14+
def get_languages() -> Generator[tuple[str, str]]:
1515
data = requests.get(
1616
'https://raw.githubusercontent.com/'
1717
'python/docsbuild-scripts/refs/heads/main/config.toml',
@@ -21,15 +21,16 @@ def get_languages() -> Generator[str, None, None]:
2121
languages = config['languages']
2222
defaults = config['defaults']
2323
for code, language in languages.items():
24-
if language.get('in_prod', defaults['in_prod']):
25-
yield code.lower().replace('_', '-')
24+
language_code = code.lower().replace('_', '-')
25+
switcher = language.get('in_prod', defaults['in_prod'])
26+
yield language_code, switcher
2627

2728

2829
def main() -> None:
29-
languages = list(get_languages())
30+
languages = {language: switcher for language, switcher in get_languages()}
3031
print(languages)
31-
for code in ('en', 'pl', 'ar', 'zh-cn'):
32-
print(f'{code}: {code in languages}')
32+
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
33+
print(f'{code}: {code in languages and languages[code]}')
3334

3435

3536
if __name__ == '__main__':

0 commit comments

Comments
 (0)