Leave zero-byte languages out of the stats chart
This commit is contained in:
1 parent
73d2a83250
commit
9f76bf6c41
2 files changed
+14
-1
No files matched your search
@@ -200,7 +200,9 @@ def generate_markdown(totals: dict[str, int]) -> str:
|
||||
if total_bytes == 0:
|
||||
return ""
|
||||
|
||||
pairs = sorted(totals.items(), key=lambda x: x[1], reverse=True)
|
||||
# Languages whose bytes were all excluded would otherwise show as 0.0%
|
||||
nonzero = [(lang, nbytes) for lang, nbytes in totals.items() if nbytes > 0]
|
||||
pairs = sorted(nonzero, key=lambda x: x[1], reverse=True)
|
||||
|
||||
lang_lines = []
|
||||
for lang, nbytes in pairs:
|
||||
|
||||
@@ -193,6 +193,17 @@ def test_markdown_percentages_are_rounded_to_one_decimal():
|
||||
)
|
||||
|
||||
|
||||
def test_markdown_leaves_out_languages_with_zero_bytes():
|
||||
# e.g. every HTML byte came from excluded files
|
||||
assert generate_markdown({"Python": 750, "JavaScript": 250, "HTML": 0}) == (
|
||||
"## 📊 Languages\n"
|
||||
+ "█" * 37
|
||||
+ " Python 75.0%\\\n"
|
||||
+ "█" * 12
|
||||
+ " JavaScript 25.0%"
|
||||
)
|
||||
|
||||
|
||||
def test_markdown_is_empty_when_there_are_no_languages():
|
||||
assert generate_markdown({}) == ""
|
||||
|
||||
|
||||
Reference in new issue
Block a user