From b7a8a3498ba245e64116cad73105d1d45eff8d43 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Mon, 11 Jun 2018 21:41:08 +0100 Subject: [PATCH] DOC: Loading sphinxcontrib.spelling to sphinx only if it's available --- ci/environment-dev.yaml | 1 + ci/requirements_dev.txt | 1 + doc/source/conf.py | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ci/environment-dev.yaml b/ci/environment-dev.yaml index f9f9208519d61..5733857b55dd4 100644 --- a/ci/environment-dev.yaml +++ b/ci/environment-dev.yaml @@ -13,3 +13,4 @@ dependencies: - pytz - setuptools>=24.2.0 - sphinx + - sphinxcontrib-spelling diff --git a/ci/requirements_dev.txt b/ci/requirements_dev.txt index 3430e778a4573..83ee30b52071d 100644 --- a/ci/requirements_dev.txt +++ b/ci/requirements_dev.txt @@ -9,3 +9,4 @@ python-dateutil>=2.5.0 pytz setuptools>=24.2.0 sphinx +sphinxcontrib-spelling \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 97081bec863b7..909bd5a80b76e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -16,9 +16,11 @@ import re import inspect import importlib -from sphinx.ext.autosummary import _import_by_name +import logging import warnings +from sphinx.ext.autosummary import _import_by_name +logger = logging.getLogger(__name__) try: raw_input # Python 2 @@ -73,9 +75,16 @@ 'sphinx.ext.ifconfig', 'sphinx.ext.linkcode', 'nbsphinx', - 'sphinxcontrib.spelling' ] +try: + import sphinxcontrib.spelling +except ImportError as err: + logger.warn(('sphinxcontrib.spelling failed to import with error "{}". ' + '`spellcheck` command is not available.'.format(err))) +else: + extensions.append('sphinxcontrib.spelling') + exclude_patterns = ['**.ipynb_checkpoints'] spelling_word_list_filename = ['spelling_wordlist.txt', 'names_wordlist.txt']