Skip to content

Commit c918d08

Browse files
author
Éric Araujo
committed
merge upstread
2 parents d8ddc72 + 1792927 commit c918d08

9 files changed

Lines changed: 72 additions & 27 deletions

File tree

.github/workflows/cleanup-pr-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
permissions:
1111
contents: write
1212
steps:
13-
- uses: actions/checkout@v5
13+
- uses: actions/checkout@v6
1414
with:
1515
ref: gh-pages
1616
- run: git config user.name "github-actions[bot]"

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@v6
1919
with:
2020
persist-credentials: false
2121
- uses: actions/setup-python@v6

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v6
1515
with:
1616
persist-credentials: false
1717
- uses: actions/setup-python@v6

.github/workflows/update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
python-version: "3.x"
1919
- uses: astral-sh/setup-uv@v7
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
- run: sudo apt-get install -y gettext
2222
- run: pip install -r requirements.txt
2323
- run: uv run generate.py # generates index.html and index.json

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
![website status](https://img.shields.io/website?url=https%3A%2F%2Ftranslations.python.org&logoColor=yellow&label=website%20status)
2+
[![lint](https://github.com/python-docs-translations/dashboard/actions/workflows/lint.yml/badge.svg)](https://github.com/python-docs-translations/dashboard/actions/workflows/lint.yml)
3+
4+
This project generates a dashboard presenting the Python documentation translations projects available at [translations.python.org](https://translations.python.org).
5+
6+
There are two entrypoints:
7+
- `generate.py`: Generates dashboard HTML and JSON files.
8+
- `generate_build_details.py`: Generates the build details HTML file and log files for each translation project.

completion.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
2323
clone_path = Path(clones_dir, 'translations', repo)
2424
for branch in branches_from_peps() + ['master', 'main']:
2525
try:
26-
clone_repo = git.Repo.clone_from(
27-
f'https://github.com/{repo}.git', clone_path, branch=branch
28-
)
26+
if not clone_path.exists():
27+
clone_repo = git.Repo.clone_from(
28+
f'https://github.com/{repo}.git', clone_path, branch=branch
29+
)
30+
else:
31+
(clone_repo := git.Repo(clone_path)).git.fetch()
32+
clone_repo.git.switch(branch)
33+
clone_repo.git.pull()
2934
except git.GitCommandError:
30-
print(f'failed to clone {repo} {branch}')
35+
print(f'failure: {branch} {repo}: clone or switch, continuing')
3136
branch = ''
3237
continue
3338
else:
39+
print(f'success: {branch} {repo}: clone or switch')
3440
break
3541
path_for_merge = Path(clones_dir, 'rebased_translations', repo)
3642
completion = potodo.merge_and_scan_paths(

generate.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import json
24
import concurrent.futures
35
import itertools
@@ -20,20 +22,26 @@
2022
generation_time = datetime.now(timezone.utc)
2123

2224

23-
def get_completion_progress() -> Iterator['LanguageProjectData']:
25+
def get_completion_progress() -> Iterator[LanguageProjectData]:
2426
clones_dir = Path('clones')
25-
Repo.clone_from(
26-
'https://github.com/python/devguide.git',
27-
devguide_dir := Path(clones_dir, 'devguide'),
28-
depth=1,
29-
)
27+
if not (devguide_dir := Path(clones_dir, 'devguide')).exists():
28+
Repo.clone_from('https://github.com/python/devguide.git', devguide_dir, depth=1)
29+
else:
30+
Repo(devguide_dir).git.pull()
3031
latest_branch = branches_from_peps()[0]
31-
Repo.clone_from(
32-
'https://github.com/python/cpython.git',
33-
cpython_dir := Path(clones_dir, 'cpython'),
34-
depth=1,
35-
branch=latest_branch,
36-
)
32+
if not (cpython_dir := Path(clones_dir, 'cpython')).exists():
33+
Repo.clone_from(
34+
'https://github.com/python/cpython.git',
35+
cpython_dir,
36+
depth=1,
37+
branch=latest_branch,
38+
)
39+
else:
40+
(cpython_repo := Repo(cpython_dir)).git.fetch()
41+
cpython_repo.git.switch(latest_branch)
42+
cpython_repo.git.pull()
43+
44+
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'clean'], check=True)
3745
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
3846
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)
3947

@@ -56,7 +64,7 @@ def get_project_data(
5664
repo: str | None,
5765
languages_built: dict[str, str],
5866
clones_dir: str,
59-
) -> 'LanguageProjectData':
67+
) -> LanguageProjectData:
6068
built = language.code in languages_built
6169
if repo:
6270
completion, branch, change = get_completion(clones_dir, repo)

src/style.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ body {
5858
flex: 1;
5959
}
6060

61+
.card:target {
62+
scroll-margin-top: 4.5rem;
63+
border-color: #1178cc;
64+
}
65+
6166
.card-body p {
6267
margin-bottom: 0;
6368
margin-top: 0;
@@ -67,6 +72,24 @@ body {
6772
margin-bottom: 0.4rem;
6873
}
6974

75+
.card-title a {
76+
color: inherit;
77+
text-decoration: none;
78+
border-radius: 4px;
79+
padding: 0 4px;
80+
margin: 0 -4px;
81+
}
82+
83+
.card-title a::after {
84+
content: " #";
85+
font-size: 0.8em;
86+
color: #7ec3ff;
87+
}
88+
89+
.card-title a:focus, .card-title a:hover {
90+
background-color: #f5e9a8;
91+
}
92+
7093
/* ------------------------------ Index ------------------------------------- */
7194

7295
.progress-bar-container {

templates/index.html.jinja

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
<div class="row">
66
{% for project in completion_progress | sort(attribute='completion') | reverse %}
77
<div class="col-12 col-sm-6 col-md-4 d-flex">
8-
<div class="card shadow mb-3 w-100">
8+
<div id="{{ project.language.code }}" class="card shadow mb-3 w-100">
99
<div class="card-body">
10-
<h3 class="card-title">{{ project.language.name }}</h3>
10+
<h3 class="card-title"><a href="#{{ project.language.code }}">{{ project.language.name }}</a></h3>
1111
<h5 class="card-subtitle mb-2 text-muted">{{ project.translated_name }}</h5>
1212
<p class="text-muted">Completion: <strong>{{ '{:.2f}%'.format(project.completion) }}</strong></p>
1313
<p class="text-muted">30-day progress: {{ '{:.2f}%'.format(project.change) }}</p>
1414

1515
<p style="text-align: center;">
1616
{% if project.built %}
17-
<a href="https://docs.python.org/{{ project.language.code }}/3/" style="color: #1595fe;">View {{ project.language.name }}</a>
17+
<a href="https://docs.python.org/{{ project.language.code }}/3/" style="color: #1178cc;">View {{ project.language.name }}</a>
1818
1919
{% endif %}
2020
{% if project.contribution_link %}
21-
<a href="{{ project.contribution_link }}" style="color: #1595fe;">Contribute to {{ project.language.name }}</a>
21+
<a href="{{ project.contribution_link }}" style="color: #1178cc;">Contribute</a>
2222
{% elif project.uses_platform %}
23-
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1595fe;">Contribute to {{ project.language.name }}</a>
23+
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1178cc;">Contribute to {{ project.language.name }}</a>
2424
{% else %}
25-
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1595fe;">Contribute to {{ project.language.name }}</a>
25+
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1178cc;">Contribute to {{ project.language.name }}</a>
2626
{% endif %}
2727
</p>
2828
<div class="progress-bar-container">

0 commit comments

Comments
 (0)