Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
23 changes: 19 additions & 4 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
from datetime import datetime, timezone
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import cast
from typing import cast, Literal

from git import Repo
from jinja2 import Template

import workflow
import repositories
import build_status
import visitors
Expand All @@ -27,7 +28,9 @@


def get_completion_progress() -> (
Iterator[tuple[str, str, float, int, int, bool, bool | None]]
Iterator[
tuple[str, str, float, int, int, bool, bool | None, bool, str | Literal[False]]
]
):
with TemporaryDirectory() as clones_dir:
Repo.clone_from(
Expand All @@ -52,12 +55,24 @@ def get_completion_progress() -> (
for lang, repo in repositories.get_languages_and_repos(devguide_dir):
built = lang in languages_built
in_switcher = languages_built.get(lang)
tx = lang in workflow.pulling_from_transifex
contrib_link = workflow.get_contrib_link(lang)
if not repo:
yield lang, cast(str, repo), 0.0, 0, 0, built, in_switcher
yield lang, cast(str, repo), 0.0, 0, 0, built, in_switcher, False, False
continue
completion, translators = get_completion(clones_dir, repo)
visitors_num = visitors.get_number_of_visitors(lang) if built else 0
yield lang, repo, completion, translators, visitors_num, built, in_switcher
yield (
lang,
repo,
completion,
translators,
visitors_num,
built,
in_switcher,
tx,
contrib_link,
)


if __name__ == '__main__':
Expand Down
8 changes: 7 additions & 1 deletion template.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
<thead>
<tr>
<th>language</th>
<th>workflow</th>
<th>build</th>
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies" target="_blank">visitors</a></th>
<th>translators</th>
<th>completion</th>
</tr>
</thead>
<tbody>
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
{% for language, repo, completion, translators, visitors, build, in_switcher, on_platform, contrib_link in completion_progress | sort(attribute='2,3') | reverse %}
<tr>
{% if repo %}
<td data-label="language">
Expand All @@ -27,6 +28,11 @@
{% else %}
<td data-label="language">{{ language }}</td>
{% endif %}
<td data-label="workflow">
{% if contrib_link %}<a href="{{ contrib_link }}" target="_blank">{% endif %}
{% if on_platform %}platform{% else %}repository{% endif %}
{% if contrib_link %}</a>{% endif %}
</td>
<td data-label="build">
{% if build %}
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓{% if in_switcher %} in switcher{% endif %}</a>
Expand Down
25 changes: 25 additions & 0 deletions workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Literal

pulling_from_transifex = ('zh-cn', 'pt-br', 'ja', 'uk', 'pl')

custom_contributing_links = {
'es': 'https://python-docs-es.readthedocs.io/page/CONTRIBUTING.html',
'ko': 'https://www.flowdas.com/pages/python-docs-ko.html',
'zh-tw': 'https://github.com/python/python-docs-zh-tw/blob/3.13/README.rst#%E5%8F%83%E8%88%87%E7%BF%BB%E8%AD%AF',
'fr': 'https://git.afpy.org/AFPy/python-docs-fr/src/branch/3.13/CONTRIBUTING.rst',
'id': 'https://github.com/python/python-docs-id/blob/master/README.md#berkontribusi-untuk-menerjemahkan',
'tr': 'https://github.com/python/python-docs-tr/blob/3.12/README.md#%C3%A7eviriye-katk%C4%B1da-bulunmak',
'gr': 'https://github.com/pygreece/python-docs-gr/blob/3.12/CONTRIBUTING.md',
}


def get_contrib_link(language: str) -> str | Literal[False]:
return custom_contributing_links.get(language) or (
language in pulling_from_transifex
and 'https://explore.transifex.com/python-doc/python-newest/'
)


if __name__ == '__main__':
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
print(f'{code}: {get_contrib_link(code)}')
Loading