Skip to content

Commit a73498e

Browse files
committed
Use jq templates to generate ISO language schemas
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 101cf1b commit a73498e

File tree

9 files changed

+432
-362
lines changed

9 files changed

+432
-362
lines changed

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ GENERATED = \
8888
schemas/xbrl/utr/volume-per-monetary-item-type.json \
8989
schemas/iso/country/2020/alpha-2.json \
9090
schemas/iso/country/2020/alpha-3.json \
91-
schemas/iso/country/2020/numeric.json
91+
schemas/iso/country/2020/numeric.json \
92+
schemas/iso/language/2023/set-1.json \
93+
schemas/iso/language/2023/set-2-bibliographic.json \
94+
schemas/iso/language/2023/set-2-terminologic.json \
95+
schemas/iso/language/2023/set-3.json \
96+
schemas/iso/language/2023/set-5.json
9297

9398
# TODO: Make `jsonschema fmt` automatically detect test files
9499
all: common test
@@ -152,7 +157,6 @@ schemas/iso/currency/2015/%.json: \
152157
$(JSONSCHEMA) fmt $@
153158

154159
build/xbrl/utr/%.json: scripts/xml2json.py vendor/data/xbrl/utr/%.xml
155-
$(MKDIRP) $(dir $@)
156160
$(PYTHON) $< $(word 2,$^) $@
157161
schemas/xbrl/utr/%.json: build/xbrl/utr/utr.json templates/xbrl/utr/%.jq
158162
$(MKDIRP) $(dir $@)
@@ -166,6 +170,26 @@ schemas/iso/country/2020/%.json: \
166170
$(JQ) --from-file $(word 2,$^) $< > $@
167171
$(JSONSCHEMA) fmt $@
168172

173+
build/iso/language/iso-639-2.json: \
174+
vendor/data/iso/language/ISO-639-2_utf-8.txt \
175+
scripts/csv2json.py
176+
$(PYTHON) $(word 2,$^) --delimiter '|' --encoding utf-8-sig --no-header \
177+
--field-names "part2b,part2t,part1,name,name_french" $< $@
178+
build/iso/language/iso-639-3.json: \
179+
vendor/data/iso/language/iso-639-3_Code_Tables/iso-639-3_Code_Tables_20251015/iso-639-3.tab \
180+
scripts/csv2json.py
181+
$(PYTHON) $(word 2,$^) --tab $< $@
182+
build/iso/language/enriched.json: \
183+
build/iso/language/iso-639-2.json \
184+
build/iso/language/iso-639-3.json \
185+
scripts/enrich-iso-language.py
186+
$(PYTHON) $(word 3,$^) $< $(word 2,$^) $@
187+
schemas/iso/language/2023/%.json: \
188+
build/iso/language/enriched.json \
189+
templates/iso/language/2023/%.jq
190+
$(MKDIRP) $(dir $@)
191+
$(JQ) --from-file $(word 2,$^) $< > $@
192+
$(JSONSCHEMA) fmt $@
169193

170194
# TODO: Add a `jsonschema pkg` command instead
171195
.PHONY: dist

0 commit comments

Comments
 (0)