Napoleon.
This commit is contained in:
@@ -23,6 +23,7 @@ extensions = [
|
|||||||
'sphinx.ext.coverage',
|
'sphinx.ext.coverage',
|
||||||
'sphinx.ext.doctest',
|
'sphinx.ext.doctest',
|
||||||
'sphinx.ext.intersphinx',
|
'sphinx.ext.intersphinx',
|
||||||
|
'sphinx.ext.napoleon',
|
||||||
'sphinx.ext.viewcode',
|
'sphinx.ext.viewcode',
|
||||||
'jsonschema_role',
|
'jsonschema_role',
|
||||||
]
|
]
|
||||||
|
@@ -21,9 +21,12 @@ class FormatChecker(object):
|
|||||||
returns a ``bool``, use the :meth:`FormatChecker.checks` or
|
returns a ``bool``, use the :meth:`FormatChecker.checks` or
|
||||||
:meth:`FormatChecker.cls_checks` decorators.
|
:meth:`FormatChecker.cls_checks` decorators.
|
||||||
|
|
||||||
:argument iterable formats: the known formats to validate. This argument
|
Arguments:
|
||||||
can be used to limit which formats will be used
|
|
||||||
during validation.
|
formats (iterable):
|
||||||
|
|
||||||
|
The known formats to validate. This argument can be used to
|
||||||
|
limit which formats will be used during validation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -39,11 +42,20 @@ class FormatChecker(object):
|
|||||||
"""
|
"""
|
||||||
Register a decorated function as validating a new format.
|
Register a decorated function as validating a new format.
|
||||||
|
|
||||||
:argument str format: the format that the decorated function will check
|
Arguments:
|
||||||
:argument Exception raises: the exception(s) raised by the decorated
|
|
||||||
function when an invalid instance is found. The exception object
|
format (str):
|
||||||
will be accessible as the :attr:`ValidationError.cause` attribute
|
|
||||||
of the resulting validation error.
|
The format that the decorated function will check.
|
||||||
|
|
||||||
|
raises (Exception):
|
||||||
|
|
||||||
|
The exception(s) raised by the decorated function when
|
||||||
|
an invalid instance is found.
|
||||||
|
|
||||||
|
The exception object will be accessible as the
|
||||||
|
:attr:`ValidationError.cause` attribute of the resulting
|
||||||
|
validation error.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -58,10 +70,20 @@ class FormatChecker(object):
|
|||||||
"""
|
"""
|
||||||
Check whether the instance conforms to the given format.
|
Check whether the instance conforms to the given format.
|
||||||
|
|
||||||
:argument instance: the instance to check
|
Arguments:
|
||||||
:type: any primitive type (str, number, bool)
|
|
||||||
:argument str format: the format that instance should conform to
|
instance (any primitive type, i.e. str, number, bool):
|
||||||
:raises: :exc:`FormatError` if instance does not conform to format
|
|
||||||
|
The instance to check
|
||||||
|
|
||||||
|
format (str):
|
||||||
|
|
||||||
|
The format that instance should conform to
|
||||||
|
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
|
||||||
|
:exc:`FormatError` if instance does not conform to ``format``
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -83,10 +105,19 @@ class FormatChecker(object):
|
|||||||
"""
|
"""
|
||||||
Check whether the instance conforms to the given format.
|
Check whether the instance conforms to the given format.
|
||||||
|
|
||||||
:argument instance: the instance to check
|
Arguments:
|
||||||
:type: any primitive type (str, number, bool)
|
|
||||||
:argument str format: the format that instance should conform to
|
instance (any primitive type, i.e. str, number, bool):
|
||||||
:rtype: bool
|
|
||||||
|
The instance to check
|
||||||
|
|
||||||
|
format (str):
|
||||||
|
|
||||||
|
The format that instance should conform to
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
bool: Whether it conformed
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -73,7 +73,11 @@ def format_as_index(indices):
|
|||||||
|
|
||||||
For example, [1, 2, "foo"] -> [1][2]["foo"]
|
For example, [1, 2, "foo"] -> [1][2]["foo"]
|
||||||
|
|
||||||
:type indices: sequence
|
Arguments:
|
||||||
|
|
||||||
|
indices (sequence):
|
||||||
|
|
||||||
|
The indices to format.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -929,6 +929,6 @@ def sorted_errors(errors):
|
|||||||
def key(error):
|
def key(error):
|
||||||
return (
|
return (
|
||||||
[str(e) for e in error.path],
|
[str(e) for e in error.path],
|
||||||
[str(e) for e in error.schema_path]
|
[str(e) for e in error.schema_path],
|
||||||
)
|
)
|
||||||
return sorted(errors, key=key)
|
return sorted(errors, key=key)
|
||||||
|
@@ -31,8 +31,15 @@ def validates(version):
|
|||||||
Registered validators and their meta schemas will be considered when
|
Registered validators and their meta schemas will be considered when
|
||||||
parsing ``$schema`` properties' URIs.
|
parsing ``$schema`` properties' URIs.
|
||||||
|
|
||||||
:argument str version: an identifier to use as the version's name
|
Arguments:
|
||||||
:returns: a class decorator to decorate the validator with the version
|
|
||||||
|
version (str):
|
||||||
|
|
||||||
|
An identifier to use as the version's name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
callable: a class decorator to decorate the validator with the version
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -226,17 +233,38 @@ class RefResolver(object):
|
|||||||
"""
|
"""
|
||||||
Resolve JSON References.
|
Resolve JSON References.
|
||||||
|
|
||||||
:argument str base_uri: URI of the referring document
|
Arguments:
|
||||||
:argument referrer: the actual referring document
|
|
||||||
:argument dict store: a mapping from URIs to documents to cache
|
base_uri (str):
|
||||||
:argument bool cache_remote: whether remote refs should be cached after
|
|
||||||
first resolution
|
The URI of the referring document
|
||||||
:argument dict handlers: a mapping from URI schemes to functions that
|
|
||||||
should be used to retrieve them
|
referrer:
|
||||||
:arguments functools.lru_cache urljoin_cache: a cache that will be used for
|
|
||||||
caching the results of joining the resolution scope to subscopes.
|
The actual referring document
|
||||||
:arguments functools.lru_cache remote_cache: a cache that will be used for
|
|
||||||
caching the results of resolved remote URLs.
|
store (dict):
|
||||||
|
|
||||||
|
A mapping from URIs to documents to cache
|
||||||
|
|
||||||
|
cache_remote (bool):
|
||||||
|
|
||||||
|
Whether remote refs should be cached after first resolution
|
||||||
|
|
||||||
|
handlers (dict):
|
||||||
|
|
||||||
|
A mapping from URI schemes to functions that should be used
|
||||||
|
to retrieve them
|
||||||
|
|
||||||
|
urljoin_cache (functools.lru_cache):
|
||||||
|
|
||||||
|
A cache that will be used for caching the results of joining
|
||||||
|
the resolution scope to subscopes.
|
||||||
|
|
||||||
|
remote_cache (functools.lru_cache):
|
||||||
|
|
||||||
|
A cache that will be used for caching the results of
|
||||||
|
resolved remote URLs.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -275,8 +303,15 @@ class RefResolver(object):
|
|||||||
"""
|
"""
|
||||||
Construct a resolver from a JSON schema object.
|
Construct a resolver from a JSON schema object.
|
||||||
|
|
||||||
:argument schema: the referring schema
|
Arguments:
|
||||||
:rtype: :class:`RefResolver`
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
the referring schema
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
:class:`RefResolver`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -320,7 +355,11 @@ class RefResolver(object):
|
|||||||
Context manager which resolves a JSON ``ref`` and enters the
|
Context manager which resolves a JSON ``ref`` and enters the
|
||||||
resolution scope of this ref.
|
resolution scope of this ref.
|
||||||
|
|
||||||
:argument str ref: reference to resolve
|
Arguments:
|
||||||
|
|
||||||
|
ref (str):
|
||||||
|
|
||||||
|
The reference to resolve
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -351,8 +390,15 @@ class RefResolver(object):
|
|||||||
"""
|
"""
|
||||||
Resolve a ``fragment`` within the referenced ``document``.
|
Resolve a ``fragment`` within the referenced ``document``.
|
||||||
|
|
||||||
:argument document: the referrant document
|
Arguments:
|
||||||
:argument str fragment: a URI fragment to resolve within it
|
|
||||||
|
document:
|
||||||
|
|
||||||
|
The referrant document
|
||||||
|
|
||||||
|
fragment (str):
|
||||||
|
|
||||||
|
a URI fragment to resolve within it
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -394,8 +440,15 @@ class RefResolver(object):
|
|||||||
If it isn't, or if the scheme of the ``uri`` is not ``http`` or
|
If it isn't, or if the scheme of the ``uri`` is not ``http`` or
|
||||||
``https``, UTF-8 is assumed.
|
``https``, UTF-8 is assumed.
|
||||||
|
|
||||||
:argument str uri: the URI to resolve
|
Arguments:
|
||||||
:returns: the retrieved document
|
|
||||||
|
uri (str):
|
||||||
|
|
||||||
|
The URI to resolve
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
The retrieved document
|
||||||
|
|
||||||
.. _requests: http://pypi.python.org/pypi/requests/
|
.. _requests: http://pypi.python.org/pypi/requests/
|
||||||
|
|
||||||
@@ -448,10 +501,19 @@ def validate(instance, schema, cls=None, *args, **kwargs):
|
|||||||
(e.g. :meth:`Draft4Validator.validate`).
|
(e.g. :meth:`Draft4Validator.validate`).
|
||||||
|
|
||||||
|
|
||||||
:argument instance: the instance to validate
|
Arguments:
|
||||||
:argument schema: the schema to validate with
|
|
||||||
:argument cls: an :class:`IValidator` class that will be used to validate
|
instance:
|
||||||
the instance.
|
|
||||||
|
The instance to validate
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
The schema to validate with
|
||||||
|
|
||||||
|
cls (:class:`IValidator`):
|
||||||
|
|
||||||
|
The class that will be used to validate the instance.
|
||||||
|
|
||||||
If the ``cls`` argument is not provided, two things will happen in
|
If the ``cls`` argument is not provided, two things will happen in
|
||||||
accordance with the specification. First, if the schema has a
|
accordance with the specification. First, if the schema has a
|
||||||
@@ -464,7 +526,8 @@ def validate(instance, schema, cls=None, *args, **kwargs):
|
|||||||
Any other provided positional and keyword arguments will be passed on when
|
Any other provided positional and keyword arguments will be passed on when
|
||||||
instantiating the ``cls``.
|
instantiating the ``cls``.
|
||||||
|
|
||||||
:raises:
|
Raises:
|
||||||
|
|
||||||
:exc:`ValidationError` if the instance is invalid
|
:exc:`ValidationError` if the instance is invalid
|
||||||
|
|
||||||
:exc:`SchemaError` if the schema itself is invalid
|
:exc:`SchemaError` if the schema itself is invalid
|
||||||
|
Reference in New Issue
Block a user