Skip to content

Commit 9b46129

Browse files
committed
Napoleon.
1 parent ef0bf1e commit 9b46129

5 files changed

Lines changed: 142 additions & 43 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'sphinx.ext.coverage',
2424
'sphinx.ext.doctest',
2525
'sphinx.ext.intersphinx',
26+
'sphinx.ext.napoleon',
2627
'sphinx.ext.viewcode',
2728
'jsonschema_role',
2829
]

jsonschema/_format.py

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ class FormatChecker(object):
2121
returns a ``bool``, use the :meth:`FormatChecker.checks` or
2222
:meth:`FormatChecker.cls_checks` decorators.
2323
24-
:argument iterable formats: the known formats to validate. This argument
25-
can be used to limit which formats will be used
26-
during validation.
24+
Arguments:
25+
26+
formats (iterable):
27+
28+
The known formats to validate. This argument can be used to
29+
limit which formats will be used during validation.
2730
2831
"""
2932

@@ -39,11 +42,20 @@ def checks(self, format, raises=()):
3942
"""
4043
Register a decorated function as validating a new format.
4144
42-
:argument str format: the format that the decorated function will check
43-
:argument Exception raises: the exception(s) raised by the decorated
44-
function when an invalid instance is found. The exception object
45-
will be accessible as the :attr:`ValidationError.cause` attribute
46-
of the resulting validation error.
45+
Arguments:
46+
47+
format (str):
48+
49+
The format that the decorated function will check.
50+
51+
raises (Exception):
52+
53+
The exception(s) raised by the decorated function when
54+
an invalid instance is found.
55+
56+
The exception object will be accessible as the
57+
:attr:`ValidationError.cause` attribute of the resulting
58+
validation error.
4759
4860
"""
4961

@@ -58,10 +70,20 @@ def check(self, instance, format):
5870
"""
5971
Check whether the instance conforms to the given format.
6072
61-
:argument instance: the instance to check
62-
:type: any primitive type (str, number, bool)
63-
:argument str format: the format that instance should conform to
64-
:raises: :exc:`FormatError` if instance does not conform to format
73+
Arguments:
74+
75+
instance (any primitive type, i.e. str, number, bool):
76+
77+
The instance to check
78+
79+
format (str):
80+
81+
The format that instance should conform to
82+
83+
84+
Raises:
85+
86+
:exc:`FormatError` if instance does not conform to ``format``
6587
6688
"""
6789

@@ -83,10 +105,19 @@ def conforms(self, instance, format):
83105
"""
84106
Check whether the instance conforms to the given format.
85107
86-
:argument instance: the instance to check
87-
:type: any primitive type (str, number, bool)
88-
:argument str format: the format that instance should conform to
89-
:rtype: bool
108+
Arguments:
109+
110+
instance (any primitive type, i.e. str, number, bool):
111+
112+
The instance to check
113+
114+
format (str):
115+
116+
The format that instance should conform to
117+
118+
Returns:
119+
120+
bool: Whether it conformed
90121
91122
"""
92123

jsonschema/_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def format_as_index(indices):
7373
7474
For example, [1, 2, "foo"] -> [1][2]["foo"]
7575
76-
:type indices: sequence
76+
Arguments:
77+
78+
indices (sequence):
79+
80+
The indices to format.
7781
7882
"""
7983

jsonschema/tests/test_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,6 @@ def sorted_errors(errors):
929929
def key(error):
930930
return (
931931
[str(e) for e in error.path],
932-
[str(e) for e in error.schema_path]
932+
[str(e) for e in error.schema_path],
933933
)
934934
return sorted(errors, key=key)

jsonschema/validators.py

Lines changed: 88 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ def validates(version):
3131
Registered validators and their meta schemas will be considered when
3232
parsing ``$schema`` properties' URIs.
3333
34-
:argument str version: an identifier to use as the version's name
35-
:returns: a class decorator to decorate the validator with the version
34+
Arguments:
35+
36+
version (str):
37+
38+
An identifier to use as the version's name
39+
40+
Returns:
41+
42+
callable: a class decorator to decorate the validator with the version
3643
3744
"""
3845

@@ -226,17 +233,38 @@ class RefResolver(object):
226233
"""
227234
Resolve JSON References.
228235
229-
:argument str base_uri: URI of the referring document
230-
:argument referrer: the actual referring document
231-
:argument dict store: a mapping from URIs to documents to cache
232-
:argument bool cache_remote: whether remote refs should be cached after
233-
first resolution
234-
:argument dict handlers: a mapping from URI schemes to functions that
235-
should be used to retrieve them
236-
:arguments functools.lru_cache urljoin_cache: a cache that will be used for
237-
caching the results of joining the resolution scope to subscopes.
238-
:arguments functools.lru_cache remote_cache: a cache that will be used for
239-
caching the results of resolved remote URLs.
236+
Arguments:
237+
238+
base_uri (str):
239+
240+
The URI of the referring document
241+
242+
referrer:
243+
244+
The actual referring document
245+
246+
store (dict):
247+
248+
A mapping from URIs to documents to cache
249+
250+
cache_remote (bool):
251+
252+
Whether remote refs should be cached after first resolution
253+
254+
handlers (dict):
255+
256+
A mapping from URI schemes to functions that should be used
257+
to retrieve them
258+
259+
urljoin_cache (functools.lru_cache):
260+
261+
A cache that will be used for caching the results of joining
262+
the resolution scope to subscopes.
263+
264+
remote_cache (functools.lru_cache):
265+
266+
A cache that will be used for caching the results of
267+
resolved remote URLs.
240268
241269
"""
242270

@@ -275,8 +303,15 @@ def from_schema(cls, schema, *args, **kwargs):
275303
"""
276304
Construct a resolver from a JSON schema object.
277305
278-
:argument schema: the referring schema
279-
:rtype: :class:`RefResolver`
306+
Arguments:
307+
308+
schema:
309+
310+
the referring schema
311+
312+
Returns:
313+
314+
:class:`RefResolver`
280315
281316
"""
282317

@@ -320,7 +355,11 @@ def resolving(self, ref):
320355
Context manager which resolves a JSON ``ref`` and enters the
321356
resolution scope of this ref.
322357
323-
:argument str ref: reference to resolve
358+
Arguments:
359+
360+
ref (str):
361+
362+
The reference to resolve
324363
325364
"""
326365

@@ -351,8 +390,15 @@ def resolve_fragment(self, document, fragment):
351390
"""
352391
Resolve a ``fragment`` within the referenced ``document``.
353392
354-
:argument document: the referrant document
355-
:argument str fragment: a URI fragment to resolve within it
393+
Arguments:
394+
395+
document:
396+
397+
The referrant document
398+
399+
fragment (str):
400+
401+
a URI fragment to resolve within it
356402
357403
"""
358404

@@ -394,8 +440,15 @@ def resolve_remote(self, uri):
394440
If it isn't, or if the scheme of the ``uri`` is not ``http`` or
395441
``https``, UTF-8 is assumed.
396442
397-
:argument str uri: the URI to resolve
398-
:returns: the retrieved document
443+
Arguments:
444+
445+
uri (str):
446+
447+
The URI to resolve
448+
449+
Returns:
450+
451+
The retrieved document
399452
400453
.. _requests: http://pypi.python.org/pypi/requests/
401454
@@ -448,10 +501,19 @@ def validate(instance, schema, cls=None, *args, **kwargs):
448501
(e.g. :meth:`Draft4Validator.validate`).
449502
450503
451-
:argument instance: the instance to validate
452-
:argument schema: the schema to validate with
453-
:argument cls: an :class:`IValidator` class that will be used to validate
454-
the instance.
504+
Arguments:
505+
506+
instance:
507+
508+
The instance to validate
509+
510+
schema:
511+
512+
The schema to validate with
513+
514+
cls (:class:`IValidator`):
515+
516+
The class that will be used to validate the instance.
455517
456518
If the ``cls`` argument is not provided, two things will happen in
457519
accordance with the specification. First, if the schema has a
@@ -464,7 +526,8 @@ def validate(instance, schema, cls=None, *args, **kwargs):
464526
Any other provided positional and keyword arguments will be passed on when
465527
instantiating the ``cls``.
466528
467-
:raises:
529+
Raises:
530+
468531
:exc:`ValidationError` if the instance is invalid
469532
470533
:exc:`SchemaError` if the schema itself is invalid

0 commit comments

Comments
 (0)