diff --git a/doc/conf.py b/doc/conf.py index a62c4d84..d4828de3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,8 +4,13 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -# -- Path setup -------------------------------------------------------------- -from pathlib import Path +# -- Release import + +import sys, os +sys.path.append(os.path.dirname(__file__)) + + +from lgrelease import release # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -22,30 +27,17 @@ project = 'Looking Glass' copyright = '2021, Looking Glass team' author = 'Geoffrey McRae and the Looking Glass team' -# The full version, including alpha/beta/rc tags -try: - with open(Path(__file__).parent.parent / 'VERSION') as f: - release = f.read().strip() -except IOError: - import subprocess - try: - release = subprocess.check_output([ - 'git', 'describe', '--always', '--abbrev=10', '--dirty=+', '--tags' - ]).decode('utf-8').strip() - except (subprocess.CalledProcessError, OSError): - release = '(unknown version)' - del subprocess - - rst_prolog = """ .. |license| replace:: GPLv2 """ + # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. + extensions = [ 'sphinx_rtd_theme', ] @@ -58,11 +50,9 @@ 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' + 'lgspell.CryptoAddressFilter', 'lgspell.VersionFilter' ] spelling_word_list_filename = [os.path.join(os.path.dirname(__file__), 'words.txt')] diff --git a/doc/lgrelease.py b/doc/lgrelease.py new file mode 100644 index 00000000..4af7e7fb --- /dev/null +++ b/doc/lgrelease.py @@ -0,0 +1,17 @@ +# -- Path setup -------------------------------------------------------------- +from pathlib import Path + +release = None + +try: + with open(Path(__file__).parent.parent / 'VERSION') as f: + release = f.read().strip() +except IOError: + import subprocess + try: + release = subprocess.check_output([ + 'git', 'describe', '--always', '--abbrev=10', '--dirty=+', '--tags' + ]).decode('utf-8').strip() + except (subprocess.CalledProcessError, OSError): + release = '(unknown version)' + del subprocess diff --git a/doc/lgspell.py b/doc/lgspell.py index 60617cf6..4148dc87 100755 --- a/doc/lgspell.py +++ b/doc/lgspell.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 import re +import sys, os +sys.path.append(os.path.dirname(__file__)) + +from lgrelease import release from enchant.tokenize import Filter @@ -36,6 +40,11 @@ class CryptoAddressFilter(Filter): return recrypto.match(word) +class VersionFilter(Filter): + def _skip(self, word): + return word == release + + if __name__ == '__main__': import os import sys