Skip to content

Commit acec3cb

Browse files
committed
Improved documentation
1 parent e18a0d8 commit acec3cb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

fastjsonschema/__init__.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"""
88
This project was made to come up with fast JSON validations. Just let's see some numbers first:
99
10-
* Probalby most popular ``jsonschema`` can take in tests up to 5 seconds for valid inputs
10+
* Probably most popular ``jsonschema`` can take up to 5 seconds for valid inputs
1111
and 1.2 seconds for invalid inputs.
12-
* Secondly most popular ``json-spec`` is even worse with up to 7.2 and 1.7 seconds.
13-
* Lastly ``validictory`` is much better with 370 or 23 miliseconds, but it does not
12+
* Second most popular ``json-spec`` is even worse with up to 7.2 and 1.7 seconds.
13+
* Last ``validictory`` is much better with 370 or 23 milliseconds, but it does not
1414
follow all standards and it can be still slow for some purposes.
1515
1616
That's why this project exists. It compiles definition into Python most stupid code
17-
which people would had hard time to write by themselfs because of not-written-rule DRY
18-
(don't repeat yourself). When you compile definition, then times are 25 miliseconds for
19-
valid inputs and less than 2 miliseconds for invalid inputs. Pretty amazing, right? :-)
17+
which people would have hard time to write by themselves because of not-written-rule DRY
18+
(don't repeat yourself). When you compile definition, then times are 25 milliseconds for
19+
valid inputs and less than 2 milliseconds for invalid inputs. Pretty amazing, right? :-)
2020
21-
You can try it for yourself with included script:
21+
You can try it for yourself with an included script:
2222
2323
.. code-block:: bash
2424
@@ -36,16 +36,16 @@
3636
validictory valid ==> 0.4084212710149586
3737
validictory invalid ==> 0.026061681972350925
3838
39-
This library follows and implements `JSON schema draft-04, draft-06 and draft-07
39+
This library follows and implements `JSON schema draft-04, draft-06, and draft-07
4040
<http://json-schema.org>`_. Sometimes it's not perfectly clear so I recommend also
41-
check out this `understaning json schema <https://spacetelescope.github.io/understanding-json-schema>`_.
41+
check out this `understanding json schema <https://spacetelescope.github.io/understanding-json-schema>`_.
4242
4343
Note that there are some differences compared to JSON schema standard:
4444
4545
* Regular expressions are full Python ones, not only what JSON schema allows. It's easier
4646
to allow everything and also it's faster to compile without limits. So keep in mind that when
47-
you will use more advanced regular expression, it may not work with other library or in
48-
other language.
47+
you will use a more advanced regular expression, it may not work with other library or in
48+
other languages.
4949
* JSON schema says you can use keyword ``default`` for providing default values. This implementation
5050
uses that and always returns transformed input data.
5151
@@ -65,7 +65,8 @@
6565
# pylint: disable=redefined-builtin,dangerous-default-value,exec-used
6666
def compile(definition, handlers={}):
6767
"""
68-
Generates validation function for validating JSON schema by ``definition``. Example:
68+
Generates validation function for validating JSON schema passed in ``definition``.
69+
Example:
6970
7071
.. code-block:: python
7172
@@ -102,7 +103,8 @@ def compile(definition, handlers={}):
102103
You can pass mapping from URI to function that should be used to retrieve
103104
remote schemes used in your ``definition`` in parameter ``handlers``.
104105
105-
Exception :any:`JsonSchemaException` is thrown when validation fails.
106+
Exception :any:`JsonSchemaException` is thrown when generation code fail
107+
(wrong definition) or validation fails (data does not follow definition).
106108
"""
107109
resolver, code_generator = _factory(definition, handlers)
108110
global_state = code_generator.global_state
@@ -114,8 +116,8 @@ def compile(definition, handlers={}):
114116
# pylint: disable=dangerous-default-value
115117
def compile_to_code(definition, handlers={}):
116118
"""
117-
Generates validation function for validating JSON schema by ``definition``
118-
and returns compiled code. Example:
119+
Generates validation code for validating JSON schema passed in ``definition``.
120+
Example:
119121
120122
.. code-block:: python
121123
@@ -131,8 +133,6 @@ def compile_to_code(definition, handlers={}):
131133
132134
echo "{'type': 'string'}" | python3 -m fastjsonschema > your_file.py
133135
python3 -m fastjsonschema "{'type': 'string'}" > your_file.py
134-
135-
Exception :any:`JsonSchemaException` is thrown when validation fails.
136136
"""
137137
_, code_generator = _factory(definition, handlers)
138138
return (

0 commit comments

Comments
 (0)