diff --git a/docs/Makefile b/docs/Makefile index 26d3159..2d83913 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -9,12 +9,12 @@ # Make configuration include make.d/prelude.make -# jqt version -Version := 0.5.1 - # Metadata directory Metadata := .meta +# jqt version +Version := 0.5.1 + # Do not build to clobber immediately ifeq (clobber,$(MAKECMDGOALS)) ifeq (,$(wildcard $(Metadata))) @@ -22,6 +22,13 @@ $(error Nothing to clobber) endif endif +# Do not build to clean immediately +ifeq (clean,$(filter clean,$(MAKECMDGOALS))) +ifeq (,$(wildcard $(Metadata))) +$(error Nothing to clean) +endif +endif + # ====================================================================== -include $(Metadata)/phase1.make include make.d/config.make diff --git a/docs/content/data.md b/docs/content/data.md index d0bd85a..2bd1290 100644 --- a/docs/content/data.md +++ b/docs/content/data.md @@ -5,7 +5,7 @@ title: Managing the data model with jqt description: jqt combines one template with one MarkDown document and a data model. keywords: jqt, JSON, YAML, gpp, preprocessing, data model updated: "2016-08-28T10:27:09Z" -use: [content/macros.m, content/LINKS.txt, content/FLOW.txt, "content/opt/[DeIMmnPRT].txt"] +use: [content/macros.m, content/LINKS.txt, content/FLOW.txt, "content/opt/[DeIMmPRT].txt"] --- <%include content/macros.m>& <%include content/LINKS.txt>& diff --git a/docs/content/engine.md b/docs/content/engine.md index 8d0e751..d4e04fa 100644 --- a/docs/content/engine.md +++ b/docs/content/engine.md @@ -5,7 +5,7 @@ title: The jqt template engine description: jqt orchestrates several shell utilities to transform MarkDown text and YAML or JSON data into a final HTML page. keywords: jqt, jq, YAML, gpp, preprocessing, template engine updated: "2016-08-28T10:27:09Z" -use: [content/macros.m, content/LINKS.txt, content/FLOW.txt, "content/opt/[4CDdeHhIijLMmnPprSTtVw].txt"] +use: [content/macros.m, content/LINKS.txt, content/FLOW.txt, "content/opt/[4CDdeHhIijLMmPprSTtVw].txt"] --- <%include content/macros.m>& <%include content/LINKS.txt>& diff --git a/docs/data/snippets.yaml b/docs/data/snippets.md similarity index 100% rename from docs/data/snippets.yaml rename to docs/data/snippets.md diff --git a/docs/jqt.make b/docs/jqt.make index 70ef34d..0f917df 100644 --- a/docs/jqt.make +++ b/docs/jqt.make @@ -1,21 +1,75 @@ ######################################################################## +# # Specific makefile for this web site +# +# Defined rules for: +# $(Metadata)/snippets.json +# $(ManPage) +# /tmp/help +# Defined targets: +# all +# clean +# clobber +# init ######################################################################## # Data files ######################################################################## -# Snippets -$(Metadata)/snippets.json: $(Data)/snippets.yaml \ -| $(Metadata) +# Declare explicitly modules with -m, -M or -j; this must be decided by a +# human! +JQTFLAGS += -msnippets:$(Metadata)/snippets.json + +# To define in phase2.make from +# find $(Data) -name '*.*' + +DataMD := $(Metadata)/snippets.json +DataYAML := +DataJSON := +DataCSV := + +# ========================= +# To move to pathnames.make +# ========================= + +# +# Files derived from $(Data)/* +# + +ifneq (,$(DataMD)) +$(DataMD): $(Metadata)/%.json : $(Data)/%.md | $(Metadata) $(info ==> $@) @jqt -T < $< | yaml2json > $@ +endif -$(DestinationPages): $(Metadata)/snippets.json +ifneq (,$(DataYAML)) +$(DataYAML): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @yaml2json > $@ +endif -JQTFLAGS += -msnippets:$(Metadata)/snippets.json +ifneq (,$(DataJSON)) +$(DataJSON): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @jqt -P json < $< > $@ +endif + +ifneq (,$(DataCSV)) +$(DataCSV): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @csv2json < $< > $@ +endif -clean:: ; @rm -f $(Metadata)/snippets.json +DataFiles := $(DataMD) $(DataYAML) $(DataJSON) $(DataCSV) + +ifneq (,$(DataFiles)) + +$(DestinationPages): $(DataFiles) + +init:: + @$(MAKE) -s $(DataFiles) + +endif ######################################################################## # Build pages options @@ -29,7 +83,9 @@ JQTFLAGS += \ -5 \ --toc-depth=4 \ -iblocks/filters \ - -msections:$(Metadata)/sections.json \ + +# only for derived nodes? +# -msections:$(Metadata)/sections.json \ ######################################################################## # Generate man page for jqt diff --git a/docs/make.d/pages.make b/docs/make.d/pages.make index 35ec960..81e07a8 100644 --- a/docs/make.d/pages.make +++ b/docs/make.d/pages.make @@ -18,8 +18,8 @@ # Create makefile containing rules for all HTML files ######################################################################## -# Rules for each page (depend also on sections.json only to force build) -$(Metadata)/phase3.make: $(Metadata)/pages.json $(Metadata)/sections.json make.d/pages.make make.d/phase3.jq $(Metadata)/phase2.make +# Build rules for each page +$(Metadata)/phase3.make: $(Metadata)/pages.json make.d/pages.make make.d/phase3.jq $(Metadata)/phase2.make $(info ==> $@) @jq --raw-output \ --arg Metadata $(Metadata) \ @@ -32,10 +32,11 @@ $(Metadata)/phase3.make: $(Metadata)/pages.json $(Metadata)/sections.json make.d # Variables used in $(Metadata)/phase3.make. # -JQTFLAGS = \ - -I./ \ - -msite:$(Metadata)/config.json \ - -j'$$'pages:$(Metadata)/pages \ +define JQTFLAGS := + -msite:$(Metadata)/config.json \ + -j'$$'pages:$(Metadata)/pages \ + -I./ +endef JQT = jqt $(JQTFLAGS) @@ -88,10 +89,15 @@ touch: fresh: clobber @$(MAKE) -s all -init: +# make all metadata except files derived from $(Data) +init:: +ifdef MAKE_RESTARTS + @: +else @rm -rf $(Metadata) @$(MAKE) -s $(Metadata)/phase3.make - endif +endif # __phase_3 + # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/pathnames.make b/docs/make.d/pathnames.make index fe8b23b..89644bc 100644 --- a/docs/make.d/pathnames.make +++ b/docs/make.d/pathnames.make @@ -32,6 +32,7 @@ $(Metadata)/phase2.make: make.d/pathnames.make make.d/phase2.jq $(Metadata)/phas --slurp \ --raw-output \ --from-file make.d/phase2.jq \ + --arg DF "$$(find $(Data) -name '*.*')" \ --arg Content $(Content) \ --arg Destination $(Destination) \ --arg Metadata $(Metadata) \ @@ -99,6 +100,6 @@ $(Metadata)/sections.json: $(Metadata)/pages.json $(info ==> $@) @jq '[.[].section] | unique | map(select(.))' < $< > $@ -endif +endif # __phase_2 # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/phase2.jq b/docs/make.d/phase2.jq index 78bf9ba..ea2624a 100644 --- a/docs/make.d/phase2.jq +++ b/docs/make.d/phase2.jq @@ -1,4 +1,4 @@ -# phase2.jq --arg Content $(Content) --arg Destination $(Destination) --arg Metadata $(Metadata) +# phase2.jq --arg Content $(Content) --arg Destination $(Destination) --arg Metadata $(Metadata) --arg DF "$$(find $(Data) -name '*.*') # # Generate phase2.make from `find` output. @@ -48,6 +48,16 @@ def mpages($documents): | "MetadataPages := " + ($json | join(" ")) + "\n" + mrule ; + +def data($files): + ($files / "\n") as $names + | [($names[] | select(test(".md$")))] as $DataMD + | [($names[] | select(test(".yaml$")))] as $DataYAML + | [($names[] | select(test(".json$")))] as $DataJSON + | [($names[] | select(test(".csv$")))] as $DataCSV + | "" +; + ######################################################################## # Output makefile ######################################################################## @@ -58,12 +68,14 @@ def mpages($documents): | mpaths($paths) as $MetadataPaths | dpages($documents) as $DestinationPages | mpages($documents) as $MetadataPages +| data($DF) as $DataFiles | "__phase_2 := 1", $DestinationPaths, $MetadataPaths, $DestinationPages, $MetadataPages, +$DataFiles, comment # vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq