Skip to content

Commit 652544f

Browse files
committed
btrfs-progs: build: add support for asciidoctor doc generator
We've been using asciidoc that's written in python2, which is going to be phased out and deprecated next year. There's a replacement, asciidoctor. Add a configure-time detection which tool is available, update Documentation/Makefile.in. The original asciidoc tool is still preferred as it produces slightly better output. The file asciidoc.conf does not have a direct equivalten in asciidoct and would need to be replaced by extension written in ruby. The differences: - the <literal> are not automatically underlined and are less visible in the generated manual page, but it's still acceptable - the inline CSS for the html output looks subjectively worse, is less compact and colourful Issue: kdave#89 Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 4523dc2 commit 652544f

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

Documentation/Makefile.in

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,21 @@ man3dir = $(mandir)/man3
4646
man5dir = $(mandir)/man5
4747
man8dir = $(mandir)/man8
4848

49+
ifeq (@ASCIIDOC_TOOL@,asciidoc)
4950
ASCIIDOC = @ASCIIDOC@
50-
ASCIIDOC_EXTRA =
51+
ASCIIDOC_ARGS = -abtrfs_version=$(BTRFS_VERSION) -f asciidoc.conf
52+
ASCIIDOC_HTML = html
53+
ASCIIDOC_DOCBOOK = docbook
54+
ASCIIDOC_DEPS = asciidoc.conf
55+
endif
56+
ifeq (@ASCIIDOC_TOOL@,asciidoctor)
57+
ASCIIDOC = @ASCIIDOCTOR@
58+
ASCIIDOC_ARGS = -abtrfs_version=$(BTRFS_VERSION)
59+
ASCIIDOC_HTML = xhtml5
60+
ASCIIDOC_DOCBOOK = docbook45
61+
ASCIIDOC_DEPS =
62+
endif
63+
5164
MANPAGE_XSL = manpage-normal.xsl
5265
XMLTO = @XMLTO@
5366
XMLTO_EXTRA =
@@ -121,16 +134,12 @@ clean:
121134
$(QUIET_XMLTO)$(RM) -f $@ && \
122135
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
123136

124-
%.xml : %.asciidoc asciidoc.conf
137+
%.xml : %.asciidoc $(ASCIIDOC_DEPS)
125138
$(QUIET_ASCIIDOC)$(RM) -f $@+ $@ && \
126-
$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
127-
$(ASCIIDOC_EXTRA) -abtrfs_version=$(BTRFS_VERSION) \
128-
-o $@+ $< && \
139+
$(ASCIIDOC) $(ASCIIDOC_ARGS) -b $(ASCIIDOC_DOCBOOK) -d manpage -o $@+ $< && \
129140
$(MV) $@+ $@
130141

131-
%.html : %.asciidoc asciidoc.conf
142+
%.html : %.asciidoc $(ASCIIDOC_DEPS)
132143
$(QUIET_ASCIIDOC)$(RM) -f $@+ $@ && \
133-
$(ASCIIDOC) -b html -d article -f asciidoc.conf \
134-
$(ASCIIDOC_EXTRA) -abtrfs_version=$(BTRFS_VERSION) \
135-
-o $@+ $< && \
144+
$(ASCIIDOC) $(ASCIIDOC_ARGS) -b $(ASCIIDOC_HTML) -d article -o $@+ $< && \
136145
$(MV) $@+ $@

configure.ac

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ AC_CHECK_TOOL([AR], [ar])
3939
AC_PATH_PROG([RM], [rm], [rm])
4040
AC_PATH_PROG([RMDIR], [rmdir], [rmdir])
4141

42+
4243
AC_CHECK_FUNCS([openat], [],
4344
[AC_MSG_ERROR([cannot find openat() function])])
4445

@@ -88,13 +89,27 @@ AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABL
8889
AC_SUBST([DISABLE_DOCUMENTATION])
8990

9091
dnl detect tools to build documentation
92+
ASCIIDOC_TOOL="none"
9193
if test "x$enable_documentation" = xyes; then
92-
AC_PATH_PROG([ASCIIDOC], [asciidoc], [asciidoc])
9394
AC_PATH_PROG([XMLTO], [xmlto], [xmlto])
9495
AC_PATH_PROG([GZIP], [gzip], [gzip])
9596
AC_PATH_PROG([MV], [mv], [mv])
9697
AC_PROG_SED
98+
AC_PATH_PROG([ASCIIDOC], [asciidoc])
99+
AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
100+
101+
dnl asciidoc is preferred
102+
if test -n "$ASCIIDOC"; then
103+
ASCIIDOC_TOOL="asciidoc"
104+
else
105+
if test -n "$ASCIIDOCTOR"; then
106+
ASCIIDOC_TOOL="asciidoctor"
107+
else
108+
AC_MSG_ERROR([cannot find asciidoc or asciidoctor, cannot build documentation])
109+
fi
110+
fi
97111
fi
112+
AC_SUBST([ASCIIDOC_TOOL])
98113

99114
AC_ARG_ENABLE([convert],
100115
AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
@@ -246,6 +261,7 @@ AC_MSG_RESULT([
246261
ldflags: ${LDFLAGS}
247262
248263
documentation: ${enable_documentation}
264+
doc generator: ${ASCIIDOC_TOOL}
249265
backtrace support: ${enable_backtrace}
250266
btrfs-convert: ${enable_convert} ${convertfs:+($convertfs)}
251267
btrfs-restore zstd: ${enable_zstd}

0 commit comments

Comments
 (0)