Skip to content

Commit f12ceb5

Browse files
committed
fix: automatically include all contributor stats tables
1 parent b76e77a commit f12ceb5

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed

_data/modules.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
modules:
2+
- total
3+
- aw-core
4+
- aw-server
5+
- aw-server-rust
6+
- aw-webui
7+
- aw-qt
8+
- aw-tauri
9+
- aw-android
10+
- aw-client
11+
- aw-client-js
12+
- aw-client-rust
13+
- aw-watcher-afk
14+
- aw-watcher-window
15+
- aw-watcher-window-wayland
16+
- aw-watcher-input
17+
- aw-watcher-web
18+
- aw-watcher-vscode
19+
- aw-watcher-vim
20+
- awatcher
21+
- aw-notify
22+
- aw-supabase
23+
- aw-leaderboard-firebase
24+
- aw-leaderboard-rust
25+
- docs
26+
- activitywatch.github.io
27+
- activitywatch

contributors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ <h3>Tables</h3>
6565
</small>
6666
</p>
6767

68-
{% assign modules = "total,aw-core,aw-server,aw-server-rust,aw-webui,aw-qt,aw-tauri,aw-android,aw-client,aw-client-js,aw-client-rust,aw-watcher-window,aw-watcher-afk,aw-watcher-input,aw-watcher-web,aw-watcher-vim,aw-watcher-vscode,awatcher,aw-notify,aw-leaderboard-firebase,aw-supabase,docs,activitywatch.github.io,activitywatch" | split: ',' %}
68+
{% assign modules = site.data.modules.modules %}
6969

7070
<b>Table of contents</b>
7171
<ul>

generate_modules_yml.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
5+
import yaml
6+
7+
# Directory containing the HTML files
8+
tables_dir = "_includes/tables"
9+
10+
# Output YAML file
11+
output_file = "_data/modules.yml"
12+
13+
# Exclude this file
14+
exclude_file = "github-stats.html"
15+
16+
17+
def load_existing_modules():
18+
if os.path.exists(output_file):
19+
with open(output_file, "r") as file:
20+
data = yaml.safe_load(file)
21+
return data.get("modules", [])
22+
return []
23+
24+
25+
def save_modules(modules):
26+
data = {"modules": modules}
27+
with open(output_file, "w") as file:
28+
yaml.dump(data, file, default_flow_style=False)
29+
30+
31+
def generate_modules_yml():
32+
# List all HTML files in the tables directory, excluding the specified file
33+
new_modules = [
34+
f.replace(".html", "")
35+
for f in os.listdir(tables_dir)
36+
if f.endswith(".html") and f != exclude_file
37+
]
38+
39+
# Load existing modules
40+
existing_modules = load_existing_modules()
41+
42+
# Add new modules to the end of the existing list, preserving order
43+
for module in new_modules:
44+
if module not in existing_modules:
45+
existing_modules.append(module)
46+
47+
# Save the updated list of modules
48+
save_modules(existing_modules)
49+
50+
print(f"Generated {output_file} with modules: {existing_modules}")
51+
52+
53+
if __name__ == "__main__":
54+
generate_modules_yml()

scripts/generate_modules_yml.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
import yaml
3+
4+
# Directory containing the HTML files
5+
tables_dir = '_includes/tables'
6+
7+
# Output YAML file
8+
output_file = '_data/modules.yml'
9+
10+
# Exclude this file
11+
exclude_file = 'github-stats.html'
12+
13+
def load_existing_modules():
14+
if os.path.exists(output_file):
15+
with open(output_file, 'r') as file:
16+
data = yaml.safe_load(file)
17+
return data.get('modules', [])
18+
return []
19+
20+
def save_modules(modules):
21+
data = {'modules': modules}
22+
with open(output_file, 'w') as file:
23+
yaml.dump(data, file, default_flow_style=False)
24+
25+
def generate_modules_yml():
26+
# List all HTML files in the tables directory, excluding the specified file
27+
new_modules = [f.replace('.html', '') for f in os.listdir(tables_dir) if f.endswith('.html') and f != exclude_file]
28+
29+
# Load existing modules
30+
existing_modules = load_existing_modules()
31+
32+
# Add new modules to the end of the existing list, preserving order
33+
for module in new_modules:
34+
if module not in existing_modules:
35+
existing_modules.append(module)
36+
37+
# Save the updated list of modules
38+
save_modules(existing_modules)
39+
40+
print(f"Generated {output_file} with modules: {existing_modules}")
41+
42+
if __name__ == "__main__":
43+
generate_modules_yml()

0 commit comments

Comments
 (0)