From e59bf5af941637130a06b17a793eb4a74774b1cc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 21:06:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20[code=20health=20improvement]=20?= =?UTF-8?q?add=20decode=20docstrings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What: Replaced a TODO comment in buildDecodeParts with the actual logic to generate docstrings for the partial decode functions. Why: Adding docstrings to the generated decode functions makes the generated code much more maintainable and readable. Verification: The change passes all tests and code review, and follows the existing Epydoc docstring formatting used in the project. Result: The generated decode functions now come with clear documentation strings describing their inputs, outputs, and descriptions. --- src/noaadata/cli/aisxmlbinmsg2py.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/noaadata/cli/aisxmlbinmsg2py.py b/src/noaadata/cli/aisxmlbinmsg2py.py index 2d1db91..7ce1393 100755 --- a/src/noaadata/cli/aisxmlbinmsg2py.py +++ b/src/noaadata/cli/aisxmlbinmsg2py.py @@ -2968,7 +2968,6 @@ def buildDecodeParts(o, msgET, verbose=False, prefixName=False): Returns: None - TODO(schwehr):FIX: doc strings for each decode! TODO(schwehr):FIX: check for a dac,fid, or efid. If exists, then this is an AIS Msg 8 payload TODO(schwehr):May want to take a dictionary of already decoded fields to speed things that need prior info for things like variable length arrays @@ -2992,6 +2991,32 @@ def buildDecodeParts(o, msgET, verbose=False, prefixName=False): type = field.attrib["type"] o.write("def " + baseName + name + "(bv, validate=False):\n") + + # doc string + desc = field[0].text.replace("\n", " ") # get ride of new lines + o.write( + " '''Decode part " + + name + + " for " + + msgET.attrib["name"] + + " message.\n\n" + ) + o.write(" - " + name + "(" + type + "): " + desc) + if len(field.xpath("required")) == 1: + o.write( + ' (field automatically set to "' + + field.xpath("required")[0].text + + '")' + ) + o.write("\n") + o.write(" @type bv: BitVector\n") + o.write(" @param bv: Bits defining a message\n") + o.write(" @type validate: bool\n") + o.write(" @param validate: Set to true to cause checking to occur\n") + o.write(" @rtype: dict\n") + o.write(" @return: dict with one key set to the decoded value\n") + o.write(" '''\n") + # Follow the same convention of decoding into a dict so that code is the same # o.write(' r={};') o.write(" return ")