From 370005bde79d2add17a344b9b0b9e8fc5f9c471f Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Wed, 7 Feb 2024 11:00:13 +0100 Subject: [PATCH] DOC: check pandoc installation and fail on error --- doc/source/conf.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 125d3f82510..96d01fa6a61 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -222,6 +222,7 @@ def setup(app): app.add_directive('pprint', PrettyPrintDirective) app.connect('autodoc-skip-member', autodoc_skip_member) app.connect('builder-inited', copy_examples) + app.connect("builder-inited", ensure_pandoc_installed) app.connect('source-read', add_ipython_time) app.connect('source-read', adjust_image_path) app.connect('html-page-context', remove_ipython_time_from_html) @@ -230,6 +231,19 @@ def setup(app): app.connect('build-finished', remove_doctree) app.connect('build-finished', check_build_finished_without_error) +def check_pandoc_installed(): + """Ensure that pandoc is installed + """ + import pypandoc + + try: + pandoc_path = pypandoc.get_pandoc_path() + pandoc_dir = os.path.dirname(pandoc_path) + if pandoc_dir not in os.environ["PATH"].split(os.pathsep): + os.environ["PATH"] += os.pathsep + pandoc_dir + except OSError: + logger.error("Pandoc was not found, please add it to your path or install pypandoc-binary") + local_path = os.path.dirname(os.path.realpath(__file__)) module_path = pathlib.Path(local_path) root_path = module_path.parent.parent @@ -392,7 +406,7 @@ def setup(app): nbsphinx_execute = "always" # Allow errors to help debug. -nbsphinx_allow_errors = True +nbsphinx_allow_errors = False # Sphinx gallery customization