Skip to content

Update API Documentation with Missing Modules and Functions #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@ run_build:
deploy:
pipenv run python -m twine upload -r "pypi" --config-file .pypirc 'dist/*'

.PHONY: precommit test coverage run_build deploy
generate-api-docs:
# Install required dependencies if not present
pip install doxypypy
# Create virtual environment directory if it doesn't exist
mkdir -p env/bin
# Create activation script if it doesn't exist
if [ ! -f env/bin/activate ]; then \
echo '#!/bin/bash' > env/bin/activate; \
echo 'export PATH=$$PATH:/home/ubuntu/.local/bin' >> env/bin/activate; \
chmod +x env/bin/activate; \
fi
# Generate documentation
doxygen Doxyfile
moxygen --output docs/api.md docs/xml

.PHONY: precommit test coverage run_build deploy generate-api-docs
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ iso8601 = "==0.1.12"
pyserial = "==3.4"
python-periphery = "==2.3.0"
pyyaml = "==6.0.1"
flake8 = "==6.1.0"
pytest = "==8.3.4"
pydocstyle = "==5.0.2"
packaging = ">=20.4"
coveralls = "==3.3.1"
ddtrace = "==2.21.1"
Expand All @@ -23,3 +21,5 @@ build = "*"
twine = "*"
pre-commit = "*"
exceptiongroup = "*" # Python 3.9 & 3.10 compatibility with pytest
pydocstyle = "*"
flake8 = "*"
34 changes: 17 additions & 17 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

692 changes: 636 additions & 56 deletions docs/api.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion notecard/binary_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Helper methods for doing binary transfers to/from a Notecard."""
"""Helper methods for performing binary transfers to and from a Notecard.

This module provides functions for working with the Notecard's binary data store,
including reading, writing, and managing binary data with CRC verification.
"""

import sys
from notecard.cobs import cobs_encode, cobs_decode
Expand Down
7 changes: 6 additions & 1 deletion notecard/cobs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Methods for COBS encoding and decoding arbitrary bytearrays."""
"""Functions for COBS encoding and decoding of bytearrays.

This module implements Consistent Overhead Byte Stuffing (COBS), an encoding
that eliminates zero bytes from arbitrary binary data. The Notecard uses this
for binary data transfers to ensure reliable transmission.
"""


def cobs_encode(data: bytearray, eop: int) -> bytearray:
Expand Down
6 changes: 5 additions & 1 deletion notecard/crc32.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Module for computing the CRC32 of arbitrary data."""
"""Functions for computing CRC32 checksums.

This module provides a lightweight implementation of the CRC32 algorithm
for verifying data integrity in Notecard communications.
"""

crc32_lookup_table = [
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 0x76DC4190, 0x6B6B51F4,
Expand Down
7 changes: 6 additions & 1 deletion notecard/md5.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Module for computing MD5 hash for MicroPython and CircuitPython."""
"""Functions for computing MD5 hashes.

This module provides a lightweight implementation of the MD5 algorithm
for MicroPython and CircuitPython platforms, used for data verification
in Notecard binary transfers.
"""

"""
Copyright [2018] [Mauro Riva <[email protected]> <lemariva.com>]
Expand Down
27 changes: 23 additions & 4 deletions notecard/notecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,21 +402,40 @@ def Command(self, req):
self.Transaction(req)

def GetUserAgent(self):
"""Return the User Agent String for the host for debug purposes."""
"""Return the User Agent String for the host for debug purposes.

Returns:
dict: A dictionary containing user agent information including OS details
and any application-specific user agent information.
"""
ua_copy = self._user_agent.copy()
ua_copy.update(self._user_agent_app or {})
return ua_copy

def SetAppUserAgent(self, app_user_agent):
"""Set the User Agent info for the app."""
"""Set the User Agent info for the app.

Args:
app_user_agent (dict): Dictionary containing application-specific
user agent information.
"""
self._user_agent_app = app_user_agent

def UserAgentSent(self):
"""Return true if the User Agent has been sent to the Notecard."""
"""Return true if the User Agent has been sent to the Notecard.

Returns:
bool: True if the User Agent has been sent to the Notecard, False otherwise.
"""
return self._user_agent_sent

def SetTransactionPins(self, rtx_pin, ctx_pin):
"""Set the pins used for RTX and CTX."""
"""Set the pins used for RTX and CTX.

Args:
rtx_pin: The pin to use for Ready To Transact (RTX) signaling.
ctx_pin: The pin to use for Clear To Transact (CTX) signaling.
"""
self._transaction_manager = TransactionManager(rtx_pin, ctx_pin)


Expand Down
6 changes: 5 additions & 1 deletion notecard/timeout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Module for managing timeouts in note-python."""
"""Functions for managing timeouts.

This module provides cross-platform timeout management for Notecard communications,
supporting different timing mechanisms for CPython, MicroPython, and CircuitPython.
"""

import sys
import time
Expand Down
7 changes: 6 additions & 1 deletion notecard/transaction_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""TransactionManager-related code for note-python."""
"""Classes for managing Notecard transactions.

This module provides transaction management for Notecard communications,
implementing the RTX/CTX protocol for reliable data exchange between
the host and Notecard.
"""

import sys
import time
Expand Down