Skip to content

Commit f4db75c

Browse files
committed
Track number of Sphinx build warnings
1 parent 8115356 commit f4db75c

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

.github/workflows/update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- run: sudo apt-get install -y gettext
2121
- run: uv run generate.py # generates "index.html"
22-
- run: mkdir -p build && cp index.html style.css build
22+
- run: mkdir -p build && cp index.html style.css warnings* build
2323
- name: Deploy 🚀
2424
if: github.event_name != 'pull_request'
2525
uses: JamesIves/github-pages-deploy-action@v4

build_warnings.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pathlib import Path
2+
from shutil import copyfile
3+
4+
import sphinx.cmd.build
5+
6+
7+
def number(clones_dir: str, repo: str, language_code: str) -> int:
8+
Path(clones_dir, f'cpython/Doc/locales/{language_code}').mkdir(parents=True)
9+
Path(clones_dir, f'cpython/Doc/locales/{language_code}/LC_MESSAGES').symlink_to(
10+
Path(clones_dir, repo), True
11+
)
12+
sphinx.cmd.build.main(
13+
(
14+
'--builder',
15+
'html',
16+
'--fresh-env',
17+
'--jobs',
18+
'auto',
19+
'--define',
20+
f'language={language_code}',
21+
'--verbose',
22+
'--warning-file',
23+
warning_file := f'{clones_dir}/warnings-{language_code}.txt',
24+
f'{clones_dir}/cpython/Doc', # sourcedir
25+
'./build', # outputdir
26+
)
27+
)
28+
copyfile(warning_file, f'warnings-{language_code}.txt')
29+
return len(Path(warning_file).read_text().splitlines())

generate.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# "jinja2",
77
# "requests",
88
# "docutils",
9+
# "sphinx",
10+
# "python-docs-theme",
911
# ]
1012
# ///
1113
import subprocess
@@ -19,11 +21,12 @@
1921
from git import Repo
2022
from jinja2 import Template
2123

22-
import contribute
24+
import build_warnings
2325
import build_status
26+
import contribute
2427
from visitors import get_number_of_visitors
2528
from completion import branches_from_devguide, get_completion, TranslatorsData
26-
from repositories import get_languages_and_repos, Language
29+
from repositories import Language, get_languages_and_repos
2730

2831
generation_time = datetime.now(timezone.utc)
2932

@@ -50,16 +53,19 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
5053
if repo:
5154
completion, translators_data = get_completion(clones_dir, repo)
5255
visitors_num = get_number_of_visitors(language.code) if built else 0
56+
issues = build_warnings.number(clones_dir, repo, language.code)
5357
else:
5458
completion = 0.0
5559
translators_data = TranslatorsData(0, False)
5660
visitors_num = 0
61+
issues = 0
5762
yield LanguageProjectData(
5863
language,
5964
repo,
6065
completion,
6166
translators_data,
6267
visitors_num,
68+
issues,
6369
built,
6470
in_switcher=languages_built.get(language.code),
6571
uses_platform=language.code in contribute.pulling_from_transifex,
@@ -74,6 +80,7 @@ class LanguageProjectData:
7480
completion: float
7581
translators: TranslatorsData
7682
visitors: int
83+
issues: int
7784
built: bool
7885
in_switcher: bool | None
7986
uses_platform: bool

style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ th {
3939
.progress-bar.low + .progress-bar-outer-label {
4040
display: inline-block;
4141
}
42-
td[data-label="visitors"], td[data-label="translators"] {
42+
td[data-label="visitors"], td[data-label="translators"], td[data-label="issues"] {
4343
text-align: right;
4444
}
4545
td[data-label="completion"] {

template.html.jinja

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
<th>language</th>
1313
<th>contribute</th>
1414
<th>build</th>
15-
<th>visitors*</th>
15+
<th>visitors¹</th>
1616
<th>translators</th>
17+
<th>warnings²</th>
1718
<th>completion</th>
1819
</tr>
1920
</thead>
@@ -47,6 +48,7 @@
4748
{{ project.translators.number }}
4849
{% if project.translators.link %}</a>{% endif %}
4950
</td>
51+
<td data-label="issues"><a href="warnings-{{ project.language.code }}.txt" target="_blank">{{ project.issues }}</a></td>
5052
<td data-label="completion">
5153
<div class="progress-bar" style="width: {{ project.completion }}%;">{{ "{:.2f}".format(project.completion) }}%</div>
5254
<div class="progress-bar-outer-label">{{ "{:.2f}".format(project.completion) }}%</div>
@@ -55,7 +57,8 @@
5557
{% endfor %}
5658
</tbody>
5759
</table>
58-
<p>* sum of <a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies" target="_blank">daily unique visitors</a> since 8 June 2024</p>
60+
<p>¹ sum of <a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies" target="_blank">daily unique visitors</a> since 8 June 2024</p>
61+
<p>² number of Sphinx build process warnings</p>
5962
<p>For more information about translations, see the <a href="https://devguide.python.org/documentation/translating/" target="_blank">Python Developer’s Guide</a>.</p>
6063
<p>Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
6164
</body>

0 commit comments

Comments
 (0)