Skip to content

Commit

Permalink
Big makefile reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 2, 2017
1 parent 0e58fa9 commit 68d40fd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 68 deletions.
2 changes: 1 addition & 1 deletion bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ function usage
function help
{
cat <<'EOF'
jqt - jq based web template engine [version 0.1.0]
jqt - jq based web template engine [version 0.5.0]
Usage: jqt [-h | --help | -p | -V | --version]
jqt [options] < infile > result
jqt [options] infile > result
Expand Down
1 change: 1 addition & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if [[ -f VERSION ]]; then
rm /tmp/$$-changes
git add CHANGES VERSION
sed -i "s/^declare -r VERSION=/&'$NEXT_VERSION'/" bin/jqt
sed -i "s/\[version .*\]/[version $(NEXT_VERSION)]/" bin/jqt
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
133 changes: 76 additions & 57 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,35 @@ SHELL := /bin/bash
########################################################################

# Output directories
Metadata := .yummy
Destination := /tmp/jqt
Metadata := .yummy

# Input files directories
Assets := ./assets
Blocks := ./blocks
Layouts := ./blocks
Content := ./content
Data := ./data
Layouts := ./blocks
Styles := ./styles

# Common dependencies for all targets
Common := \
$(Metadata)/config.json \
$(Metadata)/snippets.json \
$(Blocks)/*/markup.html \
$(Layouts)/page.html \
$(Blocks)/filters.jq \
$(Content)/LINKS.txt \
$(Content)/macros.m \
# Files to build or publish
Home := index
Other := content data engine structure
Static := README.md styles.css

# Files to "build"
Home := index
Pages := content data engine structure
Files := README.md styles.css
# Target filenames
ManPage := ../jqt.1.gz
Targets := \
$(foreach f,$(Files),$(Destination)/$(f)) \
$(foreach p,$(Home) $(Pages),$(Destination)/$(p).html) \
$(ManPage) \
HomePage := $(Destination)/$(Home).html
OtherPages := $(foreach p,$(Other),$(Destination)/$(p).html)
Files := $(foreach f,$(Static),$(Destination)/$(f))
Pages := $(HomePage) $(OtherPages)
Targets := $(Pages) $(Files) $(ManPage)

########################################################################
# jqt command with options
########################################################################

# The template engine (.site and .snippets are defined in the jqt call)

# jqt with options
JQTFLAGS := \
-5 \
-I./ \
Expand All @@ -97,15 +89,67 @@ JQTFLAGS := \

JQT = jqt $(JQTFLAGS)

# gpp for the man page (to be build without calling jqt!)
GPP_MD_FLAGS := \
-U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \
-M '<%' '>' '\B' '\B' '\W>' '<' '>' \
+sccc '&\n' '' '' \
+sccc '\\n' '' '' \
+sccc '<\#' '\#>\n' '' \
+siqi "'" "'" '\' \
+siQi '"' '"' '\' \
+ssss '<!--' '-->' '' \
+ssss '`' '`' '' \
+ssss '\n```' '\n```' '' \
+ssss '\n~~~' '\n~~~' '' \
GPP_MD = gpp $(GPP_MD_FLAGS)

# hack to modify <detail> markup
DETAILS := sed \
-e 's/^<p><details><\/p>/<details>/' \
-e 's/^<p><\/details><\/p>/<\/details>/'\
-e 's/^<p><summary>/<summary>/' \
-e 's/<\/summary><\/p>/<\/summary>/'

########################################################################
# Extra dependencies
########################################################################

$(Pages): \
$(Blocks)/*/markup.html \
$(Blocks)/filters.jq \
$(Content)/LINKS.txt \
$(Content)/macros.m \
$(Metadata)/config.json \
$(Metadata)/snippets.json \


$(OtherPages): \
$(Content)/FLOW.txt \
$(Layouts)/page.html \
$(Content)/opt/*.txt \

$(HomePage) \
$(Destination)/structure.html: \
$(Content)/EXAMPLE.txt \

$(Destination)/styles.css: \
$(Blocks)/*/*style.css \
$(Styles)/*.css \
$(Styles)/*.m \
$(Styles)/milligram/*.css \

########################################################################
# Rules
########################################################################

# Main
all: $(Targets)

# Directories
$(Metadata) $(Destination): ; mkdir $@ >/dev/null 2>&1 || true
$(Metadata) \
$(Destination):
mkdir $@ >/dev/null 2>&1 || true

# Metadata files
$(Metadata)/config.json: config.yaml \
Expand All @@ -116,57 +160,32 @@ $(Metadata)/snippets.json: $(Content)/snippets.yaml \
| $(Metadata)
jqt -T <$< | yaml2json > $@

# Documentation site to build
# Assets
$(Destination)/README.md: $(Assets)/README.md \
| $(Destination)
$(info ==> $@)
cp $< $@

DETAILS := sed \
-e 's/^<p><details><\/p>/<details>/' \
-e 's/^<p><\/details><\/p>/<\/details>/'\
-e 's/^<p><summary>/<summary>/' \
-e 's/<\/summary><\/p>/<\/summary>/'

$(Destination)/index.html: $(Content)/home.md $(Common) \
| $(Destination)
$(info ==> $@)
$(JQT) -d $< $(Layouts)/page.html > $@

$(foreach p,$(Pages),$(Destination)/$(p).html): $(Content)/FLOW.txt $(Content)/opt/*.txt
$(Destination)/index.html $(Destination)/structure.html: $(Content)/EXAMPLE.txt

# HTML pages
define Target
$(Destination)/$(1).html: $(Content)/$(1).md $(Layouts)/$(2).html $(Common) \
$(Destination)/$(1).html: $(Content)/$(1).md $(Layouts)/$(2).html \
| $(Destination)
$$(info ==> $$@)
$(JQT) -d $$< $(Layouts)/$(2).html | $(DETAILS) > $$@
endef

$(foreach p,$(Pages),$(eval $(call Target,$(p),page-toc)))
$(eval $(call Target,$(Home),page))
$(foreach p,$(Other),$(eval $(call Target,$(p),page-toc)))

TOPCSS=$(Styles)/page.css
$(Destination)/styles.css: $(TOPCSS) $(Styles)/*.css $(Styles)/milligram/*.css $(Blocks)/*/*style.css $(Styles)/bem.m
# CSS stylesheet
$(Destination)/styles.css: $(Styles)/page.css
$(info ==> $@)
jqt -P CSS-min -I$(Styles) <$< >$@

# Man page (to be build without calling jqt!)
GPP_MD := \
-U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \
-M '<%' '>' '\B' '\B' '\W>' '<' '>' \
+sccc '&\n' '' '' \
+sccc '\\n' '' '' \
+sccc '<\#' '\#>\n' '' \
+siqi "'" "'" '\' \
+siQi '"' '"' '\' \
+ssss '<!--' '-->' '' \
+ssss '`' '`' '' \
+ssss '\n```' '\n```' '' \
+ssss '\n~~~' '\n~~~' '' \
# Man page: jqt(1)
$(ManPage): $(Content)/jqt.1.markdown
$(info ==> $@)
gpp $(GPP_MD) -I$(Content) <$< \
$(GPP_MD) -I$(Content) <$< \
| pandoc --standalone --from markdown --to man \
| gzip > $@

Expand Down
16 changes: 7 additions & 9 deletions docs/blocks/content/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@
font-size: 1.4rem;
}

@media print {
&SEL{$content} figure > pre {
font-size: 1.2rem;
}
}

// Page specific

html#content-home &SEL{$content} > blockquote:first-of-type {
&SEL{$content} &SEL{page-quote} {
float: right;
margin: 0 0 0 auto;
padding-top: 0;
Expand All @@ -81,4 +73,10 @@ html#content-home &SEL{$content} > blockquote:first-of-type {
text-align: right;
}

@media print {
&SEL{$content} figure > pre {
font-size: 1.2rem;
}
}

// vim:ts=2:sw=2:ai:et:fileencoding=utf-8:syntax=css
2 changes: 1 addition & 1 deletion docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ author:

menu:
- URL: ./index.html
path: content/home.md
path: content/index.md
name: Home
- URL: ./engine.html
path: content/engine.md
Expand Down
3 changes: 3 additions & 0 deletions docs/content/home.md → docs/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ updated: "2016-08-28T10:27:09Z"

# Welcome

<!--
> _Editing is a rewording activity._\
> — _Alan J. Perlis_
-->
<blockquote class="page-quote"><p><em>Editing is a rewording activity.</em><br/>— <em>Alan J. Perlis</em></p></blockquote>

Could be [_jq_][JQ] the basis for a web template engine?
Let’s explore&hellip;
Expand Down

0 comments on commit 68d40fd

Please sign in to comment.