From 4634f853f1e294285dfae054bd7c1806340e0370 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 8 Mar 2018 10:49:04 +0100 Subject: [PATCH] Documentation spellcheck: Compatibility with enchant2 --- doc/conf.py | 38 +++++++++++++++++++++++--------------- doc/requirements.txt | 3 ++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 58bd411a09..2e95f89677 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -31,6 +31,13 @@ import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pretix.testutils.settings") django.setup() + +try: + import enchant + HAS_PYENCHANT = True +except: + HAS_PYENCHANT = False + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -45,8 +52,9 @@ extensions = [ 'sphinx.ext.coverage', 'sphinxcontrib.httpdomain', 'sphinxcontrib.images', - 'sphinxcontrib.spelling', ] +if HAS_PYENCHANT: + extensions.append('sphinxcontrib.spelling') # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -293,20 +301,20 @@ images_config = { } # -- Options for Spelling output ------------------------------------------ +if HAS_PYENCHANT: + # String specifying the language, as understood by PyEnchant and enchant. + # Defaults to en_US for US English. + spelling_lang = 'en_US' -# String specifying the language, as understood by PyEnchant and enchant. -# Defaults to en_US for US English. -spelling_lang = 'en_US' + # String specifying a file containing a list of words known to be spelled + # correctly but that do not appear in the language dictionary selected by + # spelling_lang. The file should contain one word per line. + spelling_word_list_filename='spelling_wordlist.txt' -# String specifying a file containing a list of words known to be spelled -# correctly but that do not appear in the language dictionary selected by -# spelling_lang. The file should contain one word per line. -spelling_word_list_filename='spelling_wordlist.txt' + # Boolean controlling whether suggestions for misspelled words are printed. + # Defaults to False. + spelling_show_suggestions=True -# Boolean controlling whether suggestions for misspelled words are printed. -# Defaults to False. -spelling_show_suggestions=True - -# List of filter classes to be added to the tokenizer that produces words to be checked. -from checkin_filter import CheckinFilter -spelling_filters=[CheckinFilter] + # List of filter classes to be added to the tokenizer that produces words to be checked. + from checkin_filter import CheckinFilter + spelling_filters=[CheckinFilter] diff --git a/doc/requirements.txt b/doc/requirements.txt index e5abe08f4f..af6173ce70 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -4,4 +4,5 @@ sphinx-rtd-theme sphinxcontrib-httpdomain sphinxcontrib-images sphinxcontrib-spelling -pyenchant +# See https://github.com/rfk/pyenchant/pull/130 +git+https://github.com/raphaelm/pyenchant.git@patch-1#egg=pyenchant