14
14
15
15
import sys
16
16
import os
17
-
17
+ import pkg_resources
18
18
import pip
19
19
20
20
try :
21
- from mock import Mock as MagicMock
21
+ from unittest . mock import MagicMock
22
22
except ImportError :
23
23
def install (package ):
24
24
pip .main (['install' , package ])
25
25
26
26
install ('mock' )
27
27
from mock import Mock as MagicMock
28
28
29
+ try :
30
+ from sphinxcontrib import spelling
31
+ except ImportError :
32
+ spelling = None
33
+
29
34
30
35
on_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'
35
38
36
39
# ------------------------------------------------------------------- #
37
40
# MOCK MODULES
38
41
# ------------------------------------------------------------------- #
39
- on_rtd = os .environ .get ('READTHEDOCS' , None ) == 'True'
40
42
41
43
if on_rtd :
42
44
class Mock (MagicMock ):
43
45
@classmethod
44
46
def __getattr__ (cls , name ):
45
- return Mock ()
47
+ return MagicMock ()
46
48
47
49
MOCK_MODULES = ['gmpy2' , 'numpy' ]
48
50
sys .modules .update ((mod_name , Mock ()) for mod_name in MOCK_MODULES )
49
51
50
52
51
-
52
53
# If extensions (or modules to document with autodoc) are in another directory,
53
54
# add these directories to sys.path here. If the directory is relative to the
54
55
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -64,12 +65,16 @@ def __getattr__(cls, name):
64
65
# ones.
65
66
extensions = [
66
67
'sphinx.ext.autodoc' ,
68
+ 'sphinx.ext.intersphinx' ,
67
69
'sphinx.ext.viewcode' ,
68
70
'sphinx.ext.doctest' ,
69
71
'sphinx.ext.napoleon' , # Sphinx >= 1.3
70
72
#'sphinxcontrib.napoleon' # Sphinx 1.2
71
73
]
72
74
75
+ if spelling is not None :
76
+ extensions .append ('sphinxcontrib.spelling' )
77
+
73
78
# Don't test blocks that are not doctest directive blocks - e.g. all the
74
79
# code in alternitives.rst
75
80
doctest_test_doctest_blocks = ""
@@ -86,18 +91,24 @@ def __getattr__(cls, name):
86
91
# The master toctree document.
87
92
master_doc = 'index'
88
93
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
+
89
100
# General information about the project.
90
101
project = 'python-paillier'
91
- copyright = '2016, DATA61 | CSIRO'
102
+ copyright = about [ '__copyright__' ]
92
103
93
104
# The version info for the project you're documenting, acts as replacement for
94
105
# |version| and |release|, also used in various other places throughout the
95
106
# built documents.
96
107
#
97
- # The short X.Y version.
98
- version = '1.3'
99
108
# 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
101
112
102
113
# The language for content autogenerated by Sphinx. Refer to documentation
103
114
# for a list of supported languages.
@@ -140,10 +151,6 @@ def __getattr__(cls, name):
140
151
141
152
# -- Options for HTML output ----------------------------------------------
142
153
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
-
147
154
# Theme options are theme-specific and customize the look and feel of a theme
148
155
# further. For a list of options available for each theme, see the
149
156
# documentation.
0 commit comments