added stylisher badges

This commit is contained in:
Maccesch 2023-06-10 04:49:34 +01:00
parent b3f0cb799a
commit 4cabc25ec5
3 changed files with 15 additions and 2 deletions

View file

@ -26,6 +26,8 @@ jobs:
components: rustfmt components: rustfmt
- name: Cache - name: Cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Check function count badge
run: python3 docs/generate_count_badge.py --check
- name: Check formatting - name: Check formatting
run: cargo fmt --check run: cargo fmt --check
# - name: Check if the README is up to date. # - name: Check if the README is up to date.

View file

@ -10,7 +10,7 @@
<p align="center"> <p align="center">
<a href="https://crates.io/crates/leptos-use"><img src="https://img.shields.io/crates/v/leptos-use.svg?label=&color=%232C1275" alt="Crates.io"/></a> <a href="https://crates.io/crates/leptos-use"><img src="https://img.shields.io/crates/v/leptos-use.svg?label=&color=%232C1275" alt="Crates.io"/></a>
<a href="https://leptos-use.rs"><img src="https://img.shields.io/badge/-docs%20%26%20demos-%239A233F" alt="Docs & Demos"></a> <a href="https://leptos-use.rs"><img src="https://img.shields.io/badge/-docs%20%26%20demos-%239A233F" alt="Docs & Demos"></a>
<a href="https://leptos-use.rs"><img src="https://img.shields.io/badge/-23%20functions-%23EF3939" alt="23 Functions" /></a> <a href="https://leptos-use.rs"><img src="https://img.shields.io/badge/-22%20functions-%23EF3939" alt="23 Functions" /></a>
</p> </p>
<br/> <br/>

View file

@ -1,5 +1,6 @@
import os import os
import re import re
import sys
def main(): def main():
count = 0 count = 0
@ -13,12 +14,22 @@ def main():
print(f"Found {count} functions") print(f"Found {count} functions")
with open("README.md", "r") as f: with open("README.md", "r") as f:
original_text = f.read()
text = re.sub( text = re.sub(
r'<img src="https://img.shields.io/badge/-\d+%20functions-%23EF3939" alt="\d+ Functions"', r'<img src="https://img.shields.io/badge/-\d+%20functions-%23EF3939" alt="\d+ Functions"',
f'<img src="https://img.shields.io/badge/-{count}%20functions-%23EF3939" alt="{count} Functions"', f'<img src="https://img.shields.io/badge/-{count}%20functions-%23EF3939" alt="{count} Functions"',
f.read() original_text
) )
if sys.argv[1] == "--check":
if original_text != text:
print("[Failed] README.md doesn't have the correct function count badge", file=sys.stderr)
print(" * Run `python3 docs/generate_count_badge.py` to fix", file=sys.stderr)
quit(1)
else:
print("[OK] README.md has the correct function count badge")
quit(0)
with open("README.md", "w") as f: with open("README.md", "w") as f:
f.write(text) f.write(text)