btrfs-progs: docs: integrate sphinx build

Make it possible to select sphinx doc generator instead of asciidoc so
we don't have two makefiles for that. It's still a bit crude and does
not support installing the files.

The required package is python-Sphinx (or similar name), built by
'sphinx-build'.

Configure:

  $ ASCIIDOC_TOOL=sphinx ./configure
  ...
            doc generator:      sphinx
  ...

Generate:

  $ cd Documentation/
  $ make man
  $ make html
  $ make info           # yes we can have info pages too

There are several more targets provided by sphinx, run 'make' to list
them.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-11-11 16:45:40 +01:00
parent a079982a9e
commit 4a50f64614
3 changed files with 37 additions and 20 deletions

View File

@ -1,3 +1,29 @@
ifeq (@ASCIIDOC_TOOL@,sphinx)
$(info "sphinx build, rst")
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile Makefile.in
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile Makefile.in
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
else
# Guard against environment variables
MAN8_TXT =
@ -130,3 +156,5 @@ clean:
$(QUIET_ASCIIDOC)$(RM) -f $@+ $@ && \
$(ASCIIDOC) $(ASCIIDOC_ARGS) -b $(ASCIIDOC_HTML) -d article -o $@+ $< && \
$(MV) $@+ $@
endif

View File

@ -1,20 +0,0 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile.sphinx
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile.sphinx
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -108,6 +108,14 @@ AC_ARG_ENABLE([documentation],
AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
AC_SUBST([DISABLE_DOCUMENTATION])
dnl Workaround to allow to select sphinx and build the RST documentation until
dnl it's default and without introducing temporary --with option
dnl Use as: $ ASCIIDOC_TOOL ./configure
if test "x$ASCIIDOC_TOOL" = "xsphinx"; then
ASCIIDOC_TOOL='sphinx'
AC_PATH_PROG([SPHINX], [sphinx-build])
else
dnl detect tools to build documentation
ASCIIDOC_TOOL="none"
if test "x$enable_documentation" = xyes; then
@ -132,6 +140,7 @@ if test "x$enable_documentation" = xyes; then
fi
fi
fi
fi
AC_SUBST([ASCIIDOC_TOOL])
AC_ARG_ENABLE([programs],