Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues uncovered by sphinx nitpicking option #289

Merged
merged 3 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/source/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Common
======

Functions
---------
.. autofunction:: jwcrypto.common.base64url_encode
.. autofunction:: jwcrypto.common.base64url_decode
.. autofunction:: jwcrypto.common.json_encode
.. autofunction:: jwcrypto.common.json_decode

Classes
-------

.. autoclass:: jwcrypto.common.JWSEHeaderRegistry
:members:

Exceptions
----------

.. autoclass:: jwcrypto.common.JWException

.. autoclass:: jwcrypto.common.InvalidJWAAlgorithm
:show-inheritance:

.. autoclass:: jwcrypto.common.InvalidCEKeyLength
:show-inheritance:

.. autoclass:: jwcrypto.common.InvalidJWEOperation
:show-inheritance:

.. autoclass:: jwcrypto.common.InvalidJWEKeyType
:show-inheritance:

.. autoclass:: jwcrypto.common.InvalidJWEKeyLength
:show-inheritance:

.. autoclass:: jwcrypto.common.InvalidJWSERegOperation
:show-inheritance:
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Contents:
jws
jwe
jwt
common


Note: In the examples, random or generated output values are replaced
Expand Down
12 changes: 11 additions & 1 deletion jwcrypto/jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class JWK(dict):
"""

def __init__(self, **kwargs):
"""Creates a new JWK object.
r"""Creates a new JWK object.

The function arguments must be valid parameters as defined in the
'IANA JSON Web Key Set Parameters registry' and specified in
Expand All @@ -299,6 +299,8 @@ def __init__(self, **kwargs):
valid key type as value then a new key will be generated according
to the defaults or provided key strength options (type specific).

:param \**kwargs: parameters (otional).

:raises InvalidJWKType: if the key type is invalid
:raises InvalidJWKValue: if incorrect or inconsistent parameters
are provided.
Expand Down Expand Up @@ -1107,6 +1109,10 @@ def __setitem__(self, item, value):
super(JWK, self).__setitem__(item, value)

def update(self, *args, **kwargs):
r"""
:param \*args: arguments
:param \**kwargs: keyword arguments
"""
for k, v in dict(*args, **kwargs).items():
self.__setitem__(k, v)

Expand Down Expand Up @@ -1233,6 +1239,10 @@ def __setitem__(self, key, val):
super(JWKSet, self).__setitem__(key, val)

def update(self, *args, **kwargs):
r"""
:param \*args: arguments
:param \**kwargs: keyword arguments
"""
for k, v in dict(*args, **kwargs).items():
self.__setitem__(k, v)

Expand Down
4 changes: 2 additions & 2 deletions jwcrypto/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, alg, key, header, payload, algs=None):
:param payload(bytes): An arbitrary value
:param algs: An optional list of allowed algorithms

:raises ValueError: if the key is not a :class:`JWK` object
:raises ValueError: if the key is not a (:class:`jwcrypto.jwk.JWK`)
:raises InvalidJWAAlgorithm: if the algorithm is not valid, is
unknown or otherwise not yet implemented.
:raises InvalidJWSOperation: if the algorithm is not allowed.
Expand Down Expand Up @@ -477,7 +477,7 @@ def add_signature(self, key, alg=None, protected=None, header=None):
:param header: The Unprotected Header (optional)

:raises InvalidJWSObject: if invalid headers are provided.
:raises ValueError: if the key is not a :class:`JWK` object.
:raises ValueError: if the key is not a (:class:`jwcrypto.jwk.JWK`)
:raises ValueError: if the algorithm is missing or is not provided
by one of the headers.
:raises InvalidJWAAlgorithm: if the algorithm is not valid, is
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ changedir = docs/source
deps =
sphinx
commands =
sphinx-build -v -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
sphinx-build -n -v -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv:doctest]
basepython = python3.10
Expand Down