Skip to content

Commit 01c9d56

Browse files
authored
Merge pull request #146 from horw/docs/horw
add fan @horw
2 parents 38f6f83 + c4fbe22 commit 01c9d56

File tree

3 files changed

+126
-26
lines changed

3 files changed

+126
-26
lines changed

.github/workflows/format_fans.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Check fans format
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- index.html
8+
9+
jobs:
10+
check-format:
11+
runs-on: ubuntu-24.04
12+
steps:
13+
# Checkout the repository code
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
# Run the format validation script and check for changes
20+
- name: Validate fans list format
21+
run: |
22+
echo "Checking for changes in fans list format..."
23+
git status
24+
python format_fans.py
25+
CHANGED_FILES=$(git diff --name-only)
26+
27+
if echo "$CHANGED_FILES" | grep -q "index.html"; then
28+
echo "ERROR: The file 'index.html' has been modified by the formatter."
29+
echo "------ Detected Changes ------"
30+
git diff
31+
echo "--------------------------------"
32+
echo "You can download the modified file from the artifact here:"
33+
echo "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
34+
echo "Alternatively, run the test locally using:"
35+
echo " python format_fans.py"
36+
exit 1
37+
else
38+
echo "Fans list format is valid. No changes detected."
39+
fi
40+
41+
# Upload the modified file if the validation fails
42+
- name: Upload modified files
43+
if: failure()
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: index-modified-html
47+
path: index.html

format_fans.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import re
2+
3+
with open("./index.html") as f:
4+
lines = f.readlines()
5+
6+
fans_regex = re.compile(r'href="([^"]+)">@([^<]+)<')
7+
fans_set = set()
8+
9+
start_ind = -1
10+
last_ind = -1
11+
for ind, line in enumerate(lines):
12+
if start_ind != -1:
13+
if "</p>" in line:
14+
last_ind = ind
15+
break
16+
match = fans_regex.search(line.strip())
17+
if match:
18+
fans_set.add((match.group(1), match.group(2)))
19+
if "Fans (in alphabetical order):" in line:
20+
start_ind = ind
21+
22+
if start_ind == -1:
23+
raise ValueError("'Fans (in alphabetical order):' text not found in the index.html")
24+
if last_ind == -1:
25+
raise ValueError("Closing '</p>' tag for closing fans list not found.")
26+
27+
def sort_key(fan):
28+
"""
29+
Sorting key for fans:
30+
1. Sort by the first letter of the nickname (case-insensitive).
31+
2. If the first letter is the same, sort by whether it’s uppercase.
32+
3. Finally, sort alphabetically by the full nickname.
33+
"""
34+
_nickname = fan[1]
35+
return (
36+
_nickname[0].lower(),
37+
_nickname[0].isupper(),
38+
_nickname.lower(),
39+
)
40+
41+
42+
fans_list = sorted(fans_set, key=sort_key)
43+
44+
output = [
45+
f' <a href="{_url}">@{_nickname}</a>{"," if len(fans_list) - 1 != ind else "."}\n'
46+
for ind, (_url, _nickname) in enumerate(fans_list)
47+
]
48+
49+
lines[start_ind + 1 : last_ind] = output
50+
51+
with open("./index.html", "w+") as f:
52+
f.writelines(lines)

index.html

+27-26
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@
228228
<p>
229229
Fans (in alphabetical order):
230230
<a href="https://github.com/a2xchip">@a2xchip</a>,
231-
<a href="https://github.com/acidlynx">@acidlynx</a>,
232-
<a href="https://github.com/admin1475963">@admin1475963</a>,
231+
<a href="https://github.com/acidlynx">@acidlynx</a>,
232+
<a href="https://github.com/admin1475963">@admin1475963</a>,
233233
<a href="https://github.com/aikidistas">@aikidistas</a>,
234234
<a href="https://github.com/aistomin">@aistomin</a>,
235-
<a href="https://github.com/alex-semenyuk">@alex-semenyuk</a>,
236-
<a href="https://github.com/alhadhrami">@alhadhrami</a>
235+
<a href="https://github.com/alex-semenyuk">@alex-semenyuk</a>,
236+
<a href="https://github.com/alhadhrami">@alhadhrami</a>,
237237
<a href="https://github.com/aliceice">@aliceice</a>,
238238
<a href="https://twitter.com/amihaiemil">@amihaiemil</a>,
239239
<a href="https://github.com/andreoss">@andreoss</a>,
240-
<a href="https://github.com/AndreiGurko">@AndreiGurko</a>,
240+
<a href="https://github.com/AndreiGurko">@AndreiGurko</a>,
241241
<a href="https://github.com/baudoliver7">@baudoliver7</a>,
242242
<a href="https://github.com/biboran">@biboran</a>,
243243
<a href="https://github.com/birdflu">@birdflu</a>,
244244
<a href="https://github.com/dgroup">@dgroup</a>,
245-
<a href="https://github.com/dionisvl">@dionisvl</a>,
245+
<a href="https://github.com/dionisvl">@dionisvl</a>,
246246
<a href="https://twitter.com/dmydlarz">@dmydlarz</a>,
247247
<a href="https://github.com/driver733">@driver733</a>,
248248
<a href="https://github.com/DronMDF">@DronMDF</a>,
@@ -251,59 +251,60 @@
251251
<a href="https://github.com/ErickSumargo">@ErickSumargo</a>,
252252
<a href="https://github.com/fabriciofx">@fabriciofx</a>,
253253
<a href="https://github.com/filfreire">@filfreire</a>,
254-
<a href="https://github.com/Graur">@Graur</a>,
255-
<a href="https://github.com/gennadygennady">@gennadygennady</a>,
256254
<a href="https://github.com/g4s8">@g4s8</a>,
255+
<a href="https://github.com/gennadygennady">@gennadygennady</a>,
256+
<a href="https://github.com/Graur">@Graur</a>,
257257
<a href="https://github.com/h1alexbel">@h1alexbel</a>,
258+
<a href="https://github.com/horw">@horw</a>,
259+
<a href="https://github.com/iskanred">@iskanred</a>,
258260
<a href="https://github.com/ivanovmg">@ivanovmg</a>,
259-
<a href="https://github.com/iskanred">@iskanred</a>,
260-
<a href="https://github.com/Karpikova">@Karpikova</a>,
261-
<a href="https://github.com/kerelape">@kerelape</a>,
261+
<a href="https://github.com/kerelape">@kerelape</a>,
262262
<a href="https://github.com/koeeenig">@koeeenig</a>,
263263
<a href="https://github.com/kogoia">@kogoia</a>,
264+
<a href="https://github.com/Karpikova">@Karpikova</a>,
264265
<a href="https://github.com/l3r8yJ/">@l3r8yJ</a>,
265266
<a href="https://github.com/Maratori">@maratori</a>,
266-
<a href="https://github.com/marijnz0r">@marijnz0r</a>,
267-
<a href="https://github.com/Masynchin">@Masynchin</a>,
267+
<a href="https://github.com/marijnz0r">@marijnz0r</a>,
268268
<a href="https://github.com/maxonfjvipon">@maxonfjvipon</a>,
269269
<a href="https://github.com/Meerownymous">@meerownymous</a>,
270270
<a href="https://twitter.com/GraminMaksim">@mgramin</a>,
271+
<a href="https://github.com/Masynchin">@Masynchin</a>,
271272
<a href="https://github.com/MrHadiSatrio">@MrHadiSatrio</a>,
272273
<a href="https://github.com/MyNameIsNeXTSTEP">@MyNameIsNeXTSTEP</a>,
273-
<a href="https://github.com/nakhodkiin">@nakhodkiin</a>,
274+
<a href="https://github.com/nakhodkiin">@nakhodkiin</a>,
274275
<a href="https://twitter.com/nicholasruunu">@nicholasruunu</a>,
275-
<a href="https://github.com/NickKhalow/">@NickKhalow</a>,
276276
<a href="https://github.com/nikialeksey">@nikialeksey</a>,
277+
<a href="https://github.com/NickKhalow/">@NickKhalow</a>,
277278
<a href="https://github.com/paulodamaso">@paulodamaso</a>,
278279
<a href="https://github.com/pinguinjkeke">@pinguinjkeke</a>,
279280
<a href="https://github.com/pnatashap">@pnatashap</a>,
280-
<a href="https://github.com/proshin-roman">@proshin-roman</a>,
281+
<a href="https://github.com/proshin-roman">@proshin-roman</a>,
281282
<a href="https://github.com/raffaeleflorio">@raffaeleflorio</a>,
282283
<a href="https://github.com/ratra1">@ratra1</a>,
283284
<a href="https://github.com/roch1990">@roch1990</a>,
284-
<a href="https://github.com/rocket-3">@rocket-3</a>,
285+
<a href="https://github.com/rocket-3">@rocket-3</a>,
285286
<a href="https://twitter.com/RRochegude">@RRochegude</a>,
286-
<a href="https://github.com/Samdespion">@Samdespion</a>,
287-
<a href="https://github.com/silasreinagel">@SilasReinagel</a>,
288287
<a href="https://github.com/sitnikovik">@sitnikovik</a>,
289288
<a href="https://github.com/sivaa">@sivaa</a>,
290289
<a href="https://github.com/smallcreep">@smallcreep</a>,
291290
<a href="https://github.com/stepanets">@stepanets</a>,
292291
<a href="https://github.com/stepanvalyavskiy">@stepanvalyavskiy</a>,
293292
<a href="https://github.com/swardana">@swardana</a>,
294-
<a href="https://twitter.com/tomasz_bawor">@tomasz_bawor</a>,
295-
<a href="https://github.com/tihon49">@tihon49</a>,
293+
<a href="https://github.com/Samdespion">@Samdespion</a>,
294+
<a href="https://github.com/silasreinagel">@SilasReinagel</a>,
296295
<a href="https://github.com/t-izbassar">@t-izbassar</a>,
297-
<a href="https://github.com/uchitsa">@uchitsa</a>,
296+
<a href="https://github.com/tihon49">@tihon49</a>,
297+
<a href="https://twitter.com/tomasz_bawor">@tomasz_bawor</a>,
298+
<a href="https://github.com/uchitsa">@uchitsa</a>,
298299
<a href="https://github.com/Vatavuk">@vatavuk</a>,
299-
<a href="https://github.com/vblinden">@vblinden</a>,
300+
<a href="https://github.com/vblinden">@vblinden</a>,
300301
<a href="https://github.com/vhood">@vhood</a>,
301302
<a href="https://github.com/VsSekorin">@vssekorin</a>,
302-
<a href="https://github.com/vstan02">@vstan02</a>,
303+
<a href="https://github.com/vstan02">@vstan02</a>,
303304
<a href="https://github.com/vzurauskas">@vzurauskas</a>,
304-
<a href="https://github.com/xXdatelXx">@xXdatelXx</a>,
305+
<a href="https://github.com/xXdatelXx">@xXdatelXx</a>,
305306
<a href="https://github.com/yegor256">@yegor256</a>,
306-
<a href="https://github.com/ziplla">@ziplla</a>.
307+
<a href="https://github.com/ziplla">@ziplla</a>.
307308
</p>
308309
<p>
309310
Badges for your GitHub repo:

0 commit comments

Comments
 (0)