-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_readme.py
More file actions
948 lines (724 loc) · 34.2 KB
/
generate_readme.py
File metadata and controls
948 lines (724 loc) · 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
from __future__ import annotations
import html
import json
import os
import re
from datetime import datetime, timedelta, timezone
import urllib.error
import urllib.parse
import urllib.request
from pathlib import Path
ROOT = Path(__file__).resolve().parent
DATA_DIR = ROOT / "data"
OUTPUT = ROOT / "profile" / "README.md"
ORG_NAME = "CODE CREW NEXUS"
ORG_SLUG = "Code-Crew-Nexus"
PROFILE_REPO = ".github"
GITHUB_API_URL = "https://api.github.com"
RECENT_COMMITS_LIMIT = 6
REPOS_LIMIT = 25
INDIA_TZ = timezone(timedelta(hours=5, minutes=30), name="IST")
ACRONYMS = {"AI", "ML", "DBMS", "DAA", "OOP", "OOPS", "UI", "UX", "API"}
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN", "").strip()
def normalize_icon_key(name: str) -> str:
return re.sub(r"[^a-z0-9]+", "", name.casefold())
LANGUAGE_ICON_MAP = {
"Assembly": "https://img.shields.io/badge/ASM-111827?style=for-the-badge&logo=gnuassembler&logoColor=white",
"C": "https://raw.githubusercontent.com/devicons/devicon/master/icons/c/c-original.svg",
"C++": "https://raw.githubusercontent.com/devicons/devicon/master/icons/cplusplus/cplusplus-original.svg",
"CSS": "https://raw.githubusercontent.com/devicons/devicon/master/icons/css3/css3-original.svg",
"CSS3": "https://raw.githubusercontent.com/devicons/devicon/master/icons/css3/css3-original.svg",
"HTML": "https://raw.githubusercontent.com/devicons/devicon/master/icons/html5/html5-original.svg",
"HTML5": "https://raw.githubusercontent.com/devicons/devicon/master/icons/html5/html5-original.svg",
"Java": "https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original.svg",
"JavaScript": "https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg",
"Jupyter Notebook": "https://raw.githubusercontent.com/devicons/devicon/master/icons/jupyter/jupyter-original.svg",
"MySQL": "https://raw.githubusercontent.com/devicons/devicon/master/icons/mysql/mysql-original.svg",
"Python": "https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original.svg",
"SQL": "https://raw.githubusercontent.com/devicons/devicon/master/icons/mysql/mysql-original.svg",
"Shell": "https://raw.githubusercontent.com/devicons/devicon/master/icons/bash/bash-original.svg",
"Batchfile": "https://raw.githubusercontent.com/devicons/devicon/master/icons/windows11/windows11-original.svg",
"TypeScript": "https://raw.githubusercontent.com/devicons/devicon/master/icons/typescript/typescript-original.svg",
}
LANGUAGE_ICON_ALIASES = {
"bash": "Shell",
"batch": "Batchfile",
"batchfile": "Batchfile",
"batchfiles": "Batchfile",
"cmd": "Batchfile",
"msdos": "Batchfile",
"powershell": "PowerShell",
"shell": "Shell",
}
LANGUAGE_ICON_LOOKUP = {
normalize_icon_key(name): icon_url
for name, icon_url in LANGUAGE_ICON_MAP.items()
}
FRAMEWORK_ICON_MAP = {
"AWT": "https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original.svg",
"Flask": "https://raw.githubusercontent.com/devicons/devicon/master/icons/flask/flask-original.svg",
"Maven": "https://raw.githubusercontent.com/devicons/devicon/master/icons/maven/maven-original.svg",
"NumPy": "https://raw.githubusercontent.com/devicons/devicon/master/icons/numpy/numpy-original.svg",
"Pandas": "https://raw.githubusercontent.com/devicons/devicon/master/icons/pandas/pandas-original.svg",
"React": "https://raw.githubusercontent.com/devicons/devicon/master/icons/react/react-original.svg",
"Spring": "https://raw.githubusercontent.com/devicons/devicon/master/icons/spring/spring-original.svg",
}
TOOL_CARDS = [
("PyCharm", "https://raw.githubusercontent.com/devicons/devicon/master/icons/pycharm/pycharm-original.svg"),
("IntelliJ", "https://raw.githubusercontent.com/devicons/devicon/master/icons/intellij/intellij-original.svg"),
("Jupyter", "https://raw.githubusercontent.com/devicons/devicon/master/icons/jupyter/jupyter-original.svg"),
("Git", "https://raw.githubusercontent.com/devicons/devicon/master/icons/git/git-original.svg"),
("VS Code", "https://raw.githubusercontent.com/devicons/devicon/master/icons/vscode/vscode-original.svg"),
("Eclipse", "https://raw.githubusercontent.com/devicons/devicon/master/icons/eclipse/eclipse-original.svg"),
("Dev C++", "https://raw.githubusercontent.com/devicons/devicon/master/icons/cplusplus/cplusplus-original.svg"),
]
IGNORED_LANGUAGE_NAMES = {"Makefile"}
SUBJECT_TOPIC_MAP = {
"ai": "AI",
"artificial-intelligence": "AI",
"computer-networks": "CN",
"csv": "Data Processing",
"daa": "DAA",
"database-management": "DBMS",
"database-management-system": "DBMS",
"dbms": "DBMS",
"design-analysis-algorithms": "DAA",
"machine-learning": "ML",
"ml": "ML",
"oop": "OOPs",
"oops": "OOPs",
"operating-systems": "OS",
"os": "OS",
"pbl": "PBL",
}
SUBJECT_PRIORITY = ["DAA", "DBMS", "OOPs", "OS", "AI", "ML", "CN", "PBL", "Data Processing"]
SUBJECT_NAME_HINTS = {
"articulation": "DAA",
"page-replacement": "OS",
"paging": "OS",
"tic-tac-toe": "PBL",
}
FRAMEWORK_TOPIC_MAP = {
"flask": "Flask",
"maven": "Maven",
"numpy": "NumPy",
"pandas": "Pandas",
"react": "React",
"spring": "Spring",
}
FRAMEWORK_FILE_MAP = {
"pom.xml": "Maven",
"requirements.txt": "Flask",
"package.json": "React",
"build.gradle": "Spring",
}
AWT_PATTERN = re.compile(r"\bjava\.awt\b", re.IGNORECASE)
def load_json(path: Path):
with path.open("r", encoding="utf-8") as fh:
return json.load(fh)
def chunked(items: list, size: int) -> list[list]:
return [items[i:i + size] for i in range(0, len(items), size)]
def badge(
label: str,
message: str,
color: str,
*,
style: str = "for-the-badge",
logo: str | None = None,
logo_color: str | None = None,
) -> str:
parts = {"style": style}
if logo:
parts["logo"] = logo
if logo_color:
parts["logoColor"] = logo_color
query = urllib.parse.urlencode(parts)
label_q = urllib.parse.quote(label, safe="")
message_q = urllib.parse.quote(message, safe="")
return f"https://img.shields.io/badge/{label_q}-{message_q}-{color}?{query}"
def github_json(url: str) -> list[dict] | dict | None:
headers = {
"Accept": "application/vnd.github+json",
"User-Agent": "code-crew-nexus-readme-generator",
"X-GitHub-Api-Version": "2022-11-28",
}
if GITHUB_TOKEN:
headers["Authorization"] = f"Bearer {GITHUB_TOKEN}"
request = urllib.request.Request(
url,
headers=headers,
)
try:
with urllib.request.urlopen(request, timeout=20) as response:
return json.loads(response.read().decode("utf-8"))
except (urllib.error.HTTPError, urllib.error.URLError, TimeoutError):
return None
def github_text(url: str) -> str | None:
headers = {
"Accept": "application/vnd.github.raw+json",
"User-Agent": "code-crew-nexus-readme-generator",
"X-GitHub-Api-Version": "2022-11-28",
}
if GITHUB_TOKEN:
headers["Authorization"] = f"Bearer {GITHUB_TOKEN}"
request = urllib.request.Request(url, headers=headers)
try:
with urllib.request.urlopen(request, timeout=20) as response:
return response.read().decode("utf-8", errors="replace")
except (urllib.error.HTTPError, urllib.error.URLError, TimeoutError):
return None
def format_ist(value: str, *, include_time: bool = True) -> str:
if not value:
return "TBD"
try:
parsed = datetime.fromisoformat(value.replace("Z", "+00:00")).astimezone(INDIA_TZ)
except ValueError:
return value
if include_time:
return parsed.strftime("%b %d, %Y · %I:%M %p IST")
return parsed.strftime("%b %d, %Y")
def humanize_repo_name(name: str) -> str:
parts = re.split(r"[-_]+", name.strip())
cleaned = []
for part in parts:
if not part:
continue
upper = part.upper()
if upper in ACRONYMS:
cleaned.append(upper)
else:
cleaned.append(part.capitalize())
return " ".join(cleaned) or name
def normalize_members(members: list[dict] | list[str]) -> list[dict[str, str]]:
normalized: list[dict[str, str]] = []
for member in members:
if isinstance(member, dict):
name = str(member.get("name") or "").strip()
designation = str(member.get("designation") or "Organization Member").strip()
else:
name = str(member).strip()
designation = "Organization Member"
if not name:
continue
normalized.append({"name": name, "designation": designation or "Organization Member"})
return normalized
def render_members_grid(members: list[dict] | list[str], columns: int = 3) -> str:
members = normalize_members(members)
if not members:
return "*Members will be listed here as the organization grows.*"
rows = []
for row in chunked(members, columns):
cells = []
is_partial_row = len(row) < columns
left_pad = (columns - len(row)) // 2 if is_partial_row else 0
right_pad = columns - len(row) - left_pad if is_partial_row else 0
for _ in range(left_pad):
cells.append(f'<td align="center" width="{100 // columns}%"> </td>')
for member in row:
safe_member = html.escape(member["name"])
safe_designation = html.escape(member["designation"])
cells.append(
f"""<td align="center" width="{100 // columns}%">
<strong>{safe_member}</strong><br />
<sub>{safe_designation}</sub>
</td>"""
)
while right_pad > 0:
cells.append(f'<td align="center" width="{100 // columns}%"> </td>')
right_pad -= 1
rows.append("<tr>\n" + "\n".join(cells) + "\n</tr>")
return '<div align="center">\n\n<table>\n' + "\n".join(rows) + "\n</table>\n\n</div>"
def split_project_overrides(projects: list[dict]) -> tuple[dict[str, dict], list[dict]]:
overrides_by_repo: dict[str, dict] = {}
manual_rows: list[dict] = []
for item in projects:
repo_name = (item.get("repo_name") or "").strip()
if repo_name:
overrides_by_repo[repo_name] = item
else:
manual_rows.append(item)
return overrides_by_repo, manual_rows
def fetch_public_repos(org_slug: str) -> list[dict]:
repos: list[dict] = []
page = 1
while True:
query = urllib.parse.urlencode(
{
"type": "public",
"sort": "updated",
"per_page": 100,
"page": page,
}
)
data = github_json(f"{GITHUB_API_URL}/orgs/{org_slug}/repos?{query}")
if not isinstance(data, list) or not data:
break
repos.extend(data)
if len(data) < 100:
break
page += 1
filtered = [repo for repo in repos if repo.get("name") != PROFILE_REPO]
filtered.sort(key=lambda repo: repo.get("pushed_at") or "", reverse=True)
return filtered[:REPOS_LIMIT]
def fetch_latest_commit(repo_full_name: str, branch: str) -> dict | None:
query = urllib.parse.urlencode({"sha": branch, "per_page": 1})
data = github_json(f"{GITHUB_API_URL}/repos/{repo_full_name}/commits?{query}")
if isinstance(data, list) and data:
return data[0]
return None
def fetch_repo_details(repo_full_name: str) -> dict:
data = github_json(f"{GITHUB_API_URL}/repos/{repo_full_name}")
return data if isinstance(data, dict) else {}
def fetch_repo_languages(repo_full_name: str) -> dict[str, int]:
data = github_json(f"{GITHUB_API_URL}/repos/{repo_full_name}/languages")
return data if isinstance(data, dict) else {}
def fetch_root_entries(repo_full_name: str, branch: str) -> list[dict]:
query = urllib.parse.urlencode({"ref": branch})
data = github_json(f"{GITHUB_API_URL}/repos/{repo_full_name}/contents?{query}")
return data if isinstance(data, list) else []
def fetch_readme_text(repo_full_name: str) -> str:
text = github_text(f"{GITHUB_API_URL}/repos/{repo_full_name}/readme")
return text or ""
def fetch_repo_branches(repo_full_name: str) -> list[str]:
branches: list[str] = []
page = 1
while True:
query = urllib.parse.urlencode({"per_page": 100, "page": page})
data = github_json(f"{GITHUB_API_URL}/repos/{repo_full_name}/branches?{query}")
if not isinstance(data, list) or not data:
break
for branch in data:
name = str(branch.get("name") or "").strip()
if name and name not in branches:
branches.append(name)
if len(data) < 100:
break
page += 1
return branches
def infer_subject(repo_name: str, topics: list[str]) -> str:
found_subjects: list[str] = []
for topic in topics:
mapped = SUBJECT_TOPIC_MAP.get(topic.lower())
if mapped and mapped not in found_subjects:
found_subjects.append(mapped)
for subject in SUBJECT_PRIORITY:
if subject in found_subjects:
return subject
lowered = repo_name.lower()
for hint, mapped in SUBJECT_NAME_HINTS.items():
if hint in lowered:
return mapped
for key, mapped in SUBJECT_TOPIC_MAP.items():
if key in lowered:
return mapped
return "TBD"
def format_language_stack(language_map: dict[str, int]) -> str:
names = [name for name in language_map if name not in IGNORED_LANGUAGE_NAMES]
return ", ".join(names[:3]) if names else "TBD"
def resolve_stack(language_map: dict[str, int], primary_language: str) -> str:
stack = format_language_stack(language_map)
if stack != "TBD":
return stack
return primary_language.strip() if primary_language and primary_language.strip() else "TBD"
def format_branch_list(branches: list[str], default_branch: str) -> str:
cleaned = [branch.strip() for branch in branches if branch and branch.strip()]
if not cleaned and default_branch:
cleaned = [default_branch.strip()]
if not cleaned:
return "TBD"
return "<br />".join(f"`{html.escape(branch)}`" for branch in cleaned)
def detect_frameworks(repo: dict, readme_text: str = "") -> list[str]:
detected: list[str] = []
topics = [str(topic).strip() for topic in repo.get("topics", []) if str(topic).strip()]
root_names = {str(entry.get("name") or "").strip().lower() for entry in repo.get("root_entries", [])}
readme_lower = readme_text.lower()
for topic in topics:
framework = FRAMEWORK_TOPIC_MAP.get(topic.lower())
if framework and framework not in detected:
detected.append(framework)
for file_name, framework in FRAMEWORK_FILE_MAP.items():
if file_name.lower() in root_names and framework not in detected:
detected.append(framework)
if AWT_PATTERN.search(readme_text) and "AWT" not in detected:
detected.append("AWT")
elif "awt" in readme_lower and "AWT" not in detected:
detected.append("AWT")
return detected
def enrich_repos(repos: list[dict]) -> list[dict]:
enriched: list[dict] = []
for repo in repos:
repo_name = str(repo.get("name") or "").strip()
repo_full_name = str(repo.get("full_name") or "").strip()
branch = str(repo.get("default_branch") or "main").strip()
if not repo_name or not repo_full_name:
continue
details = fetch_repo_details(repo_full_name)
merged = {**repo, **details} if details else dict(repo)
merged["language_map"] = fetch_repo_languages(repo_full_name)
merged["branches"] = fetch_repo_branches(repo_full_name)
merged["root_entries"] = fetch_root_entries(repo_full_name, branch)
merged["readme_text"] = fetch_readme_text(repo_full_name)
enriched.append(merged)
return enriched
def build_project_rows(projects: list[dict], repos: list[dict]) -> list[dict]:
overrides_by_repo, manual_rows = split_project_overrides(projects)
rows: list[dict] = []
for repo in repos:
repo_name = repo.get("name", "").strip()
if not repo_name:
continue
override = overrides_by_repo.get(repo_name, {})
topics = [str(topic).strip() for topic in repo.get("topics", []) if str(topic).strip()]
language_map = repo.get("language_map") or {}
default_branch = (repo.get("default_branch") or "main").strip()
branches = repo.get("branches") or []
description = (override.get("description") or repo.get("description") or "Academic repository under active development.").strip()
rows.append(
{
"project": (override.get("project") or humanize_repo_name(repo_name)).strip(),
"subject": (override.get("subject") or infer_subject(repo_name, topics)).strip(),
"tools_languages": (override.get("tools_languages") or resolve_stack(language_map, repo.get("language") or "")).strip(),
"description": description,
"last_commit": format_ist(repo.get("pushed_at", ""), include_time=False),
"branches": format_branch_list(branches, default_branch),
"repo_name": repo_name,
"repo_url": repo.get("html_url") or f"https://github.com/{ORG_SLUG}/{repo_name}",
}
)
if rows:
return rows
fallback_rows: list[dict] = []
for item in manual_rows:
fallback_rows.append(
{
"project": (item.get("project") or "Coming Soon").strip(),
"subject": (item.get("subject") or "TBD").strip(),
"tools_languages": (item.get("tools_languages") or "TBD").strip(),
"description": (item.get("description") or "Project details will appear here once the repository is added.").strip(),
"last_commit": "TBD",
"branches": "TBD",
"repo_name": "",
"repo_url": "",
}
)
return fallback_rows or [
{
"project": "Coming Soon",
"subject": "TBD",
"tools_languages": "TBD",
"description": "Project details will appear here once the repository is added.",
"last_commit": "TBD",
"branches": "TBD",
"repo_name": "",
"repo_url": "",
}
]
def render_projects_table(project_rows: list[dict]) -> str:
header = "| PROJECT | SUBJECT | STACK | DESCRIPTION | LAST UPDATE | BRANCHES | REPOSITORY |"
divider = "| --- | --- | --- | --- | --- | --- | --- |"
rows = []
for item in project_rows:
repo_name = item["repo_name"]
if repo_name and item["repo_url"]:
repo_link = f"[`{repo_name}`]({item['repo_url']})"
else:
repo_link = "*Coming soon*"
rows.append(
f"| **{item['project']}** | {item['subject']} | {item['tools_languages']} | "
f"{item['description']} | {item['last_commit']} | {item['branches']} | {repo_link} |"
)
return "\n".join([header, divider, *rows])
def build_recent_commits(repos: list[dict], limit: int = RECENT_COMMITS_LIMIT) -> list[dict]:
items: list[dict] = []
for repo in repos:
repo_name = repo.get("name", "").strip()
repo_full_name = repo.get("full_name", "").strip()
branch = (repo.get("default_branch") or "main").strip()
repo_url = repo.get("html_url") or f"https://github.com/{ORG_SLUG}/{repo_name}"
if not repo_name or not repo_full_name:
continue
latest = fetch_latest_commit(repo_full_name, branch)
if not latest:
continue
commit_info = latest.get("commit", {}) or {}
committer_info = commit_info.get("committer", {}) or {}
author_info = commit_info.get("author", {}) or {}
actor = (
(latest.get("author") or {}).get("login")
or committer_info.get("name")
or author_info.get("name")
or "Unknown"
)
commit_date = committer_info.get("date") or author_info.get("date") or ""
message = (commit_info.get("message") or "Recent update").splitlines()[0].strip() or "Recent update"
sha = (latest.get("sha") or "")[:7]
items.append(
{
"message": message,
"actor": actor,
"repo_name": repo_name,
"repo_url": repo_url,
"branch": branch,
"sha": sha,
"commit_url": latest.get("html_url") or f"{repo_url}/commit/{latest.get('sha', '')}",
"committed_at": commit_date,
}
)
items.sort(key=lambda item: item.get("committed_at") or "", reverse=True)
return items[:limit]
def render_recent_commits(commits: list[dict]) -> str:
if not commits:
return "> Recent commit activity will appear here once public repositories in the organization start receiving commits."
rows = []
for row in chunked(commits, 2):
cells = []
for commit in row:
message = html.escape(commit["message"])
actor = html.escape(commit["actor"])
repo_name = html.escape(commit["repo_name"])
branch = html.escape(commit["branch"])
timestamp = html.escape(format_ist(commit["committed_at"]))
sha = html.escape(commit["sha"])
repo_url = commit["repo_url"]
commit_url = commit["commit_url"]
cells.append(
f"""<td width="50%" valign="top">
<strong><a href="{commit_url}">{message}</a></strong><br />
<sub>{timestamp}</sub>
<br /><br />
<strong>Repository:</strong> <a href="{repo_url}">{repo_name}</a><br />
<strong>Committed by:</strong> {actor}<br />
<strong>Branch:</strong> <code>{branch}</code><br />
<strong>Commit:</strong> <code>{sha}</code>
</td>"""
)
while len(cells) < 2:
cells.append('<td width="50%" valign="top"> </td>')
rows.append("<tr>\n" + "\n".join(cells) + "\n</tr>")
return (
'<div align="center">\n\n<table>\n'
+ "\n".join(rows)
+ '\n</table>\n\n</div>\n\n'
+ "> This section is generated from the latest public commits across organization repositories and is shown in Indian Standard Time."
)
def icon_for(name: str, icon_map: dict[str, str]) -> str:
normalized_name = normalize_icon_key(name)
resolved_name = LANGUAGE_ICON_ALIASES.get(normalized_name, name)
resolved_key = normalize_icon_key(resolved_name)
if resolved_key in LANGUAGE_ICON_LOOKUP:
return LANGUAGE_ICON_LOOKUP[resolved_key]
if name in icon_map:
return icon_map[name]
return badge(name, "Stack", "111827", logo="github", logo_color="white")
def render_icon_table(items: list[tuple[str, str]], columns: int = 5) -> str:
if not items:
return "*No items detected yet.*"
row_tables = []
for row in chunked(items, columns):
cells = []
cell_width = max(1, 100 // max(1, len(row)))
for name, icon_url in row:
safe_name = html.escape(name)
cells.append(
f"""<td align="center" width="{cell_width}%">
<img src="{icon_url}" alt="{safe_name}" width="64" height="64" /><br />
<strong>{safe_name}</strong>
</td>"""
)
row_tables.append(
'<table>\n<tr>\n'
+ "\n".join(cells)
+ "\n</tr>\n</table>"
)
return '<div align="center">\n\n' + "\n\n".join(row_tables) + "\n\n</div>"
def build_tech_specs(repos: list[dict]) -> dict[str, list]:
languages_seen: list[str] = []
languages_seen_keys: set[str] = set()
frameworks_seen: list[str] = []
for repo in repos:
language_map = repo.get("language_map") or {}
for language in language_map:
normalized_language = normalize_icon_key(language)
if language in IGNORED_LANGUAGE_NAMES or normalized_language in languages_seen_keys:
continue
languages_seen.append(language)
languages_seen_keys.add(normalized_language)
for framework in detect_frameworks(repo, repo.get("readme_text", "")):
if framework not in frameworks_seen:
frameworks_seen.append(framework)
if not languages_seen:
primary_languages = [repo.get("language") for repo in repos if repo.get("language")]
for language in primary_languages:
normalized_language = normalize_icon_key(language)
if language not in languages_seen and language not in IGNORED_LANGUAGE_NAMES and normalized_language not in languages_seen_keys:
languages_seen.append(language)
languages_seen_keys.add(normalized_language)
language_cards = [(language, icon_for(language, LANGUAGE_ICON_MAP)) for language in languages_seen[:10]]
framework_cards = [(framework, icon_for(framework, FRAMEWORK_ICON_MAP)) for framework in frameworks_seen[:8]]
return {
"language_cards": language_cards,
"framework_cards": framework_cards,
"tool_cards": TOOL_CARDS,
}
def render_tech_specs(repos: list[dict]) -> str:
tech_specs = build_tech_specs(repos)
languages_block = render_icon_table(tech_specs["language_cards"], columns=5)
frameworks_block = (
render_icon_table(tech_specs["framework_cards"], columns=4)
if tech_specs["framework_cards"]
else "*No frameworks have been detected from the current public repositories yet.*"
)
tools_block = render_icon_table(tech_specs["tool_cards"], columns=5)
return f"""This section is generated from the organization's current public repositories wherever possible, while the core collaboration tools remain intentionally standardized.
### Languages
{languages_block}
### Frameworks
{frameworks_block}
### Tools
{tools_block}
### What We Optimize For
- Clean repository structure and readable implementation.
- Documentation that helps peers, faculty, and reviewers understand the work quickly.
- Project setups that stay reproducible as repositories keep growing.
- Practical tools that support collaboration across different subjects and workflows.
> Languages and frameworks are inferred from the organization's public repositories. Tools are kept as a standard baseline for the team workspace."""
def build_readme(members: list[dict] | list[str], projects: list[dict], repos: list[dict], recent_commits: list[dict]) -> str:
members_grid = render_members_grid(members)
project_rows = build_project_rows(projects, repos)
projects_table = render_projects_table(project_rows)
recent_commits_section = render_recent_commits(recent_commits)
tech_specs_section = render_tech_specs(repos)
generated_at = datetime.now(INDIA_TZ)
last_updated_label = generated_at.strftime("%b %d, %Y")
return f'''<!-- THIS FILE IS GENERATED. Edit data/members.json and data/projects.json, then run python generate_readme.py. -->
<div align="center">
# {ORG_NAME}
### Professional Organization Space for Academic Projects, Subject Repositories, and Structured Innovation
<img src="https://readme-typing-svg.demolab.com?font=JetBrains+Mono&weight=600&size=22&duration=2800&pause=900&color=0EA5E9¢er=true&vCenter=true&repeat=true&width=940&lines=Building+academic+projects+with+professional+intent;Maintaining+subject-based+repositories+with+clarity;Encouraging+structured+collaboration+and+innovation;Turning+project+work+into+portfolio-ready+outcomes" alt="Typing SVG" />
<br />
<p><strong>CODE CREW NEXUS</strong> is a professional GitHub organization designed to centralize collaborative academic work, project-driven learning, and innovation-focused development.</p>
<br />
<a href="https://github.com/{ORG_SLUG}"><img src="{badge('Organization', ORG_NAME, '111827', logo='github', logo_color='white')}" alt="Organization" /></a>
<img src="{badge('Direction', 'Innovation Driven', '0EA5E9')}" alt="Direction" />
<img src="{badge('Standard', 'Professional', '16A34A')}" alt="Professional Standard" />
<img src="{badge('Profile', 'Actively Maintained', 'F97316')}" alt="Profile Status" />
<br />
<img src="https://img.shields.io/github/repo-size/{ORG_SLUG}/{PROFILE_REPO}?style=for-the-badge&color=2563EB" alt="Repository Size" />
<img src="https://img.shields.io/github/last-commit/{ORG_SLUG}/{PROFILE_REPO}?style=for-the-badge&color=7C3AED" alt="Last Commit" />
<img src="{badge('Status', 'Active', '22C55E')}" alt="Project Status" />
<img src="{badge('Theme', 'Innovation', 'E11D48')}" alt="Theme" />
<br />
<img src="https://img.shields.io/badge/Last%20Updated-{urllib.parse.quote(last_updated_label, safe='')}-111827?style=for-the-badge" alt="Last Updated" />
<br />
<img src="https://img.shields.io/github/stars/{ORG_SLUG}/{PROFILE_REPO}?style=social&cacheSeconds=300" alt="GitHub Stars" />
<img src="https://img.shields.io/github/forks/{ORG_SLUG}/{PROFILE_REPO}?style=social&cacheSeconds=300" alt="GitHub Forks" />
<img src="https://img.shields.io/github/watchers/{ORG_SLUG}/{PROFILE_REPO}?style=social&cacheSeconds=300" alt="GitHub Watchers" />
</div>
<br />
```text
Focus : Academic collaboration, repository quality, structured documentation
Approach : Professional presentation, reproducible work, innovation-led execution
Positioning: A durable project hub for peers, faculty, and future opportunities
```
---
## Purpose
**CODE CREW NEXUS** exists to bring project work into one organized, durable, and high-clarity space.
This organization is designed for:
- academic projects with real-world thinking,
- subject-based repositories that stay easy to navigate,
- shared experiments and implementation-driven learning,
- and portfolio-quality presentation for peers, faculty, and recruiters.
We want every repository here to feel intentional, readable, and worth revisiting.
---
## Overview
This organization is built to support serious collaboration and stronger project visibility.
Instead of treating repositories as isolated submissions, **CODE CREW NEXUS** serves as a long-term project hub where code, documentation, reports, diagrams, and implementation quality all matter equally.
> More than a GitHub organization, this is a structured workspace for disciplined learning, stronger execution, and visible growth.
---
## Vision & Mission
- Build impactful academic projects with real-world relevance.
- Learn collaboratively and share knowledge across subjects.
- Maintain professional standards in code, documentation, and teamwork.
- Showcase collective work as a strong portfolio for recruiters, peers, and faculty.
Our mission is to create work that reflects both technical seriousness and team maturity.
---
## Activities
- Create subject-based repositories for areas like DAA, DBMS, OOPs, AI/ML, and more.
- Collaborate in smaller groups depending on project size, scope, and requirements.
- Document projects with structured reports, diagrams, implementation notes, and clear logic.
- Review each other's work for readability, reproducibility, and clarity.
- Maintain a central hub that combines innovation, teamwork, and professional presentation.
---
## Ambition
This organization is more than just a GitHub space. It is a collaboration-first environment shaped by ambition, growth, and unity.
We are building it as a foundation for:
- stronger project execution,
- better ownership and accountability,
- cleaner technical presentation,
- and long-term growth as learners and future professionals.
Every project added here should strengthen the story of a team that builds with intent and improves together.
---
## Project Directory
{projects_table}
> This directory is generated from the organization's public repositories and enriched by optional overrides in `data/projects.json`.
---
## Recent Commits
{recent_commits_section}
---
## Repository Structure
- Each repository represents a subject, project, or focused experiment.
- Teams can be assigned based on project requirements and contribution needs.
- Repositories should include code, documentation, and real-world examples wherever relevant.
### Typical flow
`Idea -> Planning -> Implementation -> Documentation -> Review -> Showcase`
---
## Innovation Roadmap
- [ ] Flagship project spotlight
- [ ] Expanded subject repository lineup
- [ ] Shared documentation standard
- [ ] Unified project showcase format
---
## Tech Specs & Tools
{tech_specs_section}
---
## Why This Org Stands Out
| Focus Area | What It Looks Like |
| --- | --- |
| **Team-Based Learning** | Knowledge moves across the group instead of staying isolated inside individual repositories. |
| **Documentation Depth** | Reports, diagrams, and implementation notes are treated as part of the project, not as an afterthought. |
| **Professional Presentation** | Repositories are organized to look polished, understandable, and recruiter-friendly. |
| **Shared Ownership** | Projects are strengthened through accountability, review, and collaboration. |
---
## How We Work
| Approach | In Practice |
| --- | --- |
| **Plan with intent** | We organize projects before building so the final output feels structured and complete. |
| **Build collaboratively** | Work is distributed thoughtfully to match scope, timelines, and strengths. |
| **Review for clarity** | We care about whether a project can be understood, reproduced, and showcased well. |
| **Keep improving** | Each repository is a chance to raise our standards in code, docs, and teamwork. |
---
## Members
{members_grid}
> This section is generated from `data/members.json` and is presented as the current organization member list for the profile.
---
## Tagline
**Forging ideas into impactful projects.**
**Where teamwork meets innovation.**
**Built for collaboration, driven by ambition.**
---
## Closing Note
**CODE CREW NEXUS** is our shared space for turning ideas into outcomes, assignments into achievements, and collaboration into something lasting.
As new repositories take shape, this profile will grow into a durable reflection of our work, our standards, and our collective momentum.
'''
def main() -> None:
members = load_json(DATA_DIR / "members.json")
projects = load_json(DATA_DIR / "projects.json")
fetched_repos = fetch_public_repos(ORG_SLUG)
if not fetched_repos and OUTPUT.exists():
return
repos = enrich_repos(fetched_repos)
recent_commits = build_recent_commits(repos)
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
OUTPUT.write_text(build_readme(members, projects, repos, recent_commits), encoding="utf-8")
if __name__ == "__main__":
main()