Skip to content

Commit 84c421c

Browse files
committed
Add Python type annotation
Signed-off-by: Jordan Borean <[email protected]>
1 parent 08fe531 commit 84c421c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3344
-2064
lines changed

ci/build.sh

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ if [ x"$FLAKE" = "xyes" ]; then
2626
fi
2727
fi
2828

29+
python -m mypy .
30+
MYPY_RES=$?
31+
if [ $MYPY_RES -ne 0 ]; then
32+
exit $MYPY_RES
33+
fi
34+
2935
# always build in-place so that Sphinx can find the modules
3036
python setup.py build_ext --inplace $EXTRA_BUILDEXT
3137
BUILD_RES=$?

docs-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Sphinx >= 1.3.1
2+
sphinx-autoapi
23
sphinx-rtd-theme >= 0.2.5b1
34
recommonmark >= 0.4.0

docs/source/conf.py

+62-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
import sys, os, re
1515

1616
# If extensions (or modules to document with autodoc) are in another directory,
1717
# add these directories to sys.path here. If the directory is relative to the
@@ -30,7 +30,20 @@
3030

3131
# Add any Sphinx extension module names here, as strings. They can be extensions
3232
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
33-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', "sphinx.ext.napoleon", 'gssapi_find_missing', 'requires_rfc']
33+
extensions = [
34+
'sphinx.ext.autodoc',
35+
'sphinx.ext.intersphinx',
36+
'sphinx.ext.viewcode',
37+
'sphinx.ext.napoleon',
38+
'autoapi.extension',
39+
'gssapi_find_missing',
40+
'requires_rfc',
41+
]
42+
43+
autoapi_generate_api_docs = False
44+
autoapi_type = 'python'
45+
autoapi_dirs = ['../../gssapi']
46+
autoapi_file_patterns = ['*.pyi']
3447

3548
# Add any paths that contain templates here, relative to this directory.
3649
templates_path = ['_templates']
@@ -56,11 +69,55 @@
5669
# The version info for the project you're documenting, acts as replacement for
5770
# |version| and |release|, also used in various other places throughout the
5871
# built documents.
59-
#
72+
# https://www.python.org/dev/peps/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
73+
setup_py_path = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'setup.py'))
74+
version_pattern = re.compile(r"""
75+
^\s*version=['|\"](?P<full_version>
76+
(?:
77+
(?:(?P<epoch>[0-9]+)!)? # epoch
78+
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
79+
(?P<pre> # pre-release
80+
[-_\.]?
81+
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
82+
[-_\.]?
83+
(?P<pre_n>[0-9]+)?
84+
)?
85+
(?P<post> # post release
86+
(?:-(?P<post_n1>[0-9]+))
87+
|
88+
(?:
89+
[-_\.]?
90+
(?P<post_l>post|rev|r)
91+
[-_\.]?
92+
(?P<post_n2>[0-9]+)?
93+
)
94+
)?
95+
(?P<dev> # dev release
96+
[-_\.]?
97+
(?P<dev_l>dev)
98+
[-_\.]?
99+
(?P<dev_n>[0-9]+)?
100+
)?
101+
)
102+
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
103+
)['|\"],?\s*$
104+
""", re.VERBOSE | re.IGNORECASE)
105+
60106
# The short X.Y version.
61-
version = '1.7.2'
107+
version = ''
62108
# The full version, including alpha/beta/rc tags.
63-
release = '1.7.2'
109+
release = ''
110+
111+
with open(setup_py_path, mode='r') as fd:
112+
for line in fd:
113+
version_match = version_pattern.match(line)
114+
if version_match:
115+
version = version_match.group('release')
116+
release = version_match.group('full_version')
117+
break
118+
119+
if not version or not release:
120+
raise Exception("Failed to find version in setup.py")
64121

65122
# The language for content autogenerated by Sphinx. Refer to documentation
66123
# for a list of supported languages.

docs/source/gssapi.raw.rst

+31-31
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,44 @@ Names
2525
Instead, they are a special form of name specific to
2626
a given mechanism.
2727

28-
.. automodule:: gssapi.raw.names
28+
.. autoapimodule:: gssapi.raw.names
2929
:members:
3030
:undoc-members:
3131

3232
Credentials
3333
~~~~~~~~~~~
3434

35-
.. automodule:: gssapi.raw.creds
35+
.. autoapimodule:: gssapi.raw.creds
3636
:members:
3737
:undoc-members:
3838

3939
Security Contexts
4040
~~~~~~~~~~~~~~~~~
4141

42-
.. automodule:: gssapi.raw.sec_contexts
42+
.. autoapimodule:: gssapi.raw.sec_contexts
4343
:members:
4444
:undoc-members:
4545

46-
.. automodule:: gssapi.raw.message
46+
.. autoapimodule:: gssapi.raw.message
4747
:members:
4848
:undoc-members:
4949

5050
Misc
5151
~~~~
5252

53-
.. automodule:: gssapi.raw.oids
53+
.. autoapimodule:: gssapi.raw.oids
5454
:members:
5555
:undoc-members:
5656

57-
.. automodule:: gssapi.raw.misc
57+
.. autoapimodule:: gssapi.raw.misc
5858
:members:
5959
:undoc-members:
6060

61-
.. automodule:: gssapi.raw.types
61+
.. autoapimodule:: gssapi.raw.types
6262
:members:
6363
:undoc-members:
6464

65-
.. automodule:: gssapi.raw.chan_bindings
65+
.. autoapimodule:: gssapi.raw.chan_bindings
6666
:members:
6767
:undoc-members:
6868

@@ -80,124 +80,124 @@ The following is a list of GSSAPI extensions supported by the low-level API.
8080
:rfc:`4178` (GSS-API Negotiation Mechanism)
8181
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8282

83-
.. automodule:: gssapi.raw.ext_rfc4178
83+
.. autoapimodule:: gssapi.raw.ext_rfc4178
8484
:members:
8585
:undoc-members:
8686

8787
:rfc:`5587` (GSS-API Extension for Mech Attributes)
8888
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8989

90-
.. automodule:: gssapi.raw.ext_rfc5587
90+
.. autoapimodule:: gssapi.raw.ext_rfc5587
9191
:members:
9292
:undoc-members:
9393

9494
:rfc:`5588` (GSS-API Extension for Storing Delegated Credentials)
9595
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9696

97-
.. automodule:: gssapi.raw.ext_rfc5588
97+
.. autoapimodule:: gssapi.raw.ext_rfc5588
9898
:members:
9999
:undoc-members:
100100

101101
:rfc:`5801` (GSS-API SASL Extensions)
102102
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103103

104-
.. automodule:: gssapi.raw.ext_rfc5801
104+
.. autoapimodule:: gssapi.raw.ext_rfc5801
105105
:members:
106106
:undoc-members:
107107

108108
Credential Store Extensions
109109
~~~~~~~~~~~~~~~~~~~~~~~~~~~
110110

111-
.. automodule:: gssapi.raw.ext_cred_store
111+
.. autoapimodule:: gssapi.raw.ext_cred_store
112112
:members:
113113
:undoc-members:
114114

115115
:rfc:`6680` (GSS-API Naming Extensions)
116116
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117117

118-
.. automodule:: gssapi.raw.ext_rfc6680
119-
:members:
120-
:undoc-members:
121-
122-
.. automodule:: gssapi.raw.ext_rfc6680_comp_oid
118+
.. autoapimodule:: gssapi.raw.ext_rfc6680
123119
:members:
124120
:undoc-members:
125121

126122
Credentials Import-Export Extensions
127123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128124

129-
.. automodule:: gssapi.raw.ext_cred_imp_exp
125+
.. autoapimodule:: gssapi.raw.ext_cred_imp_exp
130126
:members:
131127
:undoc-members:
132128

133129
DCE (IOV/AEAD) Extensions
134130
~~~~~~~~~~~~~~~~~~~~~~~~~
135131

136-
.. automodule:: gssapi.raw.ext_dce
132+
.. autoapimodule:: gssapi.raw.ext_dce
137133
:members:
138134
:undoc-members:
139135

140-
.. automodule:: gssapi.raw.ext_dce_aead
141-
:members:
142-
:undoc-members:
136+
..
137+
gssapi.raw.ext_dce_aead is imported with ext_dce so no need to double up.
138+
143139

144140
IOV MIC Extensions
145141
~~~~~~~~~~~~~~~~~~
146142

147-
.. automodule:: gssapi.raw.ext_iov_mic
143+
.. autoapimodule:: gssapi.raw.ext_iov_mic
148144
:members:
149145
:undoc-members:
150146

151147
Global Grid Forum (GGF) Extensions
152148
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153149

154-
.. automodule:: gssapi.raw.ext_ggf
150+
.. autoapimodule:: gssapi.raw.ext_ggf
155151
:members:
156152
:undoc-members:
157153

158154
Services4User Extensions
159155
~~~~~~~~~~~~~~~~~~~~~~~~
160156

161-
.. automodule:: gssapi.raw.ext_s4u
157+
.. autoapimodule:: gssapi.raw.ext_s4u
162158
:members:
163159
:undoc-members:
164160

165161
Acquiring Credentials With a Password Extensions
166162
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167163

168-
.. automodule:: gssapi.raw.ext_password
164+
.. autoapimodule:: gssapi.raw.ext_password
169165
:members:
170166
:undoc-members:
171167

172-
.. automodule:: gssapi.raw.ext_password_add
168+
.. autoapimodule:: gssapi.raw.ext_password_add
173169
:members:
174170
:undoc-members:
175171

176172
Kerberos Specific Extensions
177173
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178174

179-
.. automodule:: gssapi.raw.ext_krb5
175+
.. autoapimodule:: gssapi.raw.ext_krb5
180176
:members:
181177
:undoc-members:
182178

183179
Other Extensions
184180
~~~~~~~~~~~~~~~~
185181

186-
.. automodule:: gssapi.raw.ext_set_cred_opt
182+
.. autoapimodule:: gssapi.raw.ext_set_cred_opt
187183
:members:
188184
:undoc-members:
189185

190186
Results
191187
-------
192188

189+
..
190+
Use autoapimodule once
191+
https://github.com/readthedocs/sphinx-autoapi/issues/323 is resolved.
192+
193193
.. automodule:: gssapi.raw.named_tuples
194194
:members:
195195
:undoc-members:
196196

197197
Exceptions
198198
----------
199199

200-
.. automodule:: gssapi.raw.exceptions
200+
.. autoapimodule:: gssapi.raw.exceptions
201201
:members:
202202
:undoc-members:
203203
:show-inheritance:

0 commit comments

Comments
 (0)