diff --git a/docs/Makefile b/docs/Makefile index 5a2ed1b..1489d70 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -9,10 +9,16 @@ include make.d/config.make # Metadata directory Metadata := .yummy +# jqt/yummy version +Version := $(shell cat ../VERSION) + # Load global parameters +# As a side effect config.json and site.json are built -include $(Metadata)/globals.make -# Defined in globals.make: +# Defined in globals.make +# ======================= +# Variables: # __globals__ # Assets # Blocks @@ -28,15 +34,31 @@ ifneq (clobber,$(MAKECMDGOALS)) # Define targets for basic metadata include make.d/metadata.make +# Defined in metadata.make +# ======================== +# Targets: +# $(Metadata) +# $(Metadata)/config.json +# $(Metadata)/site.json +# $(Metadata)/globals.make + # Build metadata from introspection ifdef __globals__ include make.d/introspect.make endif -# Defined in introspect.make: +# Defined in introspect.make +# ========================== +# Variables: # HomePage # Pages # OtherPages +# PagesJSON +# Nodes +# NodesJSON +# Targets: +# $(Destination) +# all paths at $(Destination) and $(Metadata) endif # not clobbering @@ -109,15 +131,16 @@ Targets := $(Pages) $(Files) $(ManPage) # Extra dependencies # -$(Pages): \ +# All pages +$(Pages): \ $(Blocks)/*/markup.html \ $(Blocks)/filters.jq \ $(Content)/LINKS.txt \ $(Content)/macros.m \ - $(Metadata)/config.json \ $(Metadata)/snippets.json \ + $(Metadata)/config.json \ - +# All pages except home page $(OtherPages): \ $(Content)/FLOW.txt \ $(Layouts)/page.html \ diff --git a/docs/config.yaml b/docs/config.yaml index 202ae90..7388378 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -30,12 +30,12 @@ Layouts: ./blocks # shared space title: jqt, the jq template engine baseURL: https://fadado.github.com/jqt/ -lang: en +lang: &lang en logo: "❴❴❏❵❵" author: - email: jordinas@gmail.com - name: Joan Josep Ordinas Rosa + name: &author Joan Josep Ordinas Rosa # TODO: instrospect menu: @@ -55,5 +55,13 @@ menu: path: content/data.md name: Data +# Default values +defaults: + - idprefix: "" # all files + properties: + title-prefix: jqt + author: *author + lang: *lang + # vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=yaml ... diff --git a/docs/make.d/introspect.make b/docs/make.d/introspect.make index f108654..3b8e72e 100644 --- a/docs/make.d/introspect.make +++ b/docs/make.d/introspect.make @@ -10,22 +10,27 @@ # HomePage # Pages # OtherPages -# ... +# PagesJSON +# Nodes +# NodesJSON +# Targets for: +# $(Destination) +# all paths at $(Destination) and $(Metadata) # Markdown documents found in the filesystem (only .md extensions) -_documents := $(sort $(shell find $(Content) -type f -a -name '*.md')) +i_documents := $(sort $(shell find $(Content) -type f -a -name '*.md')) # Unique paths to documents directories -_paths := $(sort $(dir $(_documents))) +i_paths := $(sort $(dir $(i_documents))) # Paths to create at $(Destination) -_paths_destination := $(patsubst $(Content)%,$(Destination)%,$(_paths)) +i_paths_destination := $(patsubst $(Content)%,$(Destination)%,$(i_paths)) # Paths to nodes at $(Metadata) -_paths_meta_nodes := $(patsubst $(Content)%,$(Metadata)/nodes%,$(_paths)) +i_paths_meta_nodes := $(patsubst $(Content)%,$(Metadata)/nodes%,$(i_paths)) # Paths to pages at $(Metadata) -_paths_meta_pages := $(patsubst $(Content)%,$(Metadata)/pages%,$(_paths)) +i_paths_meta_pages := $(patsubst $(Content)%,$(Metadata)/pages%,$(i_paths)) # # Make directories @@ -33,16 +38,16 @@ _paths_meta_pages := $(patsubst $(Content)%,$(Metadata)/pages%,$(_paths)) $(Destination): $(info ==> $@) - @mkdir $@ >/dev/null 2>&1 || true + @mkdir -p $@ >/dev/null 2>&1 || true -$(_paths_destination): $(Destination)/% : $(Content)/% - @mkdir $@ >/dev/null 2>&1 || true +$(i_paths_destination): $(Destination)/% : $(Content)/% + @mkdir -p $@ >/dev/null 2>&1 || true -$(_paths_meta_pages): $(Metadata)/pages/% : $(Content)/% - @mkdir $@ >/dev/null 2>&1 || true +$(i_paths_meta_pages): $(Metadata)/pages/% : $(Content)/% + @mkdir -p $@ >/dev/null 2>&1 || true -$(_paths_meta_nodes): $(Metadata)/nodes/% : $(Content)/% - @mkdir $@ >/dev/null 2>&1 || true +$(i_paths_meta_nodes): $(Metadata)/nodes/% : $(Content)/% + @mkdir -p $@ >/dev/null 2>&1 || true # # Global names defined @@ -52,17 +57,17 @@ $(_paths_meta_nodes): $(Metadata)/nodes/% : $(Content)/% HomePage := $(Destination)/index.html # Pages to generate at $(Destination) -Pages := $(patsubst %.md,%.html,$(patsubst $(Content)%,$(Destination)%,$(_documents))) +Pages := $(patsubst %.md,%.html,$(patsubst $(Content)%,$(Destination)%,$(i_documents))) OtherPages := $(filter-out $(HomePage),$(Pages)) # JSON for each page to generate at $(Metadata)/pages -PagesJSON := $(patsubst %.md,%.json,$(patsubst $(Content)%,$(Metadata)/pages%,$(_documents))) +PagesJSON := $(patsubst %.md,%.json,$(patsubst $(Content)%,$(Metadata)/pages%,$(i_documents))) # Nodes to generate at $(Destination) -NodesHTML := $(call rest,$(patsubst %/,%/index.html,$(_paths_destination)))) +Nodes := $(call rest,$(patsubst %/,%/index.html,$(i_paths_destination))) # JSON for each node to generate at $(Metadata)/nodes -NodesJSON := $(call rest,$(patsubst %/,%.json,$(_paths_meta_nodes)))) +NodesJSON := $(call rest,$(patsubst %/,%.json,$(i_paths_meta_nodes))) ######################################################################### # Test @@ -71,18 +76,18 @@ intro: @echo 'Content: $(Content)' @echo 'Destination: $(Destination)' @echo - @echo '_documents: $(_documents)' - @echo '_paths: $(_paths)' + @echo 'i_documents: $(i_documents)' + @echo 'i_paths: $(i_paths)' @echo - @echo '_paths_meta_nodes: $(_paths_meta_nodes)' - @echo '_paths_meta_pages: $(_paths_meta_pages)' - @echo '_paths_destination: $(_paths_destination)' + @echo 'i_paths_meta_nodes: $(i_paths_meta_nodes)' + @echo 'i_paths_meta_pages: $(i_paths_meta_pages)' + @echo 'i_paths_destination: $(i_paths_destination)' @echo @echo 'HomePage: $(HomePage)' @echo 'Pages: $(Pages)' @echo 'OtherPages: $(OtherPages)' @echo 'PagesJSON: $(PagesJSON)' - @echo 'NodesHTML: $(NodesHTML)' + @echo 'Nodes: $(Nodes)' @echo 'NodesJSON: $(NodesJSON)' # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/metadata.make b/docs/make.d/metadata.make index 2fe4a93..2aed199 100644 --- a/docs/make.d/metadata.make +++ b/docs/make.d/metadata.make @@ -4,39 +4,31 @@ # Imported variables: # Metadata +# Version +# Targets for: +# $(Metadata) +# $(Metadata)/config.json ==> +# $(Metadata)/site.json ==> +# $(Metadata)/globals.make # Metadata directory $(Metadata): $(info ==> $@) - @mkdir $@ >/dev/null 2>&1 || true + @mkdir -p $@ >/dev/null 2>&1 || true # -# Configuration files +# config.json, site.json and globals.make # -# Members to mix with config.yaml when converted to JSON -define JSON_GLOBALS := - . + { \ - Destination: (.Destination // "./_site"), \ - Assets: (.Assets // "./assets"), \ - Blocks: (.Blocks // "./blocks"), \ - Content: (.Content // "./content"), \ - Data: (.Data // "./data"), \ - Layouts: (.Layouts // "./layouts"), \ - Styles: (.Styles // "./styles") \ - } -endef - -# Main configuration file. -# Must be named config.yaml or config.json and must exist. +# Create $(Metadata)/config.json +# Input is user defined config.yaml or config.json. ifeq (config.yaml, $(wildcard config.yaml)) # Convert config.yaml to $(Metadata)/config.json $(Metadata)/config.json: config.yaml \ | $(Metadata) $(info ==> $@) - @yaml2json < $< \ - | jq --sort-keys '$(JSON_GLOBALS)' > $@ + @yaml2json < $< > $@ else ifeq (config.json, $(wildcard config.json)) @@ -44,15 +36,33 @@ else ifeq (config.json, $(wildcard config.json)) $(Metadata)/config.json: config.json \ | $(Metadata) $(info ==> $@) - @jqt -Pjson < $< \ - | jq --sort-keys '$(JSON_GLOBALS)' > $@ + @jqt -Pjson < $< > $@ else $(error Configuration file not found) endif +# Globals definition to mix with config.json +define m_SITE_JSON := + del(.defaults) \ + | . + { \ + Destination: (.Destination // "./_site"), \ + Assets: (.Assets // "./assets"), \ + Blocks: (.Blocks // "./blocks"), \ + Content: (.Content // "./content"), \ + Data: (.Data // "./data"), \ + Layouts: (.Layouts // "./layouts"), \ + Styles: (.Styles // "./styles"), \ + Version: (.Version // "$(Version)") \ + } +endef + +$(Metadata)/site.json: $(Metadata)/config.json + $(info ==> $@) + @jq --sort-keys '$(m_SITE_JSON)' < $< > $@ + # Variables to define in globals.make -define MAKE_GLOBALS := +define m_MAKE_GLOBALS := "__globals__ := 1", \ "Destination := " + .Destination, \ "Assets := " + .Assets, \ @@ -64,24 +74,26 @@ define MAKE_GLOBALS := "# vim:syntax=make" endef -# Create makefile with globals -$(Metadata)/globals.make: $(Metadata)/config.json +# Create globals.make +$(Metadata)/globals.make: $(Metadata)/site.json $(info ==> $@) - @jq --sort-keys \ - --raw-output \ - '$(MAKE_GLOBALS)' \ + @jq --raw-output \ + '$(m_MAKE_GLOBALS)' \ < $< > $@ ifdef __globals__ -# TODO: rest of metadata files... - +# +# TODO: in this file??? +# Metadata files built with globals defined +# # Build all metadata files (utility not called automatically) .PHONY: metadata metadata: \ + $(Metadata)/globals.make \ $(Metadata)/config.json \ - $(Metadata)/globals.make + $(Metadata)/site.json @: endif # __globals__