Skip to content

Commit

Permalink
Document jsonyx.tool
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Aug 2, 2024
1 parent e19ada7 commit 3d40277
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ Functions
.. autofunction:: jsonyx.loads
.. autofunction:: jsonyx.read
.. autofunction:: jsonyx.write
.. autofunction:: jsonyx.tool.register
.. autofunction:: jsonyx.tool.run

Classes
-------
Expand All @@ -202,6 +204,9 @@ Classes
.. autoclass:: jsonyx.Encoder
:members:

.. autoclass:: jsonyx.tool.JSONNamespace
:members:

Exceptions
----------

Expand Down
12 changes: 10 additions & 2 deletions src/jsonyx/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class JSONNamespace:


def register(parser: ArgumentParser) -> None:
"""Register JSON tool."""
"""Register JSON tool.
:param parser: an argument parser
:type parser: ArgumentParser
"""
parser.add_argument(
"filename",
nargs="?",
Expand Down Expand Up @@ -79,7 +83,11 @@ def register(parser: ArgumentParser) -> None:


def run(args: JSONNamespace) -> None:
"""Run JSON tool."""
"""Run JSON tool.
:param args: the commandline arguments
:type args: JSONNamespace
"""
if args.filename:
filename: str = args.filename
s: bytes | str = Path(filename).read_bytes()
Expand Down

0 comments on commit 3d40277

Please sign in to comment.