From ed5026eb916135b99dcce1e9b820c161dd670812 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Jan 2024 00:28:51 +0100 Subject: [PATCH] add some more documentation --- CHANGELOG.md | 3 +++ README.md | 5 +++-- docs/api.rst | 1 + docs/api/countdown.rst | 7 +++++++ docs/api/util.rst | 6 +++--- docs/index.rst | 1 + spacepackets/countdown.py | 3 +++ 7 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 docs/api/countdown.rst diff --git a/CHANGELOG.md b/CHANGELOG.md index e22ffb9..6e619a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added - Added `ByteFieldU64` variant. +- Added `spacepackets.countdown` utility module. This class was moved from + `tmtccmd.util.countdown` and contains the `Countdown` class. It was moved here so it can + be re-used more easily. # [v0.22.0] 2023-12-22 diff --git a/README.md b/README.md index 9eebc4a..54cedf3 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ Currently, this includes the following components: It also contains various helper modules -- `PusVerificator` module to track the verification of sent telecommands -- [PTC and PFC definitions](https://spacepackets.readthedocs.io/en/latest/api/ecss.html#module-spacepackets.ecss.fields) for ECSS packets +- `PusVerificator` module to track the verification of sent telecommands. +- [PTC and PFC definitions](https://spacepackets.readthedocs.io/en/latest/api/ecss.html#module-spacepackets.ecss.fields) for ECSS packets. +- `Countdown` utility class. # Install diff --git a/docs/api.rst b/docs/api.rst index 6681c8d..8aeea7f 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -28,4 +28,5 @@ This package also uses the :py:mod:`logging` package to emit warnings. api/cfdp_pdu api/cfdp_tlv api/uslp + api/countdown api/util diff --git a/docs/api/countdown.rst b/docs/api/countdown.rst new file mode 100644 index 0000000..aa07e15 --- /dev/null +++ b/docs/api/countdown.rst @@ -0,0 +1,7 @@ +Countdown Module +================ + +.. automodule:: spacepackets.countdown + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/util.rst b/docs/api/util.rst index 8866776..58fb47f 100644 --- a/docs/api/util.rst +++ b/docs/api/util.rst @@ -2,6 +2,6 @@ Utility Module ================ .. automodule:: spacepackets.util - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/index.rst b/docs/index.rst index 7e6161c..7878835 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,6 +28,7 @@ It also contains various helper modules - :py:class:`spacepackets.ecss.pus_verificator.PusVerificator` class to track the verification of sent telecommands - PTC and PFC definitions for ECSS packets inside the :py:mod:`spacepackets.ecss.fields` module +- :py:class:`spacepackets.countdown.Countdown` utility class Other pages (online) --------------------- diff --git a/spacepackets/countdown.py b/spacepackets/countdown.py index 8155589..9f913fe 100644 --- a/spacepackets/countdown.py +++ b/spacepackets/countdown.py @@ -5,10 +5,13 @@ def time_ms() -> int: + """Returns the current :py:func:`time.time` as milliseconds.""" return round(time.time() * 1000) class Countdown: + """Utility class for counting down time. Exposes a simple API to initiate + it with an initial timeout and to check whether is has expired.""" def __init__(self, init_timeout: Optional[timedelta]): if init_timeout is not None: self._timeout_ms = int(init_timeout / timedelta(milliseconds=1))