1414
1515import sys
1616import os
17-
17+ import pkg_resources
1818import pip
1919
2020try :
21- from mock import Mock as MagicMock
21+ from unittest . mock import MagicMock
2222except ImportError :
2323 def install (package ):
2424 pip .main (['install' , package ])
2525
2626 install ('mock' )
2727 from mock import Mock as MagicMock
2828
29+ try :
30+ from sphinxcontrib import spelling
31+ except ImportError :
32+ spelling = None
33+
2934
3035on_rtd = os .environ .get ('READTHEDOCS' , None ) == 'True'
31- if on_rtd :
32- html_theme = 'default'
33- else :
34- html_theme = 'nature'
36+
37+ html_theme = 'nature'
3538
3639# ------------------------------------------------------------------- #
3740# MOCK MODULES
3841# ------------------------------------------------------------------- #
39- on_rtd = os .environ .get ('READTHEDOCS' , None ) == 'True'
4042
4143if on_rtd :
4244 class Mock (MagicMock ):
4345 @classmethod
4446 def __getattr__ (cls , name ):
45- return Mock ()
47+ return MagicMock ()
4648
4749 MOCK_MODULES = ['gmpy2' , 'numpy' ]
4850 sys .modules .update ((mod_name , Mock ()) for mod_name in MOCK_MODULES )
4951
5052
51-
5253# If extensions (or modules to document with autodoc) are in another directory,
5354# add these directories to sys.path here. If the directory is relative to the
5455# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -64,12 +65,16 @@ def __getattr__(cls, name):
6465# ones.
6566extensions = [
6667 'sphinx.ext.autodoc' ,
68+ 'sphinx.ext.intersphinx' ,
6769 'sphinx.ext.viewcode' ,
6870 'sphinx.ext.doctest' ,
6971 'sphinx.ext.napoleon' , # Sphinx >= 1.3
7072 #'sphinxcontrib.napoleon' # Sphinx 1.2
7173]
7274
75+ if spelling is not None :
76+ extensions .append ('sphinxcontrib.spelling' )
77+
7378# Don't test blocks that are not doctest directive blocks - e.g. all the
7479# code in alternitives.rst
7580doctest_test_doctest_blocks = ""
@@ -86,18 +91,24 @@ def __getattr__(cls, name):
8691# The master toctree document.
8792master_doc = 'index'
8893
94+
95+ base_dir = os .path .join (os .path .dirname (__file__ ), os .pardir )
96+ about = {}
97+ with open (os .path .join (base_dir , "phe" , "__about__.py" )) as f :
98+ exec (f .read (), about )
99+
89100# General information about the project.
90101project = 'python-paillier'
91- copyright = '2016, DATA61 | CSIRO'
102+ copyright = about [ '__copyright__' ]
92103
93104# The version info for the project you're documenting, acts as replacement for
94105# |version| and |release|, also used in various other places throughout the
95106# built documents.
96107#
97- # The short X.Y version.
98- version = '1.3'
99108# The full version, including alpha/beta/rc tags.
100- release = '1.3.1'
109+ version = about ['__version__' ]
110+ # The short X.Y version.
111+ release = pkg_resources .parse_version (version ).base_version
101112
102113# The language for content autogenerated by Sphinx. Refer to documentation
103114# for a list of supported languages.
@@ -140,10 +151,6 @@ def __getattr__(cls, name):
140151
141152# -- Options for HTML output ----------------------------------------------
142153
143- # The theme to use for HTML and HTML Help pages. See the documentation for
144- # a list of builtin themes.
145- html_theme = 'nature'
146-
147154# Theme options are theme-specific and customize the look and feel of a theme
148155# further. For a list of options available for each theme, see the
149156# documentation.
0 commit comments