From 985b7a188ad3a9b325eb50f4bee437c9263845f7 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 3 Feb 2016 21:09:41 +0200 Subject: [PATCH] Generate the documentation pages in the troff format This commit introduces the `doc` target in the Makefile, which generates man pages from the `asciidoc`-formatted documentation in the `doc/manpages` directory. Before being installed into the `$(sharedir)/doc` directory, the generated raw man pages have to be striped of a few sections without which `a2x` won't convert the `asciidoc` data: the shady block of shell script in the `doc` target does just that, along with compressing the resulting man page. New dependency hereby introduced: `asciidoc`. --- src/Makefile | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index 11b1fd36..c0de3aa7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,6 +20,15 @@ endif sources := $(wildcard *.cc) objects := $(addprefix ., $(sources:.cc=$(suffix).o)) deps := $(addprefix ., $(sources:.cc=$(suffix).d)) +docs := commands \ + execeval \ + expansions \ + faces \ + highlighters \ + hooks \ + options \ + registers \ + shortcuts \ PREFIX ?= /usr/local DESTDIR ?= # root dir @@ -63,20 +72,33 @@ kak : $(objects) .%$(suffix).o: %.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< +%.1: % + a2x -f manpage $< +%.1.gz: %.1.txt + a2x -f manpage $< + gzip -f $(basename $<) + test: cd ../test && ./run tags: ctags -R -man: ../doc/kakoune.1.txt - a2x -f manpage $< - gzip -fk $(basename $<) + +man: ../doc/kakoune.1.gz +doc: $(addsuffix .1,$(addprefix ../doc/manpages/,$(docs))) + @for f in $^; do \ + pagename="$${f##*/}"; pagename="$${pagename%.*}"; \ + sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \ + -e "/^\.SH \"NAME\"/,+1d" $$f; \ + gzip -f "$$f"; \ + mv "$${f}.gz" "$${f/.1/}.gz"; \ + done clean: rm -f .*.o .*.d kak tags XDG_CONFIG_HOME ?= $(HOME)/.config -install: kak man +install: kak man doc mkdir -p $(bindir) install -m 0755 kak $(bindir) mkdir -p $(sharedir)/rc