These options can be set in conf.py along with the other Sphinx configuration settings.
Enable or disable the built-in filters to control which words are returned by the tokenizer to be checked.
There are two ways to provide a list of known good words. The spelling_word_list_filename option (described above) specifies the name of a plain text file containing one word per line. All of the words in the file are assumed to be spelled correctly and may appear in any part of the document being processed.
The spelling directive can be used to create a list of words known to be spelled correctly within a single file. For example, if a document refers to a person or project by name, the name can be added to the list of known words for just that document.
.. spelling::
Docutils
Goodger
The PyEnchant tokenizer supports a “filtering” API for processing words from the input. Filters can alter the stream of words by adding, replacing, or dropping values.
New filters should be derived from enchant.tokenize.Filter and implement either the _split() method (to add or replace words) or _skip() (to treat words as being spelled correctly). For example, this AcronymFilter skips words that are all uppercase letters or all uppercase with a trailing lowercase “s”.
class AcronymFilter(Filter):
"""If a word looks like an acronym (all upper case letters),
ignore it.
"""
def _skip(self, word):
return (word.isupper() # all caps
or
# pluralized acronym ("URLs")
(word[-1].lower() == 's'
and
word[:-1].isupper()
)
)
To be used in a document, the custom filter needs to be installed somewhere that Sphinx can import it while processing the input files. The Sphinx project’s conf.py then needs two changes.
from mymodule import MyFilter
spelling_filters = [MyFilter]