Test if breathe and sphinx_rtd_theme are available before building html

documentation

Also build man pages only if sphinx is available. Make it nops otherwise.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-04-27 14:24:55 +02:00
parent df725b3c1a
commit 411089b2ae
6 changed files with 62 additions and 26 deletions

View file

@ -40,8 +40,7 @@ endif
OBJECTS = $(patsubst %.c, %.o, $(SOURCE)) dbus-interface-definitions.o css-definitions.o
DOBJECTS = $(patsubst %.o, %.do, $(OBJECTS))
all: options ${PROJECT} po
# build-manpages
all: options ${PROJECT} po build-manpages
# pkg-config based version checks
.version-checks/%: config.mk

1
doc/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
_build

View file

@ -5,29 +5,50 @@ include ../common.mk
include ../colors.mk
include config.mk
MAN_SOURCES=$(wildcard man/*.txt) $(wildcard man/*.txt) man/conf.py
DOXYGEN_SOURCES=$(wildcard ../*.h) Doxyfile
HTML_SORUCES=$(wildcard *.rst api/*.rst configuration/*.rst installation/*.rst usage/*.rst) conf.py
SPHINX_OPTS+=-d $(SPHINX_BUILDDIR)/doctrees
ifeq ($(shell which $(SPHINX_BIN) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINX_BIN)' command was not found.)
endif
all: html man
init:
$(QUIET)mkdir -p $(SPHINX_BUILDDIR)/
all: man html
clean:
$(call colorecho,RM,doc/$(SPHINX_BUILDDIR))
$(QUIET)rm -rf $(SPHINX_BUILDDIR)/
html: doxygen
$(SPHINX_BUILDDIR)/html/index.html: $(HTML_SOURCES) $(SPHINX_BUILDDIR)/doxygen/xml/index.xml
$(call colorecho,DOC,"Build HTML documentation")
$(QUIET)$(SPHINX_BIN) -b html $(SPHINX_OPTS) $(SPHINX_BUILDDIR)/html
$(QUIET)$(SPHINX_BIN) -b html $(SPHINX_OPTS) . $(SPHINX_BUILDDIR)/html
man: doxygen
$(SPHINX_BUILDDIR)/zathura.1 $(SPHINX_BUILDDIR)/zathurarc.5: $(MAN_SOURCES)
$(call colorecho,DOC,"Build man pages")
$(QUIET)$(SPHINX_BIN) -b man $(SPHINX_OPTS) $(SPHINX_BUILDDIR)/man
$(QUIET)$(SPHINX_BIN) -b man $(SPHINX_OPTS) man $(SPHINX_BUILDDIR)
doxygen: init
$(SPHINX_BUILDDIR)/doxygen/xml/index.xml: $(DOXYGEN_SOURCES)
$(QUIET)mkdir -p $(SPHINX_BUILDDIR)
$(call colorecho,DOC,"Run doxygen")
$(QUIET)$(DOXYGEN_BIN) Doxyfile
.PHONY: clean html man
ifeq ($(shell which $(SPHINX_BIN) >/dev/null 2>&1; echo $$?), 1)
man:
html:
else
man: $(SPHINX_BUILDDIR)/zathura.1 $(SPHINX_BUILDDIR)/zathurarc.5
ifeq ($(shell which $(DOXYGEN_BIN) >/dev/null 2>&1; echo $$?), 0)
ifeq ($(shell $(PYTHON_BIN) -c "import breathe; import sphinx_rtd_theme" >/dev/null 2>&1; echo $$?), 0)
html: $(SPHINX_BUILDDIR)/html/index.html
else
html:
endif
else
html:
endif
endif
.PHONY: clean html man all

View file

@ -34,15 +34,6 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_static_path = ['_static']
htmlhelp_basename = 'zathuradoc'
# -- Options for manual page output ---------------------------------------
man_pages = [
('man/zathura.1', 'zathura', 'a document viewer', ['pwmt.org'], 1),
('man/zathurarc.5', 'zathurarc', 'a document viewer', ['pwmt.org'], 5)
]
# -- Options for breathe ---------------------------------------
breathe_projects = { "zathura": "_build/doxygen/xml" }

View file

@ -1,7 +1,8 @@
# See LICENSE file for license and copyright information
SPHINX_BIN = sphinx-build
SPHINX_BUILDDIR = _build
SPHINX_OPTS = -d $(SPHINX_BUILDDIR)/doctrees .
DOXYGEN_BIN = doxygen
SPHINX_BIN ?= sphinx-build
SPHINX_BUILDDIR = _build
SPHINX_OPTS ?=
DOXYGEN_BIN ?= doxygen
# This needs to be the same python interpreter as used by sphinx-build
PYTHON_BIN ?= python

23
doc/man/conf.py Normal file
View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
# See LICENSE file for license and copyright information
# -- General configuration ------------------------------------------------
source_suffix = '.rst'
master_doc = 'zathura.1'
templates_path = ['_templates']
# -- Project configuration ------------------------------------------------
project = 'zathura'
copyright = '2014, pwmt.org'
version = '0.2.7'
release = '0.2.7'
# -- Options for manual page output ---------------------------------------
man_pages = [
('zathura.1', 'zathura', 'a document viewer', ['pwmt.org'], 1),
('zathurarc.5', 'zathurarc', 'a document viewer', ['pwmt.org'], 5)
]