From 753b44e34fa8ce8568f9d3d984f46cbf789511aa Mon Sep 17 00:00:00 2001 From: Quantum Date: Wed, 1 Sep 2021 19:14:58 -0400 Subject: [PATCH] [doc] support building with spell check --- doc/conf.py | 16 ++++++++++++++++ doc/lgspell.py | 29 ++++++++++++++++++++++++++++ doc/words.txt | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 doc/lgspell.py create mode 100644 doc/words.txt diff --git a/doc/conf.py b/doc/conf.py index a04aff11..031b768a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -36,6 +36,22 @@ rst_prolog = """ extensions = [ ] +try: + from sphinxcontrib import spelling +except ImportError: + pass +else: + del spelling + extensions += ['sphinxcontrib.spelling'] + + import sys, os + sys.path.append(os.path.dirname(__file__)) + spelling_filters = [ + 'lgspell.OptionFilter', 'lgspell.PackageFilter', 'lgspell.PathFilter', + 'lgspell.CryptoAddressFilter' + ] + spelling_word_list_filename = [os.path.join(os.path.dirname(__file__), 'words.txt')] + # Add any paths that contain templates here, relative to this directory. # templates_path = ['_templates'] diff --git a/doc/lgspell.py b/doc/lgspell.py new file mode 100644 index 00000000..6c6cf39d --- /dev/null +++ b/doc/lgspell.py @@ -0,0 +1,29 @@ +import re + +from enchant.tokenize import Filter + +reoption = re.compile(r'^[a-z]+:\w+$') +recamel = re.compile(r'^[a-z]+[A-Z]\w+$') +repackage = re.compile(r'^[\w-]+-(?:dev|bin)$|^fonts-[\w-]+-ttf$|^virt-manager$') +repath = re.compile(r'^/dev/') +recrypto = re.compile(r'^[13][A-Za-z0-9]{25,34}$|^0x[0-9a-fA-F]{40}$') + + +class OptionFilter(Filter): + def _skip(self, word): + return reoption.match(word) or recamel.match(word) + + +class PackageFilter(Filter): + def _skip(self, word): + return repackage.match(word) + + +class PathFilter(Filter): + def _skip(self, word): + return repath.match(word) + + +class CryptoAddressFilter(Filter): + def _skip(self, word): + return recrypto.match(word) diff --git a/doc/words.txt b/doc/words.txt new file mode 100644 index 00000000..bfadf140 --- /dev/null +++ b/doc/words.txt @@ -0,0 +1,51 @@ +backtrace +borderless +cgroups +clang +cmake +config +deuteranope +distros +dmabuf +fullscreen +gcc +gnif +imgui +ini +kvmfr +laggy +libdecor +libvirt +linux +LookingGlass +mingw +mipmapping +modprobe +msys +multisampling +Nvidia +pacman +passthrough +pre +protanope +QEMU +radeon +realtime +renderer +repo +submodule +submodules +systemd +toolchain +tritanope +udev +UEFI +uncheck +uncomment +Unigine +unix +VM +vsync +wayland +xdg +xyene