Skip to content

Commit

Permalink
Created jqt.make
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 17, 2017
1 parent 211de32 commit 0b8feaa
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 262 deletions.
1 change: 1 addition & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if [[ -f VERSION ]]; then
git add CHANGES VERSION
sed -i "s/^declare -r VERSION=/&'$NEXT_VERSION'/" bin/jqt
sed -i "s/\[version .*\]/[version $(NEXT_VERSION)]/" bin/jqt
sed -i "s/^Version *:=.*/Version := $(NEXT_VERSION)/" docs/Makefile
git commit -am "Version bump to $NEXT_VERSION"
git tag -a -m "Tagging version $NEXT_VERSION" "v$NEXT_VERSION"
[[ $PUSH == yes ]] && git push origin --tags
Expand Down
140 changes: 45 additions & 95 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
include make.d/prelude.make

# jqt version
Version := $(shell cat ../VERSION)
Version := 0.5.0

# Metadata directory
Metadata := .meta
Expand All @@ -24,11 +24,9 @@ endif

# ======================================================================
-include $(Metadata)/phase1.make
include make.d/config.make
#
# Load site global parameters. If `phase1.make` not exists it is built when
# restarting with a rule defined in `config.make`.
#
# Exported variables:
# Variables defined in phase1.make:
# __phase_1
# Assets
# Blocks
Expand All @@ -37,10 +35,13 @@ endif
# Destination
# Layouts
# Styles
# Defined rules for:
# $(Metadata)
# $(Metadata)/config.json
# $(Metadata)/phase1.make
# $(Metadata)/site.json
# ======================================================================

include make.d/config.make

# Warning:
#
# If `__phase_1` is not defined because `phase1.make` does not exists, after
Expand All @@ -53,123 +54,72 @@ ifdef __phase_1

# ======================================================================
-include $(Metadata)/phase2.make
include make.d/pathnames.make
#
# Load variables for several pathnames.
#
# Exported variables:
# Variables defined in phase2.make:
# __phase_2
# DestinationPages
# DestinationPaths
# MetadataPages
# MetadataPaths
# Exported rules for:
# $(Metadata)/pages/.../page.json
# Defined rules for:
# $(Metadata)/phase2.make
# $(DestinationPaths)
# $(MetadataPaths)
# $(MetadataPages)
# $(Metadata)/pages.json
# $(Metadata)/sections.json
# ======================================================================

include make.d/pathnames.make

ifdef __phase_2

include make.d/front-matter.make

# ======================================================================
-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`.
#
# Exported variables:
# Variables defined in phase3.make:
# __phase_3
# Exported rules for:
# dependencies and rules for all HTML files
# Defined rules for:
# $(Metadata)/phase3.make
# $(DestinationPages)
# Defined targets:
# all
# build
# clean
# clobber
# fresh
# init
# touch
# ======================================================================

include make.d/pages.make

ifdef __phase_3

# ======================================================================
include make.d/sitemap.make
include make.d/styles.make
include make.d/tools.make

########################################################################
# Specific rules for this web site
########################################################################

# Call jqt with user defined flags
JQT = jqt $(JQTFLAGS)

# Options for `jqt`.
JQTFLAGS += \
-5 \
-I./ \
-j'$$'pages:$(Metadata)/pages \
-msite:$(Metadata)/config.json \
-msections:$(Metadata)/sections.json \
-iblocks/filters \
--toc-depth=4 \
-msnippets:$(Metadata)/snippets.json \

# Snippets
$(Metadata)/snippets.json: $(Data)/snippets.yaml \
| $(Metadata)
$(info ==> $@)
@jqt -T < $< | yaml2json > $@

# Extra dependencies
$(DestinationPages): $(Metadata)/snippets.json $(Blocks)/filters.jq $(Blocks)/*/*.html $(Blocks)/*/*/*.html

#
# Generate man page for jqt
# Several complementary files.
#

# 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.text
$(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)
# Defined rules for:
# $(Destination)/sitemap.xml
# $(Destination)/sitemap.xml.gz
# $(Destination)/styles.css
# Defined targets:
# help
# lint
# valid
# ======================================================================

########################################################################
# Generate Help text
# Independent target: helps generating text for `jqt -h`
# Needs explicit call: `make /tmp/help`
include jqt.make
#
/tmp/help: $(Content)/help.text
$(info ==> $@)
@jqt -P MarkDown -I$(Content) < $< \
| pandoc --from markdown --to plain - \
| sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \
> $@

clean::
@rm -f /tmp/help
# Project specific makefile. All the previous modules are expected to be
# independent, valid for any project without any change.
########################################################################

endif # __phase_3
endif # __phase_2
Expand Down
81 changes: 81 additions & 0 deletions docs/jqt.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
########################################################################
# Specific makefile for this web site
########################################################################

# Options for `jqt`.
JQTFLAGS += \
-5 \
--toc-depth=4 \
-I./ \
-msite:$(Metadata)/config.json \
-msections:$(Metadata)/sections.json \
-msnippets:$(Metadata)/snippets.json \
-iblocks/filters \
-j'$$'pages:$(Metadata)/pages \

# Snippets
$(Metadata)/snippets.json: $(Data)/snippets.yaml \
| $(Metadata)
$(info ==> $@)
@jqt -T < $< | yaml2json > $@

clean::
@rm -f $(Metadata)/snippets.json

# Extra dependencies
$(DestinationPages): $(Metadata)/snippets.json # $(Blocks)/filters.jq $(Blocks)/*/*.html $(Blocks)/*/*/*.html

########################################################################
# Generate 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.text
$(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
########################################################################

# Independent target: helps generating text for `jqt -h`
# Needs explicit call: `make /tmp/help`
/tmp/help: $(Content)/help.text
$(info ==> $@)
@jqt -P MarkDown -I$(Content) < $< \
| pandoc --from markdown --to plain - \
| sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \
> $@

clean::
@rm -f /tmp/help

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
30 changes: 17 additions & 13 deletions docs/make.d/config.make
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,38 @@
# config.make
#
# Build files derived from user defined configuration:
# config.{yaml,json} => config.json => site.json => phase_1.make
# config.{yaml,json} => config.json => site.json => phase1.make
#
# Imported variables:
# Metadata
# Version
# Exported rules for:
# Variables defined in phase1.make:
# __phase_1
# Assets
# Blocks
# Content
# Data
# Destination
# Layouts
# Styles
# Defined rules for:
# $(Metadata)
# $(Metadata)/
# $(Metadata)/config.json
# $(Metadata)/phase1.make
# $(Metadata)/site.json
# $(Metadata)/phase_1.make

########################################################################
# Metadata directory for all generated metadata and make files
# Metadata directory for all generated make and metadata files
########################################################################

$(Metadata):
$(info ==> $@)
@mkdir --parents $@ >/dev/null 2>&1 || true

########################################################################
# Rules for configuration files
# Files derived from user defined configuration file
########################################################################

#
# Create `$(Metadata)/config.json`.
# Create `$(Metadata)/config.json` from `config.yaml` or `config.json`.
#

# Input is user defined `config.yaml` or `config.json`.
ifeq (config.yaml,$(wildcard config.yaml))

# Convert `config.yaml` to `$(Metadata)/config.json`.
Expand All @@ -54,11 +57,12 @@ endif
#
# Create `$(Metadata)/site.json` from `$(Metadata)/config.json`.
#
$(Metadata)/site.json: $(Metadata)/config.json make.d/config.make
$(Metadata)/site.json: $(Metadata)/config.json make.d/config.make make.d/phase0.jq
$(info ==> $@)
@jq --sort-keys \
--from-file make.d/phase0.jq \
--arg Version $(Version) \
--arg Metadata $(Metadata) \
< $< > $@

#
Expand Down
Loading

0 comments on commit 0b8feaa

Please sign in to comment.