Skip to content

Commit 985b7a1

Browse files
committed
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`.
1 parent 79abe58 commit 985b7a1

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/Makefile

+26-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ endif
2020
sources := $(wildcard *.cc)
2121
objects := $(addprefix ., $(sources:.cc=$(suffix).o))
2222
deps := $(addprefix ., $(sources:.cc=$(suffix).d))
23+
docs := commands \
24+
execeval \
25+
expansions \
26+
faces \
27+
highlighters \
28+
hooks \
29+
options \
30+
registers \
31+
shortcuts \
2332

2433
PREFIX ?= /usr/local
2534
DESTDIR ?= # root dir
@@ -63,20 +72,33 @@ kak : $(objects)
6372
.%$(suffix).o: %.cc
6473
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
6574

75+
%.1: %
76+
a2x -f manpage $<
77+
%.1.gz: %.1.txt
78+
a2x -f manpage $<
79+
gzip -f $(basename $<)
80+
6681
test:
6782
cd ../test && ./run
6883
tags:
6984
ctags -R
70-
man: ../doc/kakoune.1.txt
71-
a2x -f manpage $<
72-
gzip -fk $(basename $<)
85+
86+
man: ../doc/kakoune.1.gz
87+
doc: $(addsuffix .1,$(addprefix ../doc/manpages/,$(docs)))
88+
@for f in $^; do \
89+
pagename="$${f##*/}"; pagename="$${pagename%.*}"; \
90+
sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$${pagename^^}\"," \
91+
-e "/^\.SH \"NAME\"/,+1d" $$f; \
92+
gzip -f "$$f"; \
93+
mv "$${f}.gz" "$${f/.1/}.gz"; \
94+
done
7395

7496
clean:
7597
rm -f .*.o .*.d kak tags
7698

7799
XDG_CONFIG_HOME ?= $(HOME)/.config
78100

79-
install: kak man
101+
install: kak man doc
80102
mkdir -p $(bindir)
81103
install -m 0755 kak $(bindir)
82104
mkdir -p $(sharedir)/rc

0 commit comments

Comments
 (0)