aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 72a1ac0d5475f9fe64461d9e1bb84ec85552b7c2 (plain)
  1. DOCUMENTS = report
  2. PDF_DOCUMENTS = _site/report.pdf
  3. include _make/*.mk
  4. FILTER = sem-md/sem-md.lua
  5. DIFFTESTS = $(patsubst %.md.md,%,$(wildcard test/*.md.md))
  6. _which = $(shell command -v $1 >/dev/null 2>&1 && echo $1 $2)
  7. DIFF_md = $(strip $(or \
  8. $(call _which,delta,--paging never --default-language md),\
  9. $(call _which,git,--no-pager diff --no-index),\
  10. diff -u))
  11. DIFF_html = $(strip $(or \
  12. $(call _which,delta,--paging never --default-language html),\
  13. $(call _which,git,--no-pager diff --no-index),\
  14. diff -u))
  15. DIFF_json = $(strip $(or \
  16. $(call _which,delta,--paging never --default-language json),\
  17. $(call _which,git,--no-pager diff --no-index),\
  18. diff -u))
  19. #PANDOC = pandoc -f markdown+fenced_divs+bracketed_spans-auto_identifiers
  20. PANDOC = pandoc --from commonmark
  21. #PANDOC = quarto pandoc --from commonmark
  22. SYNTAX_DIAGRAMS := $(patsubst %.py,%.svg,$(wildcard syntax/*.py))
  23. WORKFLOW_DIAGRAMS := $(patsubst %.cwl,%.svg,$(wildcard workflow/phase*.cwl))
  24. RAPPER = rapper -i rdfa
  25. #RAPPER += -f relativeURIs
  26. # implicit namespaces at <https://www.w3.org/2011/rdfa-context/rdfa-1.1>
  27. NS += foaf=http://xmlns.com/foaf/0.1/
  28. NS += rdfa=http://www.w3.org/ns/rdfa\#
  29. NS += rdfs=http://www.w3.org/2000/01/rdf-schema\#
  30. NS += schema=http://schema.org/
  31. NS += wd=https://www.wikidata.org/entity/
  32. NS += bibo=http://purl.org/ontology/bibo/
  33. NS += ov=http://open.vocab.org/terms/
  34. RAPPER += $(foreach s,$(NS),$(let a b,$(subst =, $(),$s), -f 'xmlns:$a="$b"'))
  35. _site/report.pdf: $(wildcard _*.qmd) $(SYNTAX_DIAGRAMS) $(WORKFLOW_DIAGRAMS)
  36. $(SYNTAX_DIAGRAMS): %.svg: %.py
  37. python3 $< > $@
  38. $(WORKFLOW_DIAGRAMS): %.svg: %.cwl
  39. cwltool --print-dot $< \
  40. | gvpr -f workflow/rotate.gvpr \
  41. | perl -pe 's/phase\d_//g;' \
  42. -e 's/label=\K[^\s",]+|translate_to_\w+/ "\"".join(" ", split(m{_}, $$&))."\"" /ge' \
  43. | dot -Tsvg > $@
  44. check: $(DIFFTESTS:%=check-native-%)
  45. $(strip luacheck --quiet --std none \
  46. --read-globals assert error ipairs os type pandoc PANDOC_VERSION \
  47. -- $(FILTER))
  48. $(DIFFTESTS:%=check-md-%): check-md-%: %.md %.md.md
  49. -$(strip $(PANDOC) --to commonmark --lua-filter $(FILTER) --wrap preserve < $< \
  50. | $(DIFF_md) $*.md.md /dev/stdin)
  51. $(DIFFTESTS:%=check-html-%): check-html-%: %.md
  52. -$(strip $(PANDOC) --lua-filter $(FILTER) --wrap preserve < $< \
  53. | $(DIFF_html) $*.plain.html /dev/stdin)
  54. $(DIFFTESTS:%=check-native-%): SHELL = /bin/bash
  55. $(DIFFTESTS:%=check-native-%): check-native-%: %.md
  56. -$(strip $(DIFF_json) \
  57. <($(if $(wildcard $*.native),cat $*.native,$(PANDOC) --to native < $*.md.md)) \
  58. <($(PANDOC) --to native --lua-filter $(FILTER) < $<))
  59. $(DIFFTESTS:%=delta-native-%): SHELL = /bin/bash
  60. $(DIFFTESTS:%=delta-native-%): delta-native-%: %.md.md %.native
  61. -$(strip $(DIFF_json) \
  62. <($(PANDOC) --to native < $*.md.md) \
  63. <(cat $*.native))
  64. $(DIFFTESTS:%=dump-native-%): dump-native-%: %.md
  65. $(PANDOC) --to native --lua-filter $(FILTER) < $<
  66. $(DIFFTESTS:%=turtle-from-%): turtle-from-%: %.rdfa.html
  67. $(RAPPER) -o turtle $< $(dir $<)
  68. $(DIFFTESTS:%=xmp-from-%): xmp-from-%: %.rdfa.html
  69. $(RAPPER) -o rdfxml-xmp $< $(dir $<)
  70. code.zip: sem-md/ Makefile README.md _make/ syntax/ test/
  71. git archive -o $@ HEAD $^
  72. .PHONY: check \
  73. $(foreach x,\
  74. check-md check-html check-native delta-native dump-native turtle-from xmp-from,\
  75. $(DIFFTESTS:%=$x-%))