Skip to content

Commit 025620d

Browse files
Redesign of repo tooling for mixed URI prefixes in 7.1 (#729)
* Redesign for mixed URI prefixes in 7.1 Closes #727 Unblocks #722 and #723 There's a lot going on here, and I spent several weeks trying to minimize this PR, split it into pieces, etc, but couldn't find a way that worked. So here's an outline of what's changed. 1. In the spec, many tables (notably enumsets) now have an explicit URI entry. I made the URIs their own column, not the two-line cells used for URIs of events and attributes earlier, mostly because I thought we have space. We can refactor that into using <br> if we prefer. 2. I re-wrote `build/uri-def.py` from the ground up as `build/extract-yaml-tsv.py`. `uri-def.py` was a 50-line script I wrote that I slowly changed into a 500-line monstristy that I find almost impossible to read or maintain. And it had many assumptions about the spec's format not only in its code (that's inevitable when parsing human text into machine-readable files) ubt also in its design. Trying to add the more versatile URIs was such a headache I decided to use it as an excuse for a long-verdue re-write. `extract-yaml-tsv.py` uses classes to have the code mirror the files it is designed to produce. It uses type annotations (which pass `mypy`) to avoid various typing bugs. It tries to do one thing in one place instead of doing all things possible everywhere. It's 100 lines longer than `uri-def.py` but faster to run and easier to maintain. I spent some effort to match ideosynracies of `uri-def.py`, like when to use `strings`, `'strings'`, or `"strings"` in the emitted YAML; but sometimes dong that was not possible without replicating `uri-def.py`'s worse parts, so there are some trivial changes (notably in the order of lists) in the files it creates. 3. I (accidentally) fixed various bugs of omission. `uri-def.py` was sloppy in how it handled the textual explantions in sections that had either gedstruct rules with alternatives or tables. Fixing that with a more principled approach means adding extra `specification:` entries for around half of all YAML files. 4. I tried but failed to match the sorting of the various .tsv files from `uri-def.py`, which was based on some kind of sorting of structures before they were used to generate multiple lines each. I was tempted to scrap that and simply sort the final lines, which is easy and well-defined, but this commit does not do that, instead doing a half-hearted effort at mimickiing the old sorting. I did all this on 7.1 because that was the original motivation, but if we like it I can port it back to the 7.0 branch (either by adding explicit URIs to the 7.0 spec or by adding special-case handling of tag-to-URI) with relative ease. * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * Update build/extract-yaml-tsv.py Co-authored-by: Dave Thaler <dthaler1968@gmail.com> * refactor to split YAML and TSV generation * add additional version checks, and many updated v7 -> v7.1 URIs * missing period; handle spaces around <br> in table * Fix erroneous 7.1 URI found by @dthaler * roll back some URIs to v7 --------- Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
1 parent e8ef142 commit 025620d

209 files changed

Lines changed: 8455 additions & 6215 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ PDARGS := --syntax-definition=gedcom.xml --syntax-definition=gedstruct.xml --syn
1212

1313
.phony: all clean distclean
1414

15-
all: $(PDF_FILE) $(PDF_FILE) $(TAGDEFS) $(GRAMMARS)
15+
all: $(TAGDEFS) $(GRAMMARS) $(PDF_FILE) $(HTML_FILE)
1616

1717
$(PDF_FILE): $(HTML_FILE)
1818
python3 -mweasyprint $(HTML_FILE) $(PDF_FILE)
1919

2020
$(HTML_FILE): hyperlink-code.py GEDCOM-tmp.html
2121
python3 hyperlink-code.py GEDCOM-tmp.html $(HTML_FILE)
2222

23-
$(TAGDEFS): $(MD_FILES) $(TERMS_FILES) uri-def.py
24-
python3 uri-def.py $(MD_FILES) $(TAGDEFS)
23+
$(TAGDEFS): $(MD_FILES) $(TERMS_FILES) $(EXTDIR)grammar.gedstruct extract-yaml.py
24+
python3 extract-yaml.py --spec=$(SPECDIR) --dest=$(EXTDIR)
25+
rsync -au $(TERMS_FILES) $(EXTDIR)tags
26+
python3 yaml-to-tsv.py --dest=$(EXTDIR) $(TAGDEFS)
2527
touch $(TAGDEFS)
2628

2729
$(EXTDIR)grammar.abnf: $(MD_FILES) extract-grammars.py

0 commit comments

Comments
 (0)