Skip to content

Commit

Permalink
Add script to render README
Browse files Browse the repository at this point in the history
  • Loading branch information
msadowski committed Nov 5, 2023
1 parent de99f9f commit cbb66a5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 26 deletions.
35 changes: 35 additions & 0 deletions scripts/autogenerate_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import yaml
from jinja2 import Template
import os

current_directory = os.path.dirname(os.path.abspath(__file__))
events_file = "../events.yaml"
events_path = os.path.join(current_directory, events_file)
template_path = os.path.join(current_directory, 'templates/readme.j2')
readme_path = os.path.join(current_directory, '../README.md')

# Read events from events.yaml
with open(events_path, 'r') as file:
events = yaml.safe_load(file)

category_order = ['Conference', 'Expo', 'Workshop', 'Competition', 'Meetup']

# Group events by category and maintain the desired order
events_by_category = {category: [] for category in category_order}
for event in events:
category = event['category']
if category in category_order:
events_by_category[category].append(event)

# Load the Jinja template
with open(template_path, 'r') as file:
template_content = file.read()

template = Template(template_content)

# Render the template with events
rendered_template = template.render(events_by_category=events_by_category)

# Write the rendered template to README.md
with open(readme_path, 'w') as file:
file.write(rendered_template)
26 changes: 0 additions & 26 deletions scripts/sort_events.py

This file was deleted.

36 changes: 36 additions & 0 deletions scripts/templates/readme.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Robotic Events
A repository containing upcoming events in robotics maintained by [](https://www.linkedin.com/in/knmcguire/) and [Mat Sadowski](https://www.linkedin.com/in/mateuszsadowski/).

The events in this repository are rendered on [Weekly Robotics website](https://www.weeklyrobotics.com/events)

## Contributing

Please feel free to create a PR adding your event details. To insert the event, modify events.yml file, inserting your event using the format below. Please don't edit the README.md file directly, it is autogenerated from the yaml file.

```
- title: Robotics Summit & Expo
link: https://www.roboticssummit.com/
start_date: 2024-05-01
end_date: 2024-05-02
city: Boston
country: US
category: Expo
```

Using any of the categories:
* Conference
* Expo
* Workshop
* Competition
* Meetup

When you insert the event, make sure it is inserted chronically with respect of start_date of other events. Please note that at this time we don't accept any events related to weaponry or weaponization.

# Events

{% for category, events in events_by_category.items() %}
## {{ category }}

{% for event in events %}
* [{{ event.title }}]({{ event.link }}){% if event.end_date %}: {{ event.start_date.strftime('%b %d') }}-{{ event.end_date.strftime('%b %d, %Y') }}.{% else %}: {{ event.start_date.strftime('%b %d, %Y') }}.{% endif %} {{ event.city }}, {{ event.country }}{% endfor %}
{% endfor %}

0 comments on commit cbb66a5

Please sign in to comment.