From f581020ab621845f4b4609bfbca6fccdfea0cb49 Mon Sep 17 00:00:00 2001 From: Sammy Hori Date: Sun, 17 Nov 2024 20:58:03 +0000 Subject: [PATCH] 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. --- .github/README.j2 | 31 ++++++++++++++++++++++++++++ .github/scripts/render-readme.py | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/README.j2 create mode 100644 .github/scripts/render-readme.py diff --git a/.github/README.j2 b/.github/README.j2 new file mode 100644 index 0000000..c9cf47e --- /dev/null +++ b/.github/README.j2 @@ -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 %})_
{{ entry.description }}{% endfor %} +{% endfor %} + +## Contribute + +Contributions are welcome! See the [contributing guidelines](CONTRIBUTING.md). + +## Thanks to GitHub Sponsors + +{% for sponsor in sponsors %}{% endfor %}

{{ sponsor.name }}
+ +## 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. + diff --git a/.github/scripts/render-readme.py b/.github/scripts/render-readme.py new file mode 100644 index 0000000..02d4e64 --- /dev/null +++ b/.github/scripts/render-readme.py @@ -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)