Skip to content

Commit 5b87d85

Browse files
authored
Generate JSON with core project information (#417)
* Generate JSON with core project information * Dump JSON, not YAML
1 parent bce7bc4 commit 5b87d85

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help prepare html serve serve-dev clean calendars teams teams-clean
1+
.PHONY: help prepare html serve serve-dev clean calendars teams teams-clean core-project-json
22
.DEFAULT_GOAL := help
33
SHELL:=/bin/bash
44

@@ -42,11 +42,16 @@ teams-clean:
4242

4343
teams: | teams-clean $(patsubst %,$(TEAMS_DIR)/%.md,$(TEAMS)) ## generates team gallery pages
4444

45+
core-project-json: content/specs/core-projects/core-projects.json
4546

46-
html: prepare calendars ## build the website in ./public
47+
content/specs/core-projects/core-projects.json: content/specs/core-projects/[^_]*.md
48+
@echo "Generating project JSON: $@"
49+
@python tools/md-header-to-json.py $? > $@
50+
51+
html: prepare calendars core-project-json ## build the website in ./public
4752
@hugo
4853

49-
serve: prepare calendars ## serve the website
54+
serve: prepare calendars core-project-json ## serve the website
5055
@hugo --printI18nWarnings server
5156

5257
serve-dev: prepare calendars

tools/md-header-to-json.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
import yaml
6+
import json
7+
8+
files = sys.argv[1:]
9+
10+
out = []
11+
for mdfile in files:
12+
with open(mdfile) as f:
13+
data = f.readlines()
14+
end_header = data[1:].index("---\n") + 1
15+
data = data[1:end_header]
16+
header = yaml.load("".join(data), Loader=yaml.SafeLoader)
17+
out.append(header)
18+
19+
print(json.dumps(out, indent=2))

0 commit comments

Comments
 (0)