Skip to content

Commit 3e3087a

Browse files
committed
add sphinx-lint
1 parent 37d10bd commit 3e3087a

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

generate_metadata.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# "sphinx",
88
# "python-docs-theme",
99
# "dacite",
10+
# "sphinx-lint",
1011
# ]
1112
# ///
1213
import concurrent.futures
@@ -27,6 +28,7 @@
2728
from urllib3 import request
2829

2930
import build_warnings
31+
import sphinx_lint
3032
from completion import branches_from_devguide
3133
from generate import LanguageProjectData
3234
from repositories import Language
@@ -36,7 +38,7 @@
3638

3739
def get_projects_metadata(
3840
completion_progress: Sequence[LanguageProjectData],
39-
) -> Iterator[int]:
41+
) -> Iterator[tuple[int, int]]:
4042
with TemporaryDirectory() as clones_dir:
4143
Repo.clone_from(
4244
'https://github.com/python/devguide.git',
@@ -68,13 +70,18 @@ def get_metadata(
6870
branch: str | None,
6971
completion: float,
7072
clones_dir: str,
71-
) -> int:
73+
) -> tuple[int, int]:
7274
if repo:
7375
clone_path = Path(clones_dir, repo)
7476
git.Repo.clone_from(f'https://github.com/{repo}.git', clone_path, branch=branch)
7577
return (
76-
repo and completion and build_warnings.number(clones_dir, repo, language.code)
77-
) or 0
78+
repo
79+
and completion
80+
and (
81+
build_warnings.number(clones_dir, repo, language.code),
82+
sum(sphinx_lint.errors(clones_dir, repo)),
83+
)
84+
) or (0, 0)
7885

7986

8087
def get_language_repo_branch_and_completion(

metadata.html.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
<td data-label="language">{{ project.language.name }} ({{ project.language.code }})</td>
2323
<td data-label="branch">{{ project.branch }}</td>
2424
<td data-label="warnings">
25-
{% if project.completion %}<a href="warnings-{{ project.language.code }}.txt">{{ metadata }}</a>{% else %}{{ metadata }}{% endif %}
25+
{% if project.completion %}<a href="warnings-{{ project.language.code }}.txt">{{ metadata[0] }}</a>{% else %}{{ metadata[0] }}{% endif %}
2626
</td>
27+
<td data-label="lint">{{ metadata[1] }}</td>
2728
</tr>
2829
{% endfor %}
2930
</tbody>

sphinx_lint.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from collections.abc import Iterator
2+
from pathlib import Path
3+
4+
from sphinxlint import check_file, checkers
5+
6+
7+
def errors(clones_dir: str, repo: str) -> Iterator[int]:
8+
for path in Path(clones_dir, repo).rglob('*.po'):
9+
yield len(
10+
check_file(
11+
path.as_posix(),
12+
[c for c in checkers.all_checkers.values() if c.enabled],
13+
)
14+
)

0 commit comments

Comments
 (0)