diff --git a/docs/Makefile b/docs/Makefile index 56c6a73..70be33b 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,15 +2,10 @@ # Makefile for web site management # # Project: jqt -# Author: jordinas@gmail.com <Joan Josep Ordinas Rosa> +# Author: <Joan Josep Ordinas Rosa> jordinas@gmail.com # Published: https://fadado.github.io/jqt/ ######################################################################## -# Debug tool -ifdef MAKE_RESTARTS -$(info Makefile restarted: $(MAKE_RESTARTS)) -endif - # Make configuration include make.d/prelude.make @@ -20,20 +15,13 @@ Version := $(shell cat ../VERSION) # Metadata directory Metadata := .meta -# Do not build to clobber immediately -ifeq (clobber,$(MAKECMDGOALS)) -ifeq (,$(wildcard $(Metadata))) -$(error Nothing to clobber) -endif -endif - # ====================================================================== -include $(Metadata)/globals.make # # Load global parameters. If `globals.make` not exists it is built when # restarting with a rule defined in `config.make`. # -# Variables: +# Exported variables: # __globals__ # Assets # Blocks @@ -88,10 +76,11 @@ include make.d/pathnames.make # PagesJSON # Exported targets: # $(Destination) +# all # all paths starting at $(Destination) and $(Metadata) # Additional dependencies defined: -# each HTML page from his metadata and directory -# each HTML node from his metadata and directory +# $(Destination)/.../page.html => $(Metadata)/pages/.../page.json +# $(Destination)/.../node/index.html => $(Metadata)/nodes/.../node.json # ====================================================================== # ====================================================================== @@ -103,8 +92,11 @@ include make.d/front-matter.make # Content # Metadata # Exported targets: -# JSON metadata files for pages and nodes -# JSON files grouping other metadata files +# $(Metadata)/pages/.../page.json +# $(Metadata)/nodes/.../node.json +# $(Metadata)/pages.json +# $(Metadata)/nodes.json +# $(Metadata)/sections.json # ====================================================================== # ====================================================================== @@ -113,12 +105,14 @@ include make.d/front-matter.make # Load rules for pages and nodes. If not exists is built when restarting with # rule defined in `rules.make`. # -# Variables: +# Exported variables: # __html__ # Exported targets: # rules for all HTML files # ====================================================================== +ifdef __html__ + # Options for `jqt`. JQTFLAGS = \ -5 \ @@ -128,6 +122,8 @@ JQTFLAGS = \ -msnippets:$(Metadata)/snippets.json \ --toc-depth=4 \ +endif + # ====================================================================== include make.d/rules.make # @@ -140,34 +136,45 @@ include make.d/rules.make # Metadata # Exported targets: # $(Metadata)/html.make -# +# all +# build +# clean +# clobber +# xbuild # ====================================================================== -######################################################################## -# Rules -######################################################################## - -.PHONY: clean clobber build rebuild xbuild - -# Delete generated publications -clean:: - @rm -rf $(Destination)/* - -# Delete all generated files and directories -clobber:: - @rm -rf $(Destination) $(Metadata) - -# Build again all documents -build: clean all +# ====================================================================== +include make.d/tools.make +# +# Tools independent of any target. +# +# Parameters: +# vnudir +# Imported variables: +# Destination +# Exported targets: +# help +# valid +# lint +# ====================================================================== +# ====================================================================== +include make.d/styles.make +# +# Build CSS main stylesheet. # -rebuild: clobber - @$(MAKE) -s all +# Imported variables: +# Destination +# Blocks +# Styles +# Exported targets: +# $(Destination)/styles.css +# all +# ====================================================================== -# Build again all config.yaml dependents -xbuild: - @touch config.yaml - @$(MAKE) -s all +######################################################################## +# Specific rules this web site +######################################################################## # Snippets $(Metadata)/snippets.json: $(Content)/snippets.yaml \ @@ -178,39 +185,54 @@ $(Metadata)/snippets.json: $(Content)/snippets.yaml \ # Extra dependencies $(Pages): $(Metadata)/snippets.json $(Blocks)/filters.jq -# Generate CSS stylesheet -all:: $(Destination)/styles.css - -# Styles -$(Destination)/styles.css: \ - $(Blocks)/*/*style.css \ - $(Styles)/*.css \ - $(Styles)/*.m \ - $(Styles)/milligram/*.css \ +# +# Generate man page for jqt +# -# CSS stylesheet -$(Destination)/styles.css: $(Styles)/page.css +# gpp for the man page (to be build without calling jqt!) +GPP_MD := gpp \ + -U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \ + -M '<%' '>' '\B' '\B' '\W>' '<' '>' \ + +sccc '&\n' '' '' \ + +sccc '\\n' '' '' \ + +sccc '<\#' '\#>\n' '' \ + +siqi "'" "'" '\' \ + +siQi '"' '"' '\' \ + +ssss '<!--' '-->' '' \ + +ssss '`' '`' '' \ + +ssss '\n```' '\n```' '' \ + +ssss '\n~~~' '\n~~~' '' \ + +# +ManPage := ../jqt.1.gz + +# Man page: jqt(1) +$(ManPage): $(Content)/jqt.1.markdown $(info ==> $@) - @jqt -P CSS-min -I$(Styles) < $< > $@ - -# Generate man page for jqt -include make.d/man.make + @$(GPP_MD) -I$(Content) < $< \ + | pandoc --standalone --from markdown --to man \ + | gzip > $@ -# last all:: rule -all:: # copy Assets - @cp --verbose --recursive --update $(Assets)/* $(Destination) \ - | sed "s/^.*-> ./==> /;s/.$$//" - @echo 1>&2 'Imprimatur.' +# Add prerequisites and recipes to common targets +all:: $(ManPage) -######################################################################## -# Tools -######################################################################## +clean:: + @rm -f $(ManPage) -# Validate HTML 5 -include make.d/vnu.make +clobber:: + @rm -f $(ManPage) -# help and other targets -include make.d/tools.make +######################################################################## +# Generate Help text +# Independent target: helps generating text for `jqt -h` +# Needs explicit call: `make /tmp/help` +# +/tmp/help: $(Content)/help.markdown + $(info ==> $@) + @jqt -P MarkDown -I$(Content) < $< \ + | pandoc --from markdown --to plain - \ + | sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \ + > $@ endif # __globals__ diff --git a/docs/make.d/front-matter.make b/docs/make.d/front-matter.make index ae0f947..dd9000c 100644 --- a/docs/make.d/front-matter.make +++ b/docs/make.d/front-matter.make @@ -7,8 +7,11 @@ # Content # Metadata # Exported targets: -# JSON metadata files for pages and nodes -# JSON files grouping other metadata files +# $(Metadata)/pages/.../page.json +# $(Metadata)/nodes/.../node.json +# $(Metadata)/pages.json +# $(Metadata)/nodes.json +# $(Metadata)/sections.json ######################################################################## # Collect metadata for pages @@ -130,6 +133,6 @@ $(Metadata)/sections.json: $(Metadata)/pages.json $(Metadata)/nodes.json: $(NodesJSON) $(info ==> $@) - @[[ "$^" != "" ]] && jq --slurp '{ nodes: . }' $^ > $@ || true + @test -n "$^" && jq --slurp '{ nodes: . }' $^ > $@ || true # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/man.make b/docs/make.d/man.make deleted file mode 100644 index 4ccae46..0000000 --- a/docs/make.d/man.make +++ /dev/null @@ -1,46 +0,0 @@ -######################################################################## -# Man page for jqt -######################################################################## - -# gpp for the man page (to be build without calling jqt!) -GPP_MD := gpp \ - -U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \ - -M '<%' '>' '\B' '\B' '\W>' '<' '>' \ - +sccc '&\n' '' '' \ - +sccc '\\n' '' '' \ - +sccc '<\#' '\#>\n' '' \ - +siqi "'" "'" '\' \ - +siQi '"' '"' '\' \ - +ssss '<!--' '-->' '' \ - +ssss '`' '`' '' \ - +ssss '\n```' '\n```' '' \ - +ssss '\n~~~' '\n~~~' '' \ - -# -ManPage := ../jqt.1.gz - -# Man page: jqt(1) -$(ManPage): $(Content)/jqt.1.markdown - $(info ==> $@) - @$(GPP_MD) -I$(Content) < $< \ - | pandoc --standalone --from markdown --to man \ - | gzip > $@ - -# Add prerequisites and recipes to common targets -all:: $(ManPage) - -clean:: - @rm -f $(ManPage) - -clobber:: - @rm -f $(ManPage) - -# Generate Help text (needs explicit call: `make /tmp/help`) -/tmp/help: $(Content)/help.markdown - $(info ==> $@) - @jqt -P MarkDown -I$(Content) < $< \ - | pandoc --from markdown --to plain - \ - | sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \ - > $@ - -# 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 5bfa769..93c70bf 100644 --- a/docs/make.d/pathnames.make +++ b/docs/make.d/pathnames.make @@ -14,11 +14,12 @@ # Pages # PagesJSON # Exported targets: +# all # $(Destination) # all paths at $(Destination) and $(Metadata) # Additional dependencies defined: -# each HTML page from his metadata and directory -# each HTML node from his metadata and directory +# $(Destination)/.../page.html => $(Metadata)/pages/.../page.json +# $(Destination)/.../node/index.html => $(Metadata)/nodes/.../node.json ######################################################################## # Derived pathnames @@ -97,7 +98,7 @@ $(Nodes): | $$(dir $$@) $(PagesJSON): | $$(dir $$@) $(NodesJSON): | $$(dir $$@) -# Add prerequisites to main target +# Add prerequisites to default goal all:: $(Pages) ######################################################################### diff --git a/docs/make.d/prelude.make b/docs/make.d/prelude.make index be02c1e..1d5055f 100644 --- a/docs/make.d/prelude.make +++ b/docs/make.d/prelude.make @@ -9,6 +9,11 @@ # rest # filename +# Debug tool +ifdef MAKE_RESTARTS +$(info Makefile restarted: $(MAKE_RESTARTS)) +endif + ######################################################################## # Prerequisites ######################################################################## @@ -40,6 +45,13 @@ $(error Target "clobber" must be alone) endif endif +# Do not build to clobber immediately +ifeq (clobber,$(MAKECMDGOALS)) +ifeq (,$(wildcard $(Metadata))) +$(error Nothing to clobber) +endif +endif + ######################################################################## # Make configuration ######################################################################## diff --git a/docs/make.d/rules.make b/docs/make.d/rules.make index 75fa68f..bdfc5de 100644 --- a/docs/make.d/rules.make +++ b/docs/make.d/rules.make @@ -4,12 +4,50 @@ # Define rules for HTML pages and nodes. # # Imported variables: +# Assets # Destination # JQTFLAGS # Layouts # Metadata # Exported targets: # $(Metadata)/html.make +# all +# build +# clean +# clobber +# xbuild + +######################################################################## +# Standard rules +######################################################################## + +.PHONY: clean clobber build xbuild xxbuild + +# Copy Assets +all:: + @cp --verbose --recursive --update $(Assets)/* $(Destination) \ + | sed "s/^.*-> ./==> /;s/.$$//" + +# Delete generated publications +clean:: + @rm -rf $(Destination)/* + +# Delete all generated files and directories +clobber:: + @rm -rf $(Destination) $(Metadata) + +# Build again all documents +build: clean all + +# Clobber and build again +xbuild: + @test -e config.yaml && touch config.yaml || true; \ + test -e config.json && touch config.json || true + @$(MAKE) -s all + +# Clobber and build again +xxbuild: clobber + @$(MAKE) -s all ######################################################################## # Create makefile for targets rules diff --git a/docs/make.d/styles.make b/docs/make.d/styles.make new file mode 100644 index 0000000..0e46a37 --- /dev/null +++ b/docs/make.d/styles.make @@ -0,0 +1,31 @@ +######################################################################## +# styles.make +######################################################################## +# +# Generate main CSS stylesheet. +# +# Imported variables: +# Destination +# Blocks +# Styles +# Exported targets: +# $(Destination)/styles.css +# all + + +# Styles +$(Destination)/styles.css: \ + $(Blocks)/*/*style.css \ + $(Styles)/*.css \ + $(Styles)/*.m \ + $(Styles)/milligram/*.css \ + +# Generate main CSS stylesheet. +$(Destination)/styles.css: $(Styles)/main.css + $(info ==> $@) + @jqt -P CSS-min -I$(Styles) < $< > $@ + +# Add `$(Destination)/styles.css` to `all` target. +all:: $(Destination)/styles.css + +# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/tools.make b/docs/make.d/tools.make index 74849fe..5d743c1 100644 --- a/docs/make.d/tools.make +++ b/docs/make.d/tools.make @@ -1,11 +1,24 @@ ######################################################################## -# Show targets +# tools.make ######################################################################## - +# +# Tools independent of any target. +# +# Parameters: +# vnudir +# Imported variables: +# Destination # Exported targets: # help +# valid +# lint + +######################################################################## +# Show all targets +######################################################################## .PHONY: help + help: @echo 'Usage: make TARGET [parameter=value...]' @echo 'Targets:'; \ @@ -16,4 +29,26 @@ help: | sed 's/:\+$$//' \ | pr --omit-pagination --indent=4 --width=80 --columns=4 +######################################################################## +# HTML 5 validation +######################################################################## + +.PHONY: valid lint + +# Parameter, definable at runtime +vnudir ?= /usr/local/vnu + +# Validation tool +VNU := $(vnudir)/vnu.jar + +# Validation +valid: all + @xmlwf $(Destination)/*.html + @java -jar $(VNU) --errors-only --format gnu $(Destination)/*.html + +# Validation with warnings +lint: all + @xmlwf $(Destination)/*.html + @java -jar $(VNU) --format text $(Destination)/*.html + # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/vnu.make b/docs/make.d/vnu.make deleted file mode 100644 index 7f18126..0000000 --- a/docs/make.d/vnu.make +++ /dev/null @@ -1,31 +0,0 @@ -######################################################################## -# HTML 5 validation -######################################################################## - -# Parameters: -# vnudir -# Imported variables: -# Destination -# Exported targets: -# valid -# lint - -.PHONY: valid lint - -# Parameter, definable at runtime -vnudir ?= /usr/local/vnu - -# Validation tool -VNU := $(vnudir)/vnu.jar - -# Validation -valid: all - @xmlwf $(Destination)/*.html - @java -jar $(VNU) --errors-only --format gnu $(Destination)/*.html - -# Validation with warnings -lint: all - @xmlwf $(Destination)/*.html - @java -jar $(VNU) --format text $(Destination)/*.html - -# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/styles/page.css b/docs/styles/main.css similarity index 100% rename from docs/styles/page.css rename to docs/styles/main.css