From 411089b2ae781f3118e35c4e8ccae017c2e655c8 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 27 Apr 2014 14:24:55 +0200 Subject: [PATCH] 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 --- Makefile | 3 +-- doc/.gitignore | 1 + doc/Makefile | 41 +++++++++++++++++++++++++++++++---------- doc/conf.py | 9 --------- doc/config.mk | 11 ++++++----- doc/man/conf.py | 23 +++++++++++++++++++++++ 6 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 doc/.gitignore create mode 100644 doc/man/conf.py diff --git a/Makefile b/Makefile index 4034982..e946758 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..e35d885 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +_build diff --git a/doc/Makefile b/doc/Makefile index ea26b37..d9c33ea 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -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 diff --git a/doc/conf.py b/doc/conf.py index 6615277..c0fb098 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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" } diff --git a/doc/config.mk b/doc/config.mk index 553c28c..60e395b 100644 --- a/doc/config.mk +++ b/doc/config.mk @@ -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 diff --git a/doc/man/conf.py b/doc/man/conf.py new file mode 100644 index 0000000..74edb0a --- /dev/null +++ b/doc/man/conf.py @@ -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) +]