Commented on contents_generator

This commit is contained in:
Lucas
2026-01-12 11:11:28 -08:00
parent 469c21a5b2
commit 00a3422218
2 changed files with 8 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
import json
# Utils
def slugify(name):
return name.lower().replace(" ", "-").replace("(", "").replace(")", "")
@@ -23,25 +24,7 @@ def format_stars(n):
return str(n)
"""
def format_stars(n):
if n >= 1_000_000:
value = n / 1_000_000
suffix = "M"
elif n >= 1_000:
value = n / 1_000
suffix = "k"
else:
return str(n)
# If it's a whole number, don't show decimal point
if value == int(value):
return f"{int(value)}{suffix}"
else:
return f"{value:.1f}{suffix}"
"""
# Generates actual list contents in markdown (categories and projects within)
def generate_contents(platform="all"):
with open("core/data/static/categories.json", "r", encoding="utf-8") as f:
cat_data = json.load(f)
@@ -56,6 +39,7 @@ def generate_contents(platform="all"):
subcategories = cat_data.get("subcategories", [])
applications = app_data.get("applications", [])
# Map id's to corresponding names
parent_map = {cat["id"]: cat["name"] for cat in categories}
attribute_map = {
attribute["id"]: attribute["emoji"] for attribute in tags_data["attributes"]
@@ -75,6 +59,7 @@ def generate_contents(platform="all"):
for key in subcat_by_parent:
subcat_by_parent[key].sort(key=lambda x: x["Name"].lower())
# Include projects relative to type of list being gneerated (all or platform specific)
apps_by_subcat = {}
for app in applications:
include = False

View File

@@ -1,6 +1,9 @@
# Architecture
Here's a look at how the "backend" of the list works.
Here's a look at how this list works.
# The List Itself
The core of this list is powered by Python using UV and Ruff for linting and formatting.
## README Generation
All applications are stored inside [`applications.json`](core/data/dynamic/applications.json). Categories are declared inside [`categories.json`](core/data/static/categories.json). Instead of a nested format with subcategories as on object of it's parent, we've given subcategories a `parent` attribute. There's also a [`tags.json`](core/data/static/tags.json). Instead of putting the emoji inside of the ```tags``` attribute in `applications.json`, the id is used, for example, `commercial` or `disruptive`.. These id's are mapped to their corresponding emoji for when the READMEs are generated and makes``applications.json``` more readable.