From b051c4d3b54a0bed57aa8a6493f51992d7612893 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Tue, 20 Aug 2024 17:17:01 +0200 Subject: [PATCH] Update documentation --- docs/source/usage.rst | 4 ++-- src/jsonyx/__main__.py | 5 +++-- src/jsonyx/_differ.py | 4 ++-- src/jsonyx/test/test_jsonyx.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 4d1e9f3..2732bb2 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -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:: diff --git a/src/jsonyx/__main__.py b/src/jsonyx/__main__.py index 7c989e9..eb23dd0 100644 --- a/src/jsonyx/__main__.py +++ b/src/jsonyx/__main__.py @@ -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( diff --git a/src/jsonyx/_differ.py b/src/jsonyx/_differ.py index 3d58b87..38a3e8d 100644 --- a/src/jsonyx/_differ.py +++ b/src/jsonyx/_differ.py @@ -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 @@ -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 diff --git a/src/jsonyx/test/test_jsonyx.py b/src/jsonyx/test/test_jsonyx.py index 91e03f6..808b28c 100644 --- a/src/jsonyx/test/test_jsonyx.py +++ b/src/jsonyx/test/test_jsonyx.py @@ -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