Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions build_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Fetch build status of languages in the https://docs.python.org.

Yield a tuple of language code and a Boolean indicating
whether it is in the language switcher.
"""

import tomllib
from collections.abc import Iterator

import requests


def get_languages() -> Iterator[tuple[str, bool]]:
data = requests.get(
'https://raw.githubusercontent.com/'
'python/docsbuild-scripts/refs/heads/main/config.toml',
timeout=10,
).text
config = tomllib.loads(data)
for code, language in config['languages'].items():
language_code = code.lower().replace('_', '-')
in_switcher = language.get('in_prod', config['defaults']['in_prod'])
yield language_code, in_switcher


def main() -> None:
languages = {language: in_switcher for language, in_switcher in get_languages()}
print(languages)
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
print(f'{code}: {code in languages} {languages.get(code)}')


if __name__ == '__main__':
main()
13 changes: 7 additions & 6 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from jinja2 import Template

import repositories
import switcher
import build_status
import visitors
from completion import branches_from_devguide, get_completion

Expand All @@ -41,7 +41,7 @@
subprocess.run(
['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True
)
switcher_languages = list(switcher.get_languages())
languages_built = dict(build_status.get_languages())
for language, repo in repositories.get_languages_and_repos(devguide_dir):
if repo:
completion_number, translators_number = get_completion(clones_dir, repo)
Expand All @@ -55,7 +55,8 @@
completion_number,
translators_number,
visitors_number,
language in switcher_languages,
language in languages_built, # built on docs.python.org
languages_built.get(language), # in switcher
)
)
print(completion_progress[-1])
Expand All @@ -80,7 +81,7 @@
</tr>
</thead>
<tbody>
{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
<tr>
{% if repo %}
<td data-label="language">
Expand All @@ -92,8 +93,8 @@
<td data-label="language">{{ language }}</td>
{% endif %}
<td data-label="build">
{% if in_switcher %}
<a href="https://docs.python.org/{{ language }}/">in switcher</a>
{% if build %}
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓ {% if in_switcher %}in switcher{% endif %}</a>
{% else %}
{% endif %}
Expand Down
36 changes: 0 additions & 36 deletions switcher.py

This file was deleted.

Loading