Skip to content

Commit a2b2b63

Browse files
m-aciekAA-Turner
andauthored
Build status (#33)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 2e752d9 commit a2b2b63

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

build_status.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Fetch build status of languages in the https://docs.python.org.
3+
4+
Yield a tuple of language code and a Boolean indicating
5+
whether it is in the language switcher.
6+
"""
7+
8+
import tomllib
9+
from collections.abc import Iterator
10+
11+
import requests
12+
13+
14+
def get_languages() -> Iterator[tuple[str, bool]]:
15+
data = requests.get(
16+
'https://raw.githubusercontent.com/'
17+
'python/docsbuild-scripts/refs/heads/main/config.toml',
18+
timeout=10,
19+
).text
20+
config = tomllib.loads(data)
21+
for code, language in config['languages'].items():
22+
language_code = code.lower().replace('_', '-')
23+
in_switcher = language.get('in_prod', config['defaults']['in_prod'])
24+
yield language_code, in_switcher
25+
26+
27+
def main() -> None:
28+
languages = {language: in_switcher for language, in_switcher in get_languages()}
29+
print(languages)
30+
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
31+
print(f'{code}: {code in languages} {languages.get(code)}')
32+
33+
34+
if __name__ == '__main__':
35+
main()

generate.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from jinja2 import Template
1818

1919
import repositories
20-
import switcher
20+
import build_status
2121
import visitors
2222
from completion import branches_from_devguide, get_completion
2323

@@ -41,7 +41,7 @@
4141
subprocess.run(
4242
['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True
4343
)
44-
switcher_languages = list(switcher.get_languages())
44+
languages_built = dict(build_status.get_languages())
4545
for language, repo in repositories.get_languages_and_repos(devguide_dir):
4646
if repo:
4747
completion_number, translators_number = get_completion(clones_dir, repo)
@@ -55,7 +55,8 @@
5555
completion_number,
5656
translators_number,
5757
visitors_number,
58-
language in switcher_languages,
58+
language in languages_built, # built on docs.python.org
59+
languages_built.get(language), # in switcher
5960
)
6061
)
6162
print(completion_progress[-1])
@@ -80,7 +81,7 @@
8081
</tr>
8182
</thead>
8283
<tbody>
83-
{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
84+
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
8485
<tr>
8586
{% if repo %}
8687
<td data-label="language">
@@ -92,8 +93,8 @@
9293
<td data-label="language">{{ language }}</td>
9394
{% endif %}
9495
<td data-label="build">
95-
{% if in_switcher %}
96-
<a href="https://docs.python.org/{{ language }}/">in switcher</a>
96+
{% if build %}
97+
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓{% if in_switcher %} in switcher{% endif %}</a>
9798
{% else %}
9899
99100
{% endif %}

switcher.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)