Reduced the table of contents length by putting it into a table

Categories are grouped by their first character in the table
This commit is contained in:
Sammy Hori
2024-12-13 20:42:45 +00:00
parent 9fa6b2699e
commit 5d353dea89
2 changed files with 14 additions and 5 deletions

View File

@@ -6,11 +6,9 @@ TEMPLATEPATH = "./.github/"
TEMPLATEFILE = "README-template.j2"
TARGETFILE = "./README.md"
def new_technology_dict(repo_technology):
return {"link_id": repo_technology.lower(), "entries": []}
technologies = {}
with open(DATAFILE, "r") as datafile:
@@ -39,11 +37,19 @@ for key, value in zip(technologies.keys(), technologies.values()):
)
categories = sorted(categories, key=lambda x: x["title"].upper())
category_groups = {"Misc": []}
for category in categories:
category["entries"] = sorted(category["entries"], key=lambda x: x["name"].upper())
first_char = category["title"][0].upper()
if first_char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
if first_char not in category_groups:
category_groups[first_char] = []
category_groups[first_char].append(category)
else:
category_groups["Misc"].append(category)
sponsors = data["sponsors"]
output = template.render(categories=categories, sponsors=sponsors)
output = template.render(category_groups=category_groups, categories=categories, sponsors=sponsors)
open(TARGETFILE, "w").write(output)