Skip to content

Commit 4a48b38

Browse files
Merge branch 'main' into build-details
# Conflicts: # templates/build-details.html.jinja
2 parents 3f5e339 + 2ebddbc commit 4a48b38

File tree

9 files changed

+93
-173
lines changed

9 files changed

+93
-173
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Lint
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
49

510
env:
611
FORCE_COLOR: 1

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
index.html
2-
metadata.html
3-
warnings-*.txt
1+
build
42
clones
3+
venv

completion.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import json
2-
from dataclasses import dataclass
32
from functools import cache
43
from pathlib import Path
54
from tempfile import TemporaryDirectory
6-
from typing import Literal
75

86
import git
97
from potodo import potodo
108

11-
import translators
12-
139

1410
@cache
1511
def branches_from_devguide(devguide_dir: Path) -> list[str]:
@@ -22,9 +18,7 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]:
2218
]
2319

2420

25-
def get_completion(
26-
clones_dir: str, repo: str
27-
) -> tuple[float, 'TranslatorsData', str, float]:
21+
def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
2822
clone_path = Path(clones_dir, 'translations', repo)
2923
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + [
3024
'master',
@@ -36,13 +30,9 @@ def get_completion(
3630
)
3731
except git.GitCommandError:
3832
print(f'failed to clone {repo} {branch}')
39-
translators_data = TranslatorsData(0, False)
4033
branch = ''
4134
continue
4235
else:
43-
translators_number = translators.get_number(clone_path)
44-
translators_link = translators.get_link(clone_path, repo, branch)
45-
translators_data = TranslatorsData(translators_number, translators_link)
4636
break
4737
path_for_merge = Path(clones_dir, 'rebased_translations', repo)
4838
completion = potodo.merge_and_scan_path(
@@ -77,10 +67,4 @@ def get_completion(
7767

7868
change = completion - month_ago_completion
7969

80-
return completion, translators_data, branch, change
81-
82-
83-
@dataclass(frozen=True)
84-
class TranslatorsData:
85-
number: int
86-
link: str | Literal[False]
70+
return completion, branch, change

generate.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import build_status
1616
import contribute
17-
from completion import branches_from_devguide, get_completion, TranslatorsData
17+
from completion import branches_from_devguide, get_completion
1818
from repositories import Language, get_languages_and_repos
1919

2020
generation_time = datetime.now(timezone.utc)
@@ -59,10 +59,9 @@ def get_project_data(
5959
) -> 'LanguageProjectData':
6060
built = language.code in languages_built
6161
if repo:
62-
completion, translators_data, branch, change = get_completion(clones_dir, repo)
62+
completion, branch, change = get_completion(clones_dir, repo)
6363
else:
6464
completion = 0.0
65-
translators_data = TranslatorsData(0, False)
6665
change = 0.0
6766
branch = ''
6867

@@ -72,7 +71,6 @@ def get_project_data(
7271
branch,
7372
completion,
7473
change,
75-
translators_data,
7674
built,
7775
translated_name=languages_built.get(language.code, ''),
7876
uses_platform=language.code in contribute.pulling_from_transifex,
@@ -87,7 +85,6 @@ class LanguageProjectData:
8785
branch: str
8886
completion: float
8987
change: float
90-
translators: TranslatorsData
9188
built: bool
9289
translated_name: str
9390
uses_platform: bool

sphinx_lint.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
def store_and_count_failures(clones_dir: str, repo: str, language_code: str) -> int:
99
failed_checks = list(chain.from_iterable(yield_failures(clones_dir, repo)))
10-
filepath = Path(f'warnings-lint-{language_code}.txt')
11-
filepath.write_text('\n'.join([str(c) for c in failed_checks]))
10+
prefix = f'{Path(clones_dir, "rebased_translations", repo)}/'
11+
log = '\n'.join(
12+
map(lambda check: check.removeprefix(prefix), map(str, failed_checks))
13+
)
14+
filepath = Path(f'build/warnings-lint-{language_code}.txt')
15+
filepath.write_text(log)
1216
return len(failed_checks)
1317

1418

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ a:hover {
7272
position: relative;
7373
}
7474

75-
.progress-bar-index {
75+
.progress-bar {
7676
display: inline-block;
7777
color: white;
7878
height: 100%;

templates/build-details.html.jinja

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,40 @@
22

33
{% block main %}
44
<table>
5-
<thead>
6-
<tr>
7-
<th>language</th>
8-
<th>branch</th>
9-
<th>last updated</th>
10-
<th>build warnings*</th>
11-
<th>lint failures</th>
12-
</tr>
13-
</thead>
14-
<tbody>
15-
{% for project, metadata in build_details | sort(attribute='0.completion,0.translators.number') | reverse %}
16-
<tr>
17-
<td data-label="language">{{ project.language.name }} ({{ project.language.code }})</td>
18-
<td data-label="branch">{{ project.branch }}</td>
19-
<td data-label="updated">{{ metadata[2].strftime('%Y/%m/%d %T') if metadata[2] else '' }}</td>
20-
<td data-label="warnings">
21-
{% if project.completion %}<a href="warnings-{{ project.language.code }}.txt">{{ metadata[0] }}</a>{% else %}{{ metadata[0] }}{% endif %}
22-
</td>
23-
<td data-label="lint">
24-
{% if project.completion %}<a href="warnings-lint-{{ project.language.code }}.txt">{{ metadata[1] }}</a>{% else %}{{ metadata[1] }}{% endif %}
25-
</td>
26-
</tr>
27-
{% endfor %}
28-
</tbody>
5+
<thead>
6+
<tr>
7+
<th>language</th>
8+
<th>branch</th>
9+
<th>last updated</th>
10+
<th>build warnings*</th>
11+
<th>lint failures</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
{% for project, metadata in metadata | sort(attribute='0.completion') | reverse %}
16+
<tr>
17+
<td data-label="language">{{ project.language.name }} ({{ project.language.code }})</td>
18+
<td data-label="branch">{{ project.branch }}</td>
19+
<td data-label="updated">{{ metadata[2].strftime('%Y/%m/%d %T') if metadata[2] else '' }}</td>
20+
<td data-label="warnings">
21+
{% if project.completion %}
22+
<a href="warnings-{{ project.language.code }}.txt">{{ metadata[0] }}</a>
23+
{% else %}
24+
{{ metadata[0] }}
25+
{% endif %}
26+
</td>
27+
<td data-label="lint">
28+
{% if project.completion %}
29+
<a href="warnings-lint-{{ project.language.code }}.txt">{{ metadata[1] }}</a>
30+
{% else %}
31+
{{ metadata[1] }}
32+
{% endif %}
33+
</td>
34+
</tr>
35+
{% endfor %}
36+
</tbody>
2937
</table>
38+
3039
<p>* number of Sphinx build process warnings</p>
31-
<p>Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
40+
<p>Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
3241
{% endblock %}

templates/index.html.jinja

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
11
{% extends "base.html.jinja" %}
22

33
{% block main %}
4-
<div>
5-
<div class="row">
6-
{% for project in completion_progress | sort(attribute='completion,translators.number') | reverse %}
7-
<div class="col-12 col-sm-6 col-md-4 d-flex">
8-
<div class="card shadow mb-3 w-100">
9-
<div class="card-body">
10-
<h3 class="card-title">{{ project.language.name }}</h3>
11-
<h5 class="card-subtitle mb-2 text-muted">{{ project.translated_name }}</h5>
12-
<p class="text-muted">Completion: <strong>{{ '{:.2f}%'.format(project.completion) }}</strong></p>
13-
<p class="text-muted">30-day progress: {{ '{:.2f}%'.format(project.change) }}</p>
14-
<p style="text-align: center;">
15-
{% if project.built %}
16-
<a href="https://docs.python.org/{{ project.language.code }}/3/" style="color: #1595fe;">View</a>
17-
18-
{% endif %}
19-
{% if project.contribution_link %}
20-
<a href="{{ project.contribution_link }}" style="color: #1595fe;">Contribute</a>
21-
{% elif project.uses_platform %}
22-
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1595fe;">Contribute</a>
23-
{% else %}
24-
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1595fe;">Contribute</a>
25-
{% endif %}
26-
</p>
27-
<div class="progress-bar-container">
28-
<div class="progress-bar-index" style="width: {{ project.completion }}%;
29-
{% if project.change %}
30-
background: linear-gradient(to left, #94cf96 {{ project.change * 100 / project.completion }}%, #4caf50 {{ project.change * 100 / project.completion }}%);
31-
{% else %}
32-
background-color: #4caf50;
33-
{% endif %}">
34-
</div>
35-
</div>
4+
<div>
5+
<div class="row">
6+
{% for project in completion_progress | sort(attribute='completion') | reverse %}
7+
<div class="col-12 col-sm-6 col-md-4 d-flex">
8+
<div class="card shadow mb-3 w-100">
9+
<div class="card-body">
10+
<h3 class="card-title">{{ project.language.name }}</h3>
11+
<h5 class="card-subtitle mb-2 text-muted">{{ project.translated_name }}</h5>
12+
<p class="text-muted">Completion: <strong>{{ '{:.2f}%'.format(project.completion) }}</strong></p>
13+
<p class="text-muted">30-day progress: {{ '{:.2f}%'.format(project.change) }}</p>
14+
15+
<p style="text-align: center;">
16+
{% if project.built %}
17+
<a href="https://docs.python.org/{{ project.language.code }}/3/" style="color: #1595fe;">View</a>
18+
19+
{% endif %}
20+
{% if project.contribution_link %}
21+
<a href="{{ project.contribution_link }}" style="color: #1595fe;">Contribute</a>
22+
{% elif project.uses_platform %}
23+
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1595fe;">Contribute</a>
24+
{% else %}
25+
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1595fe;">Contribute</a>
26+
{% endif %}
27+
</p>
28+
<div class="progress-bar-container">
29+
<div class="progress-bar" style="width: {{ project.completion }}%;
30+
{% if project.change %}
31+
background: linear-gradient(to left, #94cf96 {{ project.change * 100 / project.completion }}%, #4caf50 {{ project.change * 100 / project.completion }}%);
32+
{% else %}
33+
background-color: #4caf50;
34+
{% endif %}">
3635
</div>
3736
</div>
3837
</div>
39-
{% endfor %}
38+
</div>
4039
</div>
41-
</div>
40+
{% endfor %}
41+
</div>
42+
</div>
4243

43-
<p style="text-align: center;">
44-
Last updated {{ generation_time.strftime('on %A %-d %B %Y at %-H:%M:%S %Z') }} (in {{ duration // 60 }} minutes and {{ duration % 60 }} seconds).<br/>
45-
You can find the scripts used to generate this website <a href="https://github.com/python-docs-translations/dashboard/">on GitHub</a>.<br/>
46-
You can download the data on this page in <a href="https://raw.githubusercontent.com/python-docs-translations/dashboard/refs/heads/gh-pages/index.json">JSON format</a>.
47-
</p>
44+
<p style="text-align: center;">
45+
Last updated {{ generation_time.strftime('on %A %-d %B %Y at %-H:%M:%S %Z') }} (in {{ duration // 60 }} minutes and {{ duration % 60 }} seconds).<br/>
46+
You can find the scripts used to generate this website <a href="https://github.com/python-docs-translations/dashboard/">on GitHub</a>.<br/>
47+
You can download the data on this page in <a href="https://raw.githubusercontent.com/python-docs-translations/dashboard/refs/heads/gh-pages/index.json">JSON format</a>.
48+
</p>
4849
{% endblock %}

translators.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)