Skip to content

Commit

Permalink
Remove function parameters and return value in docstring.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed May 30, 2018
1 parent 26f59ee commit e9dd3f3
Showing 1 changed file with 7 additions and 62 deletions.
69 changes: 7 additions & 62 deletions bitstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ class CompiledFormat(object):
Instances of this class are created by the factory function
:func:`~bitstruct.compile()`.
:param fmt: Bitstruct format string. See :func:`~bitstruct.pack()`
for details.
"""

def __init__(self, fmt):
Expand Down Expand Up @@ -195,9 +192,6 @@ def pack(self, *args):
of bits are not a multiple of 8, padding will be added at the
end of the last byte.
:param args: Variable argument list of values to pack.
:returns: A byte string of the packed values.
"""

bits = ''
Expand Down Expand Up @@ -232,9 +226,6 @@ def unpack(self, data):
according to the compiled format string. The result is a tuple
even if it contains exactly one item.
:param data: Byte string of values to unpack.
:returns: A tuple of the unpacked values.
"""

return self.unpack_from(data)
Expand All @@ -244,12 +235,6 @@ def pack_into(self, buf, offset, *args, **kwargs):
offset `offset`. Give `fill_padding` as ``False`` to leave
padding bits in `buf` unmodified.
:param buf: Buffer to pack data into.
:param offset: Bit offset to start at.
:param args: Variable argument list of values to pack.
:param fill_padding: A boolean to control if padding should
overwrite bits in `buf`.
"""

# Sanity check of the number of arguments.
Expand Down Expand Up @@ -292,10 +277,6 @@ def unpack_from(self, data, offset=0):
offset `offset`. The result is a tuple even if it contains
exactly one item.
:param data: Byte string of values to unpack.
:param offset: Bit offset to start unpack from.
:returns: A tuple of the unpacked values.
"""

bits = bin(int(b'01' + binascii.hexlify(bytearray(data)), 16))[3 + offset:]
Expand Down Expand Up @@ -356,9 +337,7 @@ def unpack_from(self, data, offset=0):
return tuple(res)

def calcsize(self):
"""Calculate the number of bits in the compiled format string.
:returns: Number of bits in the format string.
"""Return the number of bits in the compiled format string.
"""

Expand All @@ -371,10 +350,6 @@ def pack(fmt, *args):
bits are not a multiple of 8, padding will be added at the end of
the last byte.
:param fmt: Bitstruct format string. See format description below.
:param args: Variable argument list of values to pack.
:returns: A byte string of the packed values.
`fmt` is a string of bitorder-type-length groups, and optionally a
byteorder identifier after the groups. Bitorder and byteorder may
be omitted.
Expand Down Expand Up @@ -423,11 +398,6 @@ def unpack(fmt, data):
according to given format string `fmt`. The result is a tuple even
if it contains exactly one item.
:param fmt: Bitstruct format string. See :func:`~bitstruct.pack()`
for details.
:param data: Byte string of values to unpack.
:returns: A tuple of the unpacked values.
"""

return CompiledFormat(fmt).unpack(data)
Expand All @@ -439,13 +409,6 @@ def pack_into(fmt, buf, offset, *args, **kwargs):
`fill_padding` as ``False`` to leave padding bits in `buf`
unmodified.
:param fmt: Bitstruct format string. See format description below.
:param buf: Buffer to pack data into.
:param offset: Bit offset to start at.
:param args: Variable argument list of values to pack.
:param fill_padding: A boolean to control if padding should
overwrite bits in `buf`.
"""

return CompiledFormat(fmt).pack_into(buf,
Expand All @@ -460,40 +423,25 @@ def unpack_from(fmt, data, offset=0):
offset `offset`. The result is a tuple even if it contains exactly
one item.
:param fmt: Bitstruct format string. See :func:`~bitstruct.pack()`
for details.
:param data: Byte string of values to unpack.
:param offset: Bit offset to start unpack from.
:returns: A tuple of the unpacked values.
"""

return CompiledFormat(fmt).unpack_from(data, offset)


def calcsize(fmt):
"""Calculate the number of bits in given format string `fmt`.
:param fmt: Bitstruct format string. See :func:`~bitstruct.pack()`
for details.
:returns: Number of bits in format string.
"""Return the number of bits in given format string `fmt`.
"""

return CompiledFormat(fmt).calcsize()


def byteswap(fmt, data, offset=0):
"""Swap bytes in `data` according to `fmt`, starting at byte
`offset`. `fmt` must be an iterable, iterating over number of
bytes to swap. For example, the format string ``'24'`` applied to
the byte string ``b'\\x00\\x11\\x22\\x33\\x44\\x55'`` will produce
the result ``b'\\x11\\x00\\x55\\x44\\x33\\x22'``.
:param fmt: Swap format string.
:param data: Byte string of data to swap.
:param offset: Start offset into `data`.
:returns: Byte string of swapped bytes.
"""Swap bytes in `data` according to `fmt`, starting at byte `offset`
and return the result. `fmt` must be an iterable, iterating over
number of bytes to swap. For example, the format string ``'24'``
applied to the byte string ``b'\\x00\\x11\\x22\\x33\\x44\\x55'``
will produce the result ``b'\\x11\\x00\\x55\\x44\\x33\\x22'``.
"""

Expand All @@ -513,9 +461,6 @@ def compile(fmt):
:class:`~bitstruct.CompiledFormat` object that can be used to pack
and/or unpack data multiple times.
:param fmt: Bitstruct format string. See :func:`~bitstruct.pack()`
for details.
"""

return CompiledFormat(fmt)

2 comments on commit e9dd3f3

@danielhrisca
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@eerimoq
Copy link
Owner Author

@eerimoq eerimoq commented on e9dd3f3 May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very few, if any, modules in the Python standard library has parameters and return value listed in the documentation, so I figured I'll follow that pattern. Instead, the parameters are described in "normal text".

Please sign in to comment.