WIP: Added new script for building the README

This uses jinja templating to do so.
The script is made to exactly copy the behaviour of the current
script as now, to prove that it does the same thing.
This commit is contained in:
Sammy Hori
2024-11-17 20:58:03 +00:00
parent 1eba3b9491
commit f581020ab6
2 changed files with 66 additions and 0 deletions

31
.github/README.j2 vendored Normal file
View File

@@ -0,0 +1,31 @@
# Awesome First PR Opportunities [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)
Inspired by [First Timers Only](https://kentcdodds.com/blog/first-timers-only) blog post.
If you are a maintainer of open-source projects, add the label `first-timers-only` (or similar) to your project and list it here so that people can find it.
If you are not a programmer but would like to contribute, check out the [Awesome for non-programmers](https://github.com/szabgab/awesome-for-non-programmers) list.
## Table of Contents:
{% for category in categories %}
- [{{ category.title }}](#{{ category.link_id }}){% endfor %}
{% for category in categories %}
## {{ category.title }}
{% for entry in category.entries %}
- [{{ entry.name }}]({{ entry.link }}) _(label: {% if entry.label is defined %}{{ entry.label }}{% else %}n/a{% endif %})_ <br> {{ entry.description }}{% endfor %}
{% endfor %}
## Contribute
Contributions are welcome! See the [contributing guidelines](CONTRIBUTING.md).
## Thanks to GitHub Sponsors
<table>{% for sponsor in sponsors %}<tr><td align="center"><a href="{{ sponsor.link }}"><img src="{{ sponsor.image }}" width="60px;" alt=""/><br/><sub><b>{{ sponsor.name }}</b></sub></a></td></tr>{% endfor %}</table>
## License
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)
To the extent possible under law, the author has waived all copyrights and related or neighboring rights to this work.

35
.github/scripts/render-readme.py vendored Normal file
View File

@@ -0,0 +1,35 @@
from jinja2 import Environment, FileSystemLoader
import json
technologies = {}
with open("../../data.json", 'r') as datafile:
data = json.loads(datafile.read())
for technology in data["technologies"]:
technologies[technology] = {"link_id": data["technologies"][technology], "entries": []}
for repository in data["repositories"]:
repo_technologies = repository["technologies"]
for repo_technology in repo_technologies:
if not technologies.get(repo_technology, False):
technologies[repo_technology] = {"link_id": repo_technology.lower(), "entries": []}
technologies[repo_technology]["entries"].append(repository)
env = Environment(loader = FileSystemLoader(".."))
template = env.get_template("README.j2")
categories = []
for key, value in zip(technologies.keys(), technologies.values()):
categories.append({"title": key, "link_id": value["link_id"], "entries": value["entries"]})
categories = sorted(categories, key=lambda x: x["title"].upper())
for category in categories:
category["entries"] = sorted(category["entries"], key=lambda x: x["name"].upper())
sponsors = data["sponsors"]
output = template.render(categories=categories, sponsors=sponsors)
open("README.md", "w").write(output)