From 961e431408844e94c2b1187b56375346199e2763 Mon Sep 17 00:00:00 2001 From: Sayed Adel Date: Tue, 31 Aug 2021 16:41:07 +0200 Subject: [PATCH] DOC: skip generating c/c++ doc from comment blocks when Doxygen or Breathe isn't available. --- doc/Makefile | 4 ++++ doc/source/conf.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index 760e16038dd..16fc3229d4c 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -178,7 +178,11 @@ html: version-check html-build html-build: generate mkdir -p build/html build/doctrees $(PYTHON) preprocess.py +ifeq (, $(shell which $(DOXYGEN))) + @echo "Unable to find 'Doxygen:$(DOXYGEN)', skip generating C/C++ API from comment blocks." +else $(DOXYGEN) build/doxygen/Doxyfile +endif $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html $(FILES) $(PYTHON) postprocess.py html build/html/*.html @echo diff --git a/doc/source/conf.py b/doc/source/conf.py index 835ad906415..d08f29e5946 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -2,6 +2,7 @@ import os import re import sys +import importlib # Minimum version, enforced by sphinx needs_sphinx = '3.2.0' @@ -84,9 +85,18 @@ class PyTypeObject(ctypes.Structure): 'IPython.sphinxext.ipython_console_highlighting', 'IPython.sphinxext.ipython_directive', 'sphinx.ext.mathjax', - 'breathe' ] +skippable_extensions = [ + ('breathe', 'skip generating C/C++ API from comment blocks.'), +] +for ext, warn in skippable_extensions: + ext_exist = importlib.util.find_spec(ext) is not None + if ext_exist: + extensions.append(ext) + else: + print(f"Unable to find Sphinx extension '{ext}', {warn}.") + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']