diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index dbe47d6f2..de577ec5e 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -21,7 +21,7 @@ jobs: - run: sudo apt-get install -y gettext - run: pip install -r requirements.txt - run: uv run generate.py # generates index.html and index.json - - run: mkdir -p build && cp index.* style.css build + - run: mkdir -p build && cp index.* style.css ./*.html build - name: Deploy 🚀 if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4 diff --git a/completion.py b/completion.py index a420b498c..6ad23233b 100644 --- a/completion.py +++ b/completion.py @@ -20,9 +20,9 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]: ] -def get_completion( +def get_stats( clones_dir: str, repo: str -) -> tuple[float, 'TranslatorsData', str, float]: +) -> tuple[potodo.PoProjectStats, 'TranslatorsData', str, float]: clone_path = Path(clones_dir, 'translations', repo) for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + [ 'master', @@ -43,15 +43,15 @@ def get_completion( translators_data = TranslatorsData(translators_number, translators_link) break path_for_merge = Path(clones_dir, 'rebased_translations', repo) - completion = potodo.merge_and_scan_path( + po_project = potodo.merge_and_scan_path( clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=path_for_merge, hide_reserved=False, api_url='', - ).completion + ) - if completion: + if po_project.completion: # Fetch commit from before 30 days ago and checkout try: commit = next( @@ -73,9 +73,9 @@ def get_completion( else: month_ago_completion = 0.0 - change = completion - month_ago_completion + change = po_project.completion - month_ago_completion - return completion, translators_data, branch, change + return po_project, translators_data, branch, change @dataclass(frozen=True) diff --git a/generate.py b/generate.py index f773848b3..05457b124 100644 --- a/generate.py +++ b/generate.py @@ -7,6 +7,7 @@ from dataclasses import dataclass, asdict from datetime import datetime, timezone from pathlib import Path +from types import SimpleNamespace from git import Repo from jinja2 import Template @@ -14,7 +15,7 @@ import build_status import contribute -from completion import branches_from_devguide, get_completion, TranslatorsData +from completion import branches_from_devguide, get_stats, TranslatorsData from repositories import Language, get_languages_and_repos from word_count import get_word_count @@ -56,9 +57,14 @@ def get_project_data( ) -> 'LanguageProjectData': built = language.code in languages_built if repo: - completion, translators_data, branch, change = get_completion(clones_dir, repo) + stats, translators_data, branch, change = get_stats(clones_dir, repo) + + template = Template(Path('language.html.jinja').read_text()) + Path(f'{language.code}.html').write_text( + template.render(stats=stats, language=language) + ) else: - completion = 0.0 + stats = SimpleNamespace(completion=0.0) translators_data = TranslatorsData(0, False) change = 0.0 branch = '' @@ -66,7 +72,7 @@ def get_project_data( language, repo, branch, - completion, + stats.completion, change, translators_data, built, diff --git a/language.html.jinja b/language.html.jinja new file mode 100644 index 000000000..6e8aac08c --- /dev/null +++ b/language.html.jinja @@ -0,0 +1,88 @@ + + + Python Docs Translation Dashboard + + + + + + +

Python Docs Translation Dashboard: {{ language.name }}

+ + + + + + + + +{% for directory in stats.stats_by_directory() %} + + + + + +{% for file in directory.files_stats | sort(attribute='filename') %} + + + + +{% endfor %} + +{% endfor %} +
pathcompletion*
â–¶ {{ directory.path.name }} ({{ directory.files_stats | length }}) +
+ {{ '{:.2f}%'.format(directory.completion) }} ({{ directory.translated }} / {{ directory.entries }}) +
+
+ {{ '{:.2f}%'.format(directory.completion) }} ({{ directory.translated }} / {{ directory.entries }}) +
+
+

* in brackets: number of strings (entries) translated / total

+ + + diff --git a/style.css b/style.css index 866b7454d..5fa2d6e2d 100644 --- a/style.css +++ b/style.css @@ -53,6 +53,10 @@ td[data-label="completion"] { right: 10px; } +.directory { + cursor: pointer; +} + @media screen and (max-width: 675px) { .switchpages{ all: unset; diff --git a/template.html.jinja b/template.html.jinja index 676f83117..5a057fae4 100644 --- a/template.html.jinja +++ b/template.html.jinja @@ -39,6 +39,7 @@ main | meta {% if project.translators.link %}{% endif %} +
@@ -47,6 +48,7 @@ main | meta
{{ '{:.2f}%'.format(project.completion) }} {% if project.change >= 0.01 %}({{ '{:+.2f}%'.format(project.change) }}){% endif %}
+ {% endfor %}