diff --git a/docs/Makefile b/docs/Makefile index 2d83913..3da29c7 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -9,12 +9,12 @@ # Make configuration include make.d/prelude.make -# Metadata directory -Metadata := .meta - # jqt version Version := 0.5.1 +# Metadata directory +Metadata := .meta + # Do not build to clobber immediately ifeq (clobber,$(MAKECMDGOALS)) ifeq (,$(wildcard $(Metadata))) @@ -61,10 +61,14 @@ ifdef __phase_1 # ====================================================================== -include $(Metadata)/phase2.make - include make.d/pathnames.make + include make.d/data.make # # Variables defined in phase2.make: # __phase_2 +# DataCSV +# DataJSON +# DataMD +# DataYAML # DestinationPages # DestinationPaths # MetadataPages @@ -76,6 +80,8 @@ ifdef __phase_1 # $(MetadataPages) # $(Metadata)/pages.json # $(Metadata)/sections.json +# Defined targets: +# init # ====================================================================== ifdef __phase_2 @@ -84,8 +90,7 @@ ifdef __phase_2 -include $(Metadata)/phase3.make include make.d/pages.make # -# Load rules for pages and nodes. If not exists is built when restarting with -# rule defined in `pages.make`. +# Load rules for pages and nodes. # # Variables defined in phase3.make: # __phase_3 @@ -98,7 +103,6 @@ ifdef __phase_2 # clean # clobber # fresh -# init # touch # ====================================================================== @@ -122,7 +126,7 @@ include make.d/tools.make # ====================================================================== ######################################################################## -include jqt.make +include project.make # # Project specific makefile. All the previous modules are expected to be # independent, valid for any project without any change. diff --git a/docs/make.d/pathnames.make b/docs/make.d/data.make similarity index 69% rename from docs/make.d/pathnames.make rename to docs/make.d/data.make index 89644bc..58a5916 100644 --- a/docs/make.d/pathnames.make +++ b/docs/make.d/data.make @@ -1,10 +1,14 @@ ######################################################################## -# pathnames.make +# data.make # # Build metadata from filesystem introspection. # # Variables defined in phase2.make: # __phase_2 +# DataCSV +# DataJSON +# DataMD +# DataYAML # DestinationPages # DestinationPaths # MetadataPages @@ -16,13 +20,16 @@ # $(MetadataPages) # $(Metadata)/pages.json # $(Metadata)/sections.json +# $(DataFiles) +# Targets: +# init ######################################################################## # Create makefile defining global variables about pathnames and rules to # generate JSON metadata files for each page. ######################################################################## -$(Metadata)/phase2.make: make.d/pathnames.make make.d/phase2.jq $(Metadata)/phase1.make +$(Metadata)/phase2.make: make.d/data.make make.d/phase2.jq $(Metadata)/phase1.make $(info ==> $@) @find $(Content) -type f -a \ -name '[!_]*.md' -o \ @@ -34,6 +41,7 @@ $(Metadata)/phase2.make: make.d/pathnames.make make.d/phase2.jq $(Metadata)/phas --from-file make.d/phase2.jq \ --arg DF "$$(find $(Data) -name '*.*')" \ --arg Content $(Content) \ + --arg Data $(Data) \ --arg Destination $(Destination) \ --arg Metadata $(Metadata) \ > $@ @@ -68,10 +76,9 @@ endef $(DestinationPages): $(Destination)/%.html : $(Metadata)/pages/%.json $(DestinationPages): $(Layouts)/default.html +$(DestinationPages): | $$(dir $$@) $(MetadataPages): $(Metadata)/config.json - -$(DestinationPages): | $$(dir $$@) $(MetadataPages): | $$(dir $$@) ######################################################################## @@ -100,6 +107,49 @@ $(Metadata)/sections.json: $(Metadata)/pages.json $(info ==> $@) @jq '[.[].section] | unique | map(select(.))' < $< > $@ +######################################################################## +# Files derived from $(Data)/* +######################################################################## + +ifneq (,$(DataMD)) +$(DataMD): $(Metadata)/%.json : $(Data)/%.md | $(Metadata) + $(info ==> $@) + @jqt -T < $< | yaml2json > $@ +endif + +ifneq (,$(DataYAML)) +$(DataYAML): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @yaml2json > $@ +endif + +ifneq (,$(DataJSON)) +$(DataJSON): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @jqt -P json < $< > $@ +endif + +ifneq (,$(DataCSV)) +$(DataCSV): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) + $(info ==> $@) + @csv2json < $< > $@ +endif + +DataFiles := $(DataMD) $(DataYAML) $(DataJSON) $(DataCSV) + +######################################################################## + +$(DestinationPages): $(DataFiles) + +# make all metadata and data files +init:: +ifdef MAKE_RESTARTS + @$(MAKE) -s $(DataFiles) +else + @rm -rf $(Metadata) + @$(MAKE) -s $(DataFiles) +endif + endif # __phase_2 # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/pages.make b/docs/make.d/pages.make index 81e07a8..834c7d1 100644 --- a/docs/make.d/pages.make +++ b/docs/make.d/pages.make @@ -11,7 +11,6 @@ # clean # clobber # fresh -# init # touch ######################################################################## @@ -28,6 +27,8 @@ $(Metadata)/phase3.make: $(Metadata)/pages.json make.d/pages.make make.d/phase3. --from-file make.d/phase3.jq \ < $< > $@ +ifdef __phase_3 + # # Variables used in $(Metadata)/phase3.make. # @@ -47,8 +48,6 @@ define DETAILS := -e 's/<\/summary><\/p>/<\/summary>/' endef -ifdef __phase_3 - ######################################################################## # Standard targets ######################################################################## @@ -89,15 +88,6 @@ touch: fresh: clobber @$(MAKE) -s all -# 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/phase2.jq b/docs/make.d/phase2.jq index ea2624a..444421a 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) --arg DF "$$(find $(Data) -name '*.*') +# phase2.jq --arg ... # # Generate phase2.make from `find` output. @@ -50,12 +50,23 @@ def mpages($documents): def data($files): + def d2m($x): + sub("\\."+$x+"$"; ".json") + | sub("^"+$Data; $Metadata) + ; ($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 - | "" + | [$names[] | select(test(".md$"))] as $DataMD + | [$names[] | select(test(".yaml$"))] as $DataYAML + | [$names[] | select(test(".json$"))] as $DataJSON + | [$names[] | select(test(".csv$"))] as $DataCSV + | if ($DataMD|length) == 0 then "DataMD :=\n" + else "DataMD := " + ($DataMD | map(d2m("md")) | join(" ")) + "\n" end + + if ($DataYAML|length) == 0 then "DataYAML :=\n" + else "DataYAML := " + ($DataYAML | map(d2m("yaml")) | join(" ")) + "\n" end + + if ($DataJSON|length) == 0 then "DataJSON :=\n" + else "DataJSON := " + ($DataJSON | map(d2m("json")) | join(" ")) + "\n" end + + if ($DataCSV|length) == 0 then "DataCSV :=\n" + else "DataCSV := " + ($DataCSV | map(d2m("csv")) | join(" ")) + "\n" end ; ######################################################################## diff --git a/docs/jqt.make b/docs/project.make similarity index 66% rename from docs/jqt.make rename to docs/project.make index 0f917df..64404d6 100644 --- a/docs/jqt.make +++ b/docs/project.make @@ -3,81 +3,21 @@ # Specific makefile for this web site # # Defined rules for: -# $(Metadata)/snippets.json # $(ManPage) # /tmp/help # Defined targets: # all # clean # clobber -# init ######################################################################## -# Data files +# Build pages options ######################################################################## # 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 - -ifneq (,$(DataYAML)) -$(DataYAML): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) - $(info ==> $@) - @yaml2json > $@ -endif - -ifneq (,$(DataJSON)) -$(DataJSON): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) - $(info ==> $@) - @jqt -P json < $< > $@ -endif - -ifneq (,$(DataCSV)) -$(DataCSV): $(Metadata)/%.json : $(Data)/%.yaml | $(Metadata) - $(info ==> $@) - @csv2json < $< > $@ -endif - -DataFiles := $(DataMD) $(DataYAML) $(DataJSON) $(DataCSV) - -ifneq (,$(DataFiles)) - -$(DestinationPages): $(DataFiles) - -init:: - @$(MAKE) -s $(DataFiles) - -endif - -######################################################################## -# Build pages options -######################################################################## - -# Extra dependencies -#?$(DestinationPages): $(Blocks)/filters.jq $(Blocks)/*/*.html $(Blocks)/*/*/*.html - # Options for `jqt`. JQTFLAGS += \ -5 \ @@ -87,6 +27,9 @@ JQTFLAGS += \ # only for derived nodes? # -msections:$(Metadata)/sections.json \ +# Extra dependencies +#?$(DestinationPages): $(Blocks)/filters.jq $(Blocks)/*/*.html $(Blocks)/*/*/*.html + ######################################################################## # Generate man page for jqt ########################################################################