aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-07-05 01:03:36 +0200
committerGuilhem Moulin <guilhem@fripost.org>2019-07-05 03:32:01 +0200
commit25f1dbdf54947bd6bbce653bc64f6c45b2473792 (patch)
treeeb5a21d1a528502845da6b987d4431bd04a4a5bd /Makefile
parentc4abd6128c3ca5471afc84225533a958ce273875 (diff)
Refactor documentation.
In particular, move manpages to the 'doc' directory, and generate HTML documentation with `make html`.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile34
1 files changed, 27 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index b0e4d59..fda0fe0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,11 @@
-all: pullimap.1 interimap.1
+all: manual
+
+MANUALS = $(patsubst %.md,%,$(wildcard ./doc/*.[1-9].md))
+manual: $(MANUALS)
# upper case the headers and remove the links
-%.1: %.md
- @pandoc -f markdown -t json "$<" | \
+$(MANUALS): %: %.md
+ @pandoc -f markdown -t json -- "$<" | \
jq " \
def fixheaders: \
if .t == \"Header\" then \
@@ -29,12 +32,29 @@ all: pullimap.1 interimap.1
}" | \
pandoc -s -f json -t man+smart -o "$@"
-install:
-
test:
@for t in tests/*; do if [ -f "$$t/run" ]; then ./tests/run "$$t" || exit 1; fi; done
+HTML_ROOTDIR ?= ./doc
+CSS ?= /usr/share/javascript/bootstrap/css/bootstrap.min.css
+HTML_TEMPLATE ?= ./doc/template.html
+
+HTML_FILES = $(addprefix $(HTML_ROOTDIR)/,$(patsubst ./doc/%.md,%.html,$(wildcard ./doc/*.md)))
+html: $(HTML_FILES)
+
+## CSS="https://guilhem.org/static/css/bootstrap.min.css" HTML_ROOTDIR="$XDG_RUNTIME_DIR/Downloads" make html
+$(HTML_ROOTDIR)/%.html: ./doc/%.md $(HTML_TEMPLATE)
+ mtime="$$(git --no-pager log -1 --pretty="format:%ct" -- "$<" 2>/dev/null)"; \
+ [ -n "$$mtime" ] || mtime="$$(date +%s -r "$<")"; \
+ pandoc -sp -f markdown -t html+smart --css=$(CSS) --template=$(HTML_TEMPLATE) \
+ --variable=date:"$$(LC_TIME=C date +"Last modified on %a, %d %b %Y at %T %z" -d @"$$mtime")" \
+ --output="$@" -- "$<"
+
+doc: manual html
+
+install:
+
clean:
- rm -f pullimap.1 interimap.1
+ rm -f $(MANUALS) $(HTML_FILES)
-.PHONY: all install clean test
+.PHONY: all manual html doc test install clean