Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Aug 20, 2024
1 parent d803c2e commit b051c4d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ Using :class:`decimal.Decimal` instead of :class:`float`::
>>> json.dump(Decimal("1.1"))
1.1

Making a patch::
Comparing two Python objects::

>>> import jsonyx as json
>>> json.make_patch([1, 2, 3, 5], [1, 3, 4, 5])
>>> json.diff([1, 2, 3, 5], [1, 3, 4, 5])
[{'op': 'del', 'path': '$[1]'}, {'op': 'insert', 'path': '$[2]', 'value': 4}]

Applying a patch::
Expand Down
5 changes: 3 additions & 2 deletions src/jsonyx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ def _register(parser: ArgumentParser) -> None:

diff_parser = commands.add_parser(
"diff",
help="make a JSON patch from two JSON files.",
description="make a JSON patch from two JSON files.",
help="compare two JSON files and generate a diff in JSON patch format.",
description="compare two JSON files and generate a diff in JSON patch "
"format.",
parents=[parent_parser],
)
diff_parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions src/jsonyx/_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _diff( # noqa: C901


def diff(old: Any, new: Any) -> list[dict[str, Any]]:
"""Make a JSON patch from two Python objects.
"""Compare two Python objects and generate a diff in JSON patch format.
:param old: the old Python object
:type old: Any
Expand All @@ -129,7 +129,7 @@ def diff(old: Any, new: Any) -> list[dict[str, Any]]:
:rtype: list[dict[str, Any]]
>>> import jsonyx as json
>>> json.make_patch([1, 2, 3, 5], [1, 3, 4, 5])
>>> json.diff([1, 2, 3, 5], [1, 3, 4, 5])
[{'op': 'del', 'path': '$[1]'}, {'op': 'insert', 'path': '$[2]', 'value': 4}]
.. versionadded:: 2.0
Expand Down
2 changes: 1 addition & 1 deletion src/jsonyx/test/test_jsonyx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2024 Nice Zombies
# TODO(Nice Zombies): test apply_patch
# TODO(Nice Zombies): test diff
# TODO(Nice Zombies): test load query value
# TODO(Nice Zombies): test make_patch
# TODO(Nice Zombies): test run_filter_query
# TODO(Nice Zombies): test run_select_query
# TODO(Nice Zombies): test schema
Expand Down

0 comments on commit b051c4d

Please sign in to comment.