Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aeaad60
Check all against local gettext build
m-aciek Nov 19, 2024
c8ef090
Remove branch info as superfluous
m-aciek Nov 19, 2024
c2cd2f7
Clone CPython repo and build gettext
m-aciek Nov 20, 2024
a239100
Add Sphinx dependency
m-aciek Nov 20, 2024
e342c74
Add blurb dependency
m-aciek Nov 20, 2024
b97808d
Fix clone path
m-aciek Nov 20, 2024
c5a19ab
Debug log
m-aciek Nov 20, 2024
058edc7
Install gettext in the workflow
m-aciek Nov 20, 2024
14b44e9
Format with black
m-aciek Nov 20, 2024
2bfe4b7
Skip OSError handling -- covered by potodo now
m-aciek Nov 20, 2024
e825810
Improve styling
m-aciek Nov 20, 2024
98207f7
Simplify scan after upstream change
m-aciek Nov 21, 2024
dd27f55
Remove unused import
m-aciek Nov 21, 2024
f420781
Fix: break the versions loop when cloned
m-aciek Nov 21, 2024
83a785d
Make cpython docs venv
m-aciek Nov 22, 2024
26db37b
fix: bring back outer temp directory
m-aciek Nov 22, 2024
681a306
revert format on template
m-aciek Nov 22, 2024
10098e6
Merge branch 'main' into check-against-latest
m-aciek Dec 5, 2024
9aa8117
update call argument name
m-aciek Dec 5, 2024
da92325
Remove custom potodo version and a note from template
m-aciek Dec 8, 2024
6323a16
Install GNU Gettext in Read the Docs, reorder arguments
m-aciek Dec 8, 2024
484bea9
Remove sudo call in Read the Docs command
m-aciek Dec 8, 2024
c00b88b
Add gettext with apt_packages (test)
m-aciek Dec 9, 2024
dec5e01
convert command to jobs
m-aciek Dec 9, 2024
44551e6
move plugin add to install group
m-aciek Dec 9, 2024
77be670
Align visitors number to right
m-aciek Dec 9, 2024
65ef8c6
Revert "Align visitors number to right"
m-aciek Dec 9, 2024
53e3f27
Merge branch 'main' into check-against-latest
m-aciek Dec 9, 2024
d7683c6
Add missing import
m-aciek Dec 9, 2024
828ea97
Update completion.py: fix reference
m-aciek Dec 9, 2024
6067937
Add missing CPython clone code
m-aciek Dec 10, 2024
4faf155
Merge branch 'main' into check-against-latest
m-aciek Dec 10, 2024
15966b1
Merge branch 'main' into check-against-latest
m-aciek Dec 13, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
python-version: "3.x"
- uses: astral-sh/setup-uv@v4
- uses: actions/checkout@v4
- run: sudo apt-get install -y gettext
- run: uv run generate.py # generates "index.html"
- run: mkdir -p build && cp index.html style.css build
- name: Deploy 🚀
Expand Down
21 changes: 14 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ build:
os: ubuntu-24.04
tools:
python: "3"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv run generate.py
- mkdir -p _readthedocs/html
- mv index.html style.css _readthedocs/html
apt_packages:
- gettext
jobs:
post_checkout: []
install:
- asdf plugin add uv
- asdf install uv latest
pre_build:
- asdf global uv latest
build:
html:
- uv run generate.py
- mkdir -p _readthedocs/html
- mv index.html style.css _readthedocs/html
27 changes: 14 additions & 13 deletions completion.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pathlib
import shutil
from functools import cache
from pathlib import Path
from tempfile import TemporaryDirectory

import git
from potodo import potodo
import requests


@cache
def branches_from_devguide() -> list[str]:
r = requests.get(
"https://raw.githubusercontent.com/"
Expand All @@ -18,21 +19,21 @@ def branches_from_devguide() -> list[str]:
]


def get_completion_and_branch(tmpdir: str, language: str) -> tuple[float, str]:
clone_path = pathlib.Path(tmpdir, language)
def get_completion(clones_dir: str, language: str) -> float:
clone_path = Path(clones_dir, language)

for branch in branches_from_devguide():
try:
git.Repo.clone_from(f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch)
git.Repo.clone_from(
f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch
)
except git.GitCommandError:
print(f'failed to clone {language} {branch}')
continue
try:
completion = potodo.scan_path(clone_path, no_cache=True, hide_reserved=False, api_url='').completion
except OSError:
print(f'failed to scan {language} {branch}')
shutil.rmtree(clone_path)
continue
else:
break
return completion, branch
with TemporaryDirectory() as tmpdir:
completion = potodo.merge_and_scan_path(
clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), hide_reserved=False, api_url=''
).completion
return completion
25 changes: 15 additions & 10 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,37 @@
# "requests",
# ]
# ///
import subprocess
from datetime import datetime, timezone
from pathlib import Path
from tempfile import TemporaryDirectory

from git import Repo
from jinja2 import Template

import completion
import visitors
from completion import branches_from_devguide, get_completion

completion_progress = []
generation_time = datetime.now(timezone.utc)

with TemporaryDirectory() as tmpdir:
with TemporaryDirectory() as clones_dir:
Repo.clone_from(
f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch=branches_from_devguide()[0]
)
subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True)
subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True)
for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'):
completion_number, branch = completion.get_completion_and_branch(tmpdir, language)
completion_number = get_completion(clones_dir, language)
visitors_number = visitors.get_number_of_visitors(language)
completion_progress.append((language, completion_number, branch, visitors_number))
completion_progress.append((language, completion_number, visitors_number))
print(completion_progress[-1])

template = Template("""
<html lang="en">
<head>
<title>Python Docs Translation Dashboard</title>
<link rel="stylesheet" href="style.css">
<title>Python Docs Translation Dashboard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Python Docs Translation Dashboard</h1>
Expand All @@ -37,12 +45,11 @@
<tr>
<th>language</th>
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors<a/></th>
<th>branch</th>
<th>completion</th>
</tr>
</thead>
<tbody>
{% for language, completion, branch, visitors in completion_progress | sort(attribute=1) | reverse %}
{% for language, completion, visitors in completion_progress | sort(attribute=1) | reverse %}
<tr>
<td data-label="language">
<a href="https://github.com/python/python-docs-{{ language }}" target="_blank">
Expand All @@ -54,7 +61,6 @@
{{ '{:,}'.format(visitors) }}
</a>
</td>
<td data-label="branch">{{ branch }}</td>
<td data-label="completion">
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
</td>
Expand All @@ -63,7 +69,6 @@
</tbody>
</table>
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
<p>Note that the completion value is based on files available in language Git repository and <a href="https://github.com/m-aciek/pydocs-translation-dashboard/issues/2" target="_blank">may not include</a> e.g. resources which translation hasn't yet started.</p>
</body>
</html>
""")
Expand Down
Loading