Skip to content

Commit eed321c

Browse files
committed
store lint failures in files
1 parent db4d621 commit eed321c

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

generate_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_metadata(
7979
and completion
8080
and (
8181
build_warnings.number(clones_dir, repo, language.code),
82-
sum(sphinx_lint.errors(clones_dir, repo)),
82+
sphinx_lint.store_and_count_failures(clones_dir, repo, language.code),
8383
)
8484
) or (0, 0)
8585

metadata.html.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
<td data-label="warnings">
2626
{% if project.completion %}<a href="warnings-{{ project.language.code }}.txt">{{ metadata[0] }}</a>{% else %}{{ metadata[0] }}{% endif %}
2727
</td>
28-
<td data-label="lint">{{ metadata[1] }}</td>
28+
<td data-label="lint">
29+
{% if project.completion %}<a href="warnings-lint-{{ project.language.code }}.txt">{{ metadata[1] }}</a>{% else %}{{ metadata[1] }}{% endif %}
30+
</td>
2931
</tr>
3032
{% endfor %}
3133
</tbody>

sphinx_lint.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
from collections.abc import Iterator
2+
from itertools import chain
23
from pathlib import Path
34

45
from sphinxlint import check_file, checkers
56

67

7-
def errors(clones_dir: str, repo: str) -> Iterator[int]:
8+
def store_and_count_failures(clones_dir: str, repo: str, language_code: str) -> int:
9+
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]))
12+
return len(failed_checks)
13+
14+
15+
def yield_failures(clones_dir: str, repo: str) -> Iterator[str]:
16+
enabled_checkers = [c for c in checkers.all_checkers.values() if c.enabled]
817
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-
)
18+
yield check_file(path.as_posix(), enabled_checkers)

0 commit comments

Comments
 (0)