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`.
This commit is contained in:
Frank LENORMAND 2016-02-03 21:09:41 +02:00
parent 79abe58599
commit 985b7a188a

View File

@ -20,6 +20,15 @@ endif
sources := $(wildcard *.cc) sources := $(wildcard *.cc)
objects := $(addprefix ., $(sources:.cc=$(suffix).o)) objects := $(addprefix ., $(sources:.cc=$(suffix).o))
deps := $(addprefix ., $(sources:.cc=$(suffix).d)) deps := $(addprefix ., $(sources:.cc=$(suffix).d))
docs := commands \
execeval \
expansions \
faces \
highlighters \
hooks \
options \
registers \
shortcuts \
PREFIX ?= /usr/local PREFIX ?= /usr/local
DESTDIR ?= # root dir DESTDIR ?= # root dir
@ -63,20 +72,33 @@ kak : $(objects)
.%$(suffix).o: %.cc .%$(suffix).o: %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< $(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: test:
cd ../test && ./run cd ../test && ./run
tags: tags:
ctags -R ctags -R
man: ../doc/kakoune.1.txt
a2x -f manpage $< man: ../doc/kakoune.1.gz
gzip -fk $(basename $<) 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: clean:
rm -f .*.o .*.d kak tags rm -f .*.o .*.d kak tags
XDG_CONFIG_HOME ?= $(HOME)/.config XDG_CONFIG_HOME ?= $(HOME)/.config
install: kak man install: kak man doc
mkdir -p $(bindir) mkdir -p $(bindir)
install -m 0755 kak $(bindir) install -m 0755 kak $(bindir)
mkdir -p $(sharedir)/rc mkdir -p $(sharedir)/rc